@kruntime/komputer 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/README.md +368 -0
- package/dist/agent/approvals.d.ts +28 -0
- package/dist/agent/approvals.js +109 -0
- package/dist/agent/approvals.js.map +1 -0
- package/dist/agent/messages.d.ts +67 -0
- package/dist/agent/messages.js +213 -0
- package/dist/agent/messages.js.map +1 -0
- package/dist/agent/recovery.d.ts +13 -0
- package/dist/agent/recovery.js +112 -0
- package/dist/agent/recovery.js.map +1 -0
- package/dist/agent/session-utils.d.ts +17 -0
- package/dist/agent/session-utils.js +77 -0
- package/dist/agent/session-utils.js.map +1 -0
- package/dist/agent-session.d.ts +303 -0
- package/dist/agent-session.js +3031 -0
- package/dist/agent-session.js.map +1 -0
- package/dist/authority.d.ts +34 -0
- package/dist/authority.js +105 -0
- package/dist/authority.js.map +1 -0
- package/dist/content.d.ts +17 -0
- package/dist/content.js +69 -0
- package/dist/content.js.map +1 -0
- package/dist/cron.d.ts +20 -0
- package/dist/cron.js +25 -0
- package/dist/cron.js.map +1 -0
- package/dist/drive.d.ts +198 -0
- package/dist/drive.js +656 -0
- package/dist/drive.js.map +1 -0
- package/dist/events.d.ts +20 -0
- package/dist/events.js +149 -0
- package/dist/events.js.map +1 -0
- package/dist/fs-mode.d.ts +9 -0
- package/dist/fs-mode.js +98 -0
- package/dist/fs-mode.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/komputer.d.ts +123 -0
- package/dist/komputer.js +733 -0
- package/dist/komputer.js.map +1 -0
- package/dist/kstate.d.ts +107 -0
- package/dist/kstate.js +529 -0
- package/dist/kstate.js.map +1 -0
- package/dist/model.d.ts +81 -0
- package/dist/model.js +824 -0
- package/dist/model.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/path.d.ts +4 -0
- package/dist/path.js +38 -0
- package/dist/path.js.map +1 -0
- package/dist/pool.d.ts +56 -0
- package/dist/pool.js +172 -0
- package/dist/pool.js.map +1 -0
- package/dist/receipts.d.ts +44 -0
- package/dist/receipts.js +35 -0
- package/dist/receipts.js.map +1 -0
- package/dist/remote-node.d.ts +2 -0
- package/dist/remote-node.js +122 -0
- package/dist/remote-node.js.map +1 -0
- package/dist/remote.d.ts +84 -0
- package/dist/remote.js +11 -0
- package/dist/remote.js.map +1 -0
- package/dist/sandbox.d.ts +4 -0
- package/dist/sandbox.js +70 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/shell/builtins/catalog.d.ts +6 -0
- package/dist/shell/builtins/catalog.js +12 -0
- package/dist/shell/builtins/catalog.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/basename.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/basename.js +23 -0
- package/dist/shell/builtins/commands/filesystem/basename.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/cat.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/cat.js +85 -0
- package/dist/shell/builtins/commands/filesystem/cat.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/cd.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/cd.js +14 -0
- package/dist/shell/builtins/commands/filesystem/cd.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/chmod.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/chmod.js +46 -0
- package/dist/shell/builtins/commands/filesystem/chmod.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/copy-directory.d.ts +4 -0
- package/dist/shell/builtins/commands/filesystem/copy-directory.js +48 -0
- package/dist/shell/builtins/commands/filesystem/copy-directory.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/cp.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/cp.js +92 -0
- package/dist/shell/builtins/commands/filesystem/cp.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/dirname.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/dirname.js +23 -0
- package/dist/shell/builtins/commands/filesystem/dirname.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/du.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/du.js +93 -0
- package/dist/shell/builtins/commands/filesystem/du.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/find.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/find.js +111 -0
- package/dist/shell/builtins/commands/filesystem/find.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/install.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/install.js +89 -0
- package/dist/shell/builtins/commands/filesystem/install.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/ln.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/ln.js +57 -0
- package/dist/shell/builtins/commands/filesystem/ln.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/ls.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/ls.js +153 -0
- package/dist/shell/builtins/commands/filesystem/ls.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/mkdir.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/mkdir.js +41 -0
- package/dist/shell/builtins/commands/filesystem/mkdir.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/mktemp.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/mktemp.js +94 -0
- package/dist/shell/builtins/commands/filesystem/mktemp.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/mv.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/mv.js +41 -0
- package/dist/shell/builtins/commands/filesystem/mv.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/pwd.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/pwd.js +2 -0
- package/dist/shell/builtins/commands/filesystem/pwd.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/realpath.d.ts +3 -0
- package/dist/shell/builtins/commands/filesystem/realpath.js +61 -0
- package/dist/shell/builtins/commands/filesystem/realpath.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/rm.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/rm.js +38 -0
- package/dist/shell/builtins/commands/filesystem/rm.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/stat.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/stat.js +141 -0
- package/dist/shell/builtins/commands/filesystem/stat.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem/touch.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem/touch.js +143 -0
- package/dist/shell/builtins/commands/filesystem/touch.js.map +1 -0
- package/dist/shell/builtins/commands/filesystem.d.ts +2 -0
- package/dist/shell/builtins/commands/filesystem.js +44 -0
- package/dist/shell/builtins/commands/filesystem.js.map +1 -0
- package/dist/shell/builtins/commands/network/curl.d.ts +2 -0
- package/dist/shell/builtins/commands/network/curl.js +25 -0
- package/dist/shell/builtins/commands/network/curl.js.map +1 -0
- package/dist/shell/builtins/commands/network/http.d.ts +27 -0
- package/dist/shell/builtins/commands/network/http.js +226 -0
- package/dist/shell/builtins/commands/network/http.js.map +1 -0
- package/dist/shell/builtins/commands/network/wget.d.ts +2 -0
- package/dist/shell/builtins/commands/network/wget.js +32 -0
- package/dist/shell/builtins/commands/network/wget.js.map +1 -0
- package/dist/shell/builtins/commands/network.d.ts +2 -0
- package/dist/shell/builtins/commands/network.js +9 -0
- package/dist/shell/builtins/commands/network.js.map +1 -0
- package/dist/shell/builtins/commands/process/bg.d.ts +2 -0
- package/dist/shell/builtins/commands/process/bg.js +10 -0
- package/dist/shell/builtins/commands/process/bg.js.map +1 -0
- package/dist/shell/builtins/commands/process/fg.d.ts +2 -0
- package/dist/shell/builtins/commands/process/fg.js +14 -0
- package/dist/shell/builtins/commands/process/fg.js.map +1 -0
- package/dist/shell/builtins/commands/process/jobs.d.ts +2 -0
- package/dist/shell/builtins/commands/process/jobs.js +8 -0
- package/dist/shell/builtins/commands/process/jobs.js.map +1 -0
- package/dist/shell/builtins/commands/process/jobspec.d.ts +4 -0
- package/dist/shell/builtins/commands/process/jobspec.js +20 -0
- package/dist/shell/builtins/commands/process/jobspec.js.map +1 -0
- package/dist/shell/builtins/commands/process/kill.d.ts +2 -0
- package/dist/shell/builtins/commands/process/kill.js +35 -0
- package/dist/shell/builtins/commands/process/kill.js.map +1 -0
- package/dist/shell/builtins/commands/process/ps.d.ts +2 -0
- package/dist/shell/builtins/commands/process/ps.js +6 -0
- package/dist/shell/builtins/commands/process/ps.js.map +1 -0
- package/dist/shell/builtins/commands/process/sleep.d.ts +2 -0
- package/dist/shell/builtins/commands/process/sleep.js +6 -0
- package/dist/shell/builtins/commands/process/sleep.js.map +1 -0
- package/dist/shell/builtins/commands/process/wait.d.ts +2 -0
- package/dist/shell/builtins/commands/process/wait.js +21 -0
- package/dist/shell/builtins/commands/process/wait.js.map +1 -0
- package/dist/shell/builtins/commands/process.d.ts +2 -0
- package/dist/shell/builtins/commands/process.js +19 -0
- package/dist/shell/builtins/commands/process.js.map +1 -0
- package/dist/shell/builtins/commands/system/command.d.ts +2 -0
- package/dist/shell/builtins/commands/system/command.js +42 -0
- package/dist/shell/builtins/commands/system/command.js.map +1 -0
- package/dist/shell/builtins/commands/system/date.d.ts +2 -0
- package/dist/shell/builtins/commands/system/date.js +121 -0
- package/dist/shell/builtins/commands/system/date.js.map +1 -0
- package/dist/shell/builtins/commands/system/env.d.ts +2 -0
- package/dist/shell/builtins/commands/system/env.js +84 -0
- package/dist/shell/builtins/commands/system/env.js.map +1 -0
- package/dist/shell/builtins/commands/system/export.d.ts +2 -0
- package/dist/shell/builtins/commands/system/export.js +18 -0
- package/dist/shell/builtins/commands/system/export.js.map +1 -0
- package/dist/shell/builtins/commands/system/false.d.ts +2 -0
- package/dist/shell/builtins/commands/system/false.js +4 -0
- package/dist/shell/builtins/commands/system/false.js.map +1 -0
- package/dist/shell/builtins/commands/system/help.d.ts +2 -0
- package/dist/shell/builtins/commands/system/help.js +38 -0
- package/dist/shell/builtins/commands/system/help.js.map +1 -0
- package/dist/shell/builtins/commands/system/hostname.d.ts +2 -0
- package/dist/shell/builtins/commands/system/hostname.js +6 -0
- package/dist/shell/builtins/commands/system/hostname.js.map +1 -0
- package/dist/shell/builtins/commands/system/id.d.ts +2 -0
- package/dist/shell/builtins/commands/system/id.js +55 -0
- package/dist/shell/builtins/commands/system/id.js.map +1 -0
- package/dist/shell/builtins/commands/system/printenv.d.ts +2 -0
- package/dist/shell/builtins/commands/system/printenv.js +22 -0
- package/dist/shell/builtins/commands/system/printenv.js.map +1 -0
- package/dist/shell/builtins/commands/system/read.d.ts +2 -0
- package/dist/shell/builtins/commands/system/read.js +75 -0
- package/dist/shell/builtins/commands/system/read.js.map +1 -0
- package/dist/shell/builtins/commands/system/resolve-command.d.ts +3 -0
- package/dist/shell/builtins/commands/system/resolve-command.js +34 -0
- package/dist/shell/builtins/commands/system/resolve-command.js.map +1 -0
- package/dist/shell/builtins/commands/system/set.d.ts +2 -0
- package/dist/shell/builtins/commands/system/set.js +49 -0
- package/dist/shell/builtins/commands/system/set.js.map +1 -0
- package/dist/shell/builtins/commands/system/sh.d.ts +2 -0
- package/dist/shell/builtins/commands/system/sh.js +55 -0
- package/dist/shell/builtins/commands/system/sh.js.map +1 -0
- package/dist/shell/builtins/commands/system/source.d.ts +2 -0
- package/dist/shell/builtins/commands/system/source.js +42 -0
- package/dist/shell/builtins/commands/system/source.js.map +1 -0
- package/dist/shell/builtins/commands/system/test-expression.d.ts +2 -0
- package/dist/shell/builtins/commands/system/test-expression.js +93 -0
- package/dist/shell/builtins/commands/system/test-expression.js.map +1 -0
- package/dist/shell/builtins/commands/system/test.d.ts +4 -0
- package/dist/shell/builtins/commands/system/test.js +19 -0
- package/dist/shell/builtins/commands/system/test.js.map +1 -0
- package/dist/shell/builtins/commands/system/true.d.ts +2 -0
- package/dist/shell/builtins/commands/system/true.js +2 -0
- package/dist/shell/builtins/commands/system/true.js.map +1 -0
- package/dist/shell/builtins/commands/system/type.d.ts +2 -0
- package/dist/shell/builtins/commands/system/type.js +77 -0
- package/dist/shell/builtins/commands/system/type.js.map +1 -0
- package/dist/shell/builtins/commands/system/uname.d.ts +2 -0
- package/dist/shell/builtins/commands/system/uname.js +39 -0
- package/dist/shell/builtins/commands/system/uname.js.map +1 -0
- package/dist/shell/builtins/commands/system/unset.d.ts +2 -0
- package/dist/shell/builtins/commands/system/unset.js +9 -0
- package/dist/shell/builtins/commands/system/unset.js.map +1 -0
- package/dist/shell/builtins/commands/system/which.d.ts +2 -0
- package/dist/shell/builtins/commands/system/which.js +38 -0
- package/dist/shell/builtins/commands/system/which.js.map +1 -0
- package/dist/shell/builtins/commands/system/whoami.d.ts +2 -0
- package/dist/shell/builtins/commands/system/whoami.js +6 -0
- package/dist/shell/builtins/commands/system/whoami.js.map +1 -0
- package/dist/shell/builtins/commands/system.d.ts +2 -0
- package/dist/shell/builtins/commands/system.js +49 -0
- package/dist/shell/builtins/commands/system.js.map +1 -0
- package/dist/shell/builtins/commands/text/awk.d.ts +2 -0
- package/dist/shell/builtins/commands/text/awk.js +8 -0
- package/dist/shell/builtins/commands/text/awk.js.map +1 -0
- package/dist/shell/builtins/commands/text/base64.d.ts +2 -0
- package/dist/shell/builtins/commands/text/base64.js +69 -0
- package/dist/shell/builtins/commands/text/base64.js.map +1 -0
- package/dist/shell/builtins/commands/text/cut.d.ts +2 -0
- package/dist/shell/builtins/commands/text/cut.js +35 -0
- package/dist/shell/builtins/commands/text/cut.js.map +1 -0
- package/dist/shell/builtins/commands/text/diff.d.ts +2 -0
- package/dist/shell/builtins/commands/text/diff.js +83 -0
- package/dist/shell/builtins/commands/text/diff.js.map +1 -0
- package/dist/shell/builtins/commands/text/echo.d.ts +2 -0
- package/dist/shell/builtins/commands/text/echo.js +6 -0
- package/dist/shell/builtins/commands/text/echo.js.map +1 -0
- package/dist/shell/builtins/commands/text/grep.d.ts +2 -0
- package/dist/shell/builtins/commands/text/grep.js +123 -0
- package/dist/shell/builtins/commands/text/grep.js.map +1 -0
- package/dist/shell/builtins/commands/text/head.d.ts +2 -0
- package/dist/shell/builtins/commands/text/head.js +8 -0
- package/dist/shell/builtins/commands/text/head.js.map +1 -0
- package/dist/shell/builtins/commands/text/jq.d.ts +2 -0
- package/dist/shell/builtins/commands/text/jq.js +239 -0
- package/dist/shell/builtins/commands/text/jq.js.map +1 -0
- package/dist/shell/builtins/commands/text/printf.d.ts +2 -0
- package/dist/shell/builtins/commands/text/printf.js +3 -0
- package/dist/shell/builtins/commands/text/printf.js.map +1 -0
- package/dist/shell/builtins/commands/text/sed.d.ts +2 -0
- package/dist/shell/builtins/commands/text/sed.js +21 -0
- package/dist/shell/builtins/commands/text/sed.js.map +1 -0
- package/dist/shell/builtins/commands/text/sha256sum.d.ts +2 -0
- package/dist/shell/builtins/commands/text/sha256sum.js +63 -0
- package/dist/shell/builtins/commands/text/sha256sum.js.map +1 -0
- package/dist/shell/builtins/commands/text/sort.d.ts +2 -0
- package/dist/shell/builtins/commands/text/sort.js +134 -0
- package/dist/shell/builtins/commands/text/sort.js.map +1 -0
- package/dist/shell/builtins/commands/text/tail.d.ts +2 -0
- package/dist/shell/builtins/commands/text/tail.js +10 -0
- package/dist/shell/builtins/commands/text/tail.js.map +1 -0
- package/dist/shell/builtins/commands/text/tee.d.ts +2 -0
- package/dist/shell/builtins/commands/text/tee.js +29 -0
- package/dist/shell/builtins/commands/text/tee.js.map +1 -0
- package/dist/shell/builtins/commands/text/tr.d.ts +2 -0
- package/dist/shell/builtins/commands/text/tr.js +3 -0
- package/dist/shell/builtins/commands/text/tr.js.map +1 -0
- package/dist/shell/builtins/commands/text/uniq.d.ts +2 -0
- package/dist/shell/builtins/commands/text/uniq.js +8 -0
- package/dist/shell/builtins/commands/text/uniq.js.map +1 -0
- package/dist/shell/builtins/commands/text/wc.d.ts +2 -0
- package/dist/shell/builtins/commands/text/wc.js +30 -0
- package/dist/shell/builtins/commands/text/wc.js.map +1 -0
- package/dist/shell/builtins/commands/text/xargs.d.ts +2 -0
- package/dist/shell/builtins/commands/text/xargs.js +138 -0
- package/dist/shell/builtins/commands/text/xargs.js.map +1 -0
- package/dist/shell/builtins/commands/text.d.ts +2 -0
- package/dist/shell/builtins/commands/text.js +41 -0
- package/dist/shell/builtins/commands/text.js.map +1 -0
- package/dist/shell/builtins/help-text.d.ts +69 -0
- package/dist/shell/builtins/help-text.js +381 -0
- package/dist/shell/builtins/help-text.js.map +1 -0
- package/dist/shell/builtins/path.d.ts +28 -0
- package/dist/shell/builtins/path.js +184 -0
- package/dist/shell/builtins/path.js.map +1 -0
- package/dist/shell/builtins/registry.d.ts +3 -0
- package/dist/shell/builtins/registry.js +75 -0
- package/dist/shell/builtins/registry.js.map +1 -0
- package/dist/shell/builtins/run.d.ts +4 -0
- package/dist/shell/builtins/run.js +29 -0
- package/dist/shell/builtins/run.js.map +1 -0
- package/dist/shell/builtins/runtime.d.ts +83 -0
- package/dist/shell/builtins/runtime.js +46 -0
- package/dist/shell/builtins/runtime.js.map +1 -0
- package/dist/shell/builtins/text.d.ts +90 -0
- package/dist/shell/builtins/text.js +970 -0
- package/dist/shell/builtins/text.js.map +1 -0
- package/dist/shell/control.d.ts +31 -0
- package/dist/shell/control.js +232 -0
- package/dist/shell/control.js.map +1 -0
- package/dist/shell/expansion.d.ts +30 -0
- package/dist/shell/expansion.js +514 -0
- package/dist/shell/expansion.js.map +1 -0
- package/dist/shell/functions.d.ts +10 -0
- package/dist/shell/functions.js +108 -0
- package/dist/shell/functions.js.map +1 -0
- package/dist/shell/runtime.d.ts +44 -0
- package/dist/shell/runtime.js +276 -0
- package/dist/shell/runtime.js.map +1 -0
- package/dist/shell/time.d.ts +1 -0
- package/dist/shell/time.js +68 -0
- package/dist/shell/time.js.map +1 -0
- package/dist/state-backend.d.ts +61 -0
- package/dist/state-backend.js +275 -0
- package/dist/state-backend.js.map +1 -0
- package/dist/state-node.d.ts +2 -0
- package/dist/state-node.js +266 -0
- package/dist/state-node.js.map +1 -0
- package/dist/types.d.ts +462 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +117 -0
- package/dist/utils.js.map +1 -0
- package/dist/vbash.d.ts +40 -0
- package/dist/vbash.js +389 -0
- package/dist/vbash.js.map +1 -0
- package/dist/vfs.d.ts +64 -0
- package/dist/vfs.js +248 -0
- package/dist/vfs.js.map +1 -0
- package/dist/vprocess.d.ts +139 -0
- package/dist/vprocess.js +756 -0
- package/dist/vprocess.js.map +1 -0
- package/package.json +28 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { filesystemBuiltins } from "./commands/filesystem.js";
|
|
2
|
+
import { networkBuiltins } from "./commands/network.js";
|
|
3
|
+
import { processBuiltins } from "./commands/process.js";
|
|
4
|
+
import { systemBuiltins } from "./commands/system.js";
|
|
5
|
+
import { textBuiltins } from "./commands/text.js";
|
|
6
|
+
import { registerBuiltinHelp } from "./catalog.js";
|
|
7
|
+
import { normalizeBuiltinEntry, normalizeBuiltinOutput } from "./runtime.js";
|
|
8
|
+
export { builtinErrorText } from "./runtime.js";
|
|
9
|
+
export { builtinHelp, builtinHelpEntries } from "./catalog.js";
|
|
10
|
+
const BUILTIN_ENTRIES = {
|
|
11
|
+
...filesystemBuiltins,
|
|
12
|
+
...textBuiltins,
|
|
13
|
+
...systemBuiltins,
|
|
14
|
+
...processBuiltins,
|
|
15
|
+
...networkBuiltins,
|
|
16
|
+
};
|
|
17
|
+
const BUILTIN_SPECS = Object.fromEntries(Object.entries(BUILTIN_ENTRIES).map(([name, entry]) => [name, normalizeBuiltinEntry(entry)]));
|
|
18
|
+
for (const [name, spec] of Object.entries(BUILTIN_SPECS))
|
|
19
|
+
registerBuiltinHelp(name, spec.help);
|
|
20
|
+
export async function runBuiltin(ctx, cmd, args, stdin = '', signal) {
|
|
21
|
+
const spec = BUILTIN_SPECS[cmd];
|
|
22
|
+
if (spec) {
|
|
23
|
+
if (args.length === 1 && args[0] === '--help' && spec.help)
|
|
24
|
+
return { stdout: `${spec.help}\n`, stderr: '', code: 0 };
|
|
25
|
+
return normalizeBuiltinOutput(await spec.handler(ctx, args, stdin, signal));
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`unknown K builtin: ${cmd}`);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../../../packages/komputer/src/shell/builtins/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,eAAe,GAAiC;IACpD,GAAG,kBAAkB;IACrB,GAAG,YAAY;IACf,GAAG,cAAc;IACjB,GAAG,eAAe;IAClB,GAAG,eAAe;CACnB,CAAA;AAED,MAAM,aAAa,GAAgC,MAAM,CAAC,WAAW,CACnE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7F,CAAA;AAED,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;IAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;AAE9F,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAmB,EAAE,GAAW,EAAE,IAAc,EAAE,KAAK,GAAG,EAAE,EAAE,MAAoB;IACjH,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;QACpH,OAAO,sBAAsB,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IAC7E,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { KFileSystem } from '../../vfs.js';
|
|
2
|
+
import type { RuntimeCommand, NetworkResponse } from '../../types.js';
|
|
3
|
+
import type { VJobRecord, VProcessRecord } from '../../vprocess.js';
|
|
4
|
+
import type { ShellOptions } from '../runtime.js';
|
|
5
|
+
export interface BuiltinRuntime {
|
|
6
|
+
cwd: string;
|
|
7
|
+
home: string;
|
|
8
|
+
agentName: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
fs: KFileSystem;
|
|
11
|
+
commands: Map<string, RuntimeCommand>;
|
|
12
|
+
functions: Set<string>;
|
|
13
|
+
shellPath(path: string): string;
|
|
14
|
+
cd(path: string): Promise<void>;
|
|
15
|
+
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
16
|
+
jobs(): Promise<VJobRecord[]>;
|
|
17
|
+
processes(): Promise<VProcessRecord[]>;
|
|
18
|
+
kill(target: string, signal?: string): Promise<VProcessRecord[]>;
|
|
19
|
+
wait(target: string): Promise<{
|
|
20
|
+
status: string;
|
|
21
|
+
vpid?: string;
|
|
22
|
+
jobId?: string;
|
|
23
|
+
receiptId?: string;
|
|
24
|
+
recovered?: boolean;
|
|
25
|
+
code?: number;
|
|
26
|
+
}>;
|
|
27
|
+
foreground(target: string): Promise<{
|
|
28
|
+
status: string;
|
|
29
|
+
vpid?: string;
|
|
30
|
+
jobId?: string;
|
|
31
|
+
receiptId?: string;
|
|
32
|
+
recovered?: boolean;
|
|
33
|
+
code?: number;
|
|
34
|
+
stdout?: string;
|
|
35
|
+
stderr?: string;
|
|
36
|
+
}>;
|
|
37
|
+
background(target: string): Promise<VProcessRecord>;
|
|
38
|
+
env(): Record<string, string>;
|
|
39
|
+
setEnv(name: string, value: string): Promise<void>;
|
|
40
|
+
unsetEnv(name: string): Promise<void>;
|
|
41
|
+
shellOptions(): ShellOptions;
|
|
42
|
+
setShellOptions(patch: Partial<ShellOptions>): Promise<void>;
|
|
43
|
+
fetchNetwork(url: string, init?: {
|
|
44
|
+
method?: string;
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
body?: string;
|
|
47
|
+
}): Promise<NetworkResponse>;
|
|
48
|
+
exec(script: string, options?: {
|
|
49
|
+
env?: Record<string, string>;
|
|
50
|
+
replaceEnv?: boolean;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<Record<string, unknown>>;
|
|
53
|
+
source(script: string, options?: {
|
|
54
|
+
env?: Record<string, string>;
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
}): Promise<Record<string, unknown>>;
|
|
57
|
+
trace(type: string, data: Record<string, unknown>): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export interface BuiltinResult {
|
|
60
|
+
stdout?: string;
|
|
61
|
+
stderr?: string;
|
|
62
|
+
code?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface NormalizedBuiltinResult {
|
|
65
|
+
stdout: string;
|
|
66
|
+
stderr: string;
|
|
67
|
+
code: number;
|
|
68
|
+
}
|
|
69
|
+
export type BuiltinOutput = string | BuiltinResult;
|
|
70
|
+
export type BuiltinHandler = (ctx: BuiltinRuntime, args: string[], stdin: string, signal?: AbortSignal) => Promise<BuiltinOutput> | BuiltinOutput;
|
|
71
|
+
export interface BuiltinSpec {
|
|
72
|
+
handler: BuiltinHandler;
|
|
73
|
+
help: string;
|
|
74
|
+
}
|
|
75
|
+
export type BuiltinEntry = BuiltinHandler | BuiltinSpec;
|
|
76
|
+
export declare function builtinSpec(handler: BuiltinHandler, help: string): BuiltinSpec;
|
|
77
|
+
export declare function normalizeBuiltinEntry(entry: BuiltinEntry): BuiltinSpec;
|
|
78
|
+
export declare function normalizeBuiltinOutput(output: BuiltinOutput): NormalizedBuiltinResult;
|
|
79
|
+
export declare function readBuiltinInput(ctx: BuiltinRuntime, paths: string[], stdin?: string): Promise<string>;
|
|
80
|
+
export declare function quoteEnvValue(value: string): string;
|
|
81
|
+
export declare function quoteShellWord(value: string): string;
|
|
82
|
+
export declare function unsupportedOption(command: string, option: string): Error;
|
|
83
|
+
export declare function builtinErrorText(cmd: string, error: unknown): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function builtinSpec(handler, help) {
|
|
2
|
+
return { handler, help: help.trim() };
|
|
3
|
+
}
|
|
4
|
+
export function normalizeBuiltinEntry(entry) {
|
|
5
|
+
return typeof entry === 'function' ? { handler: entry, help: '' } : entry;
|
|
6
|
+
}
|
|
7
|
+
export function normalizeBuiltinOutput(output) {
|
|
8
|
+
if (typeof output === 'string')
|
|
9
|
+
return { stdout: output, stderr: '', code: 0 };
|
|
10
|
+
return {
|
|
11
|
+
stdout: output.stdout || '',
|
|
12
|
+
stderr: output.stderr || '',
|
|
13
|
+
code: output.code ?? 0,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export async function readBuiltinInput(ctx, paths, stdin = '') {
|
|
17
|
+
if (!paths.length)
|
|
18
|
+
return stdin;
|
|
19
|
+
const chunks = [];
|
|
20
|
+
for (const path of paths)
|
|
21
|
+
chunks.push(path === '-' ? stdin : await ctx.fs.readText(ctx.shellPath(path)));
|
|
22
|
+
return chunks.join('');
|
|
23
|
+
}
|
|
24
|
+
export function quoteEnvValue(value) {
|
|
25
|
+
if (/^[A-Za-z0-9_./:@%+=,-]*$/.test(value))
|
|
26
|
+
return value;
|
|
27
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
28
|
+
}
|
|
29
|
+
export function quoteShellWord(value) {
|
|
30
|
+
if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value))
|
|
31
|
+
return value;
|
|
32
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
33
|
+
}
|
|
34
|
+
export function unsupportedOption(command, option) {
|
|
35
|
+
return new Error(`${command}: unsupported option: ${option}`);
|
|
36
|
+
}
|
|
37
|
+
export function builtinErrorText(cmd, error) {
|
|
38
|
+
if (cmd === 'false' || cmd === 'test' || cmd === '[' || cmd === '[[')
|
|
39
|
+
return '';
|
|
40
|
+
if (cmd === 'grep' && error instanceof Error && error.message === 'grep:no-match')
|
|
41
|
+
return '';
|
|
42
|
+
if (cmd === 'command' && error instanceof Error && error.message === 'command:not-found')
|
|
43
|
+
return '';
|
|
44
|
+
return error instanceof Error ? error.message : String(error);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../../../packages/komputer/src/shell/builtins/runtime.ts"],"names":[],"mappings":"AAuDA,MAAM,UAAU,WAAW,CAAC,OAAuB,EAAE,IAAY;IAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAmB;IACvD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AAC3E,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAqB;IAC1D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IAC9E,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC;KACvB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAmB,EAAE,KAAe,EAAE,KAAK,GAAG,EAAE;IACrF,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAC/B,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxG,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACxD,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACxD,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,MAAc;IAC/D,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,yBAAyB,MAAM,EAAE,CAAC,CAAA;AAC/D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,KAAc;IAC1D,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IAC/E,IAAI,GAAG,KAAK,MAAM,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe;QAAE,OAAO,EAAE,CAAA;IAC5F,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,mBAAmB;QAAE,OAAO,EAAE,CAAA;IACnG,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface GrepArgs {
|
|
2
|
+
patterns: string[];
|
|
3
|
+
paths: string[];
|
|
4
|
+
fixedStrings: boolean;
|
|
5
|
+
ignoreCase: boolean;
|
|
6
|
+
invert: boolean;
|
|
7
|
+
lineNumber: boolean;
|
|
8
|
+
recursive: boolean;
|
|
9
|
+
count: boolean;
|
|
10
|
+
filesWithMatches: boolean;
|
|
11
|
+
quiet: boolean;
|
|
12
|
+
onlyMatching: boolean;
|
|
13
|
+
noFilename: boolean;
|
|
14
|
+
withFilename: boolean;
|
|
15
|
+
maxCount?: number;
|
|
16
|
+
beforeContext: number;
|
|
17
|
+
afterContext: number;
|
|
18
|
+
includes: string[];
|
|
19
|
+
excludes: string[];
|
|
20
|
+
excludeDirs: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface WcArgs {
|
|
23
|
+
fields: WcField[];
|
|
24
|
+
paths: string[];
|
|
25
|
+
}
|
|
26
|
+
export type WcField = 'lines' | 'words' | 'bytes';
|
|
27
|
+
export interface HeadTailArgs {
|
|
28
|
+
count: number;
|
|
29
|
+
unit: 'lines' | 'bytes';
|
|
30
|
+
fromLine?: number;
|
|
31
|
+
fromByte?: number;
|
|
32
|
+
paths: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface CutArgs {
|
|
35
|
+
mode: 'fields' | 'chars';
|
|
36
|
+
delimiter: string;
|
|
37
|
+
fields: NumberSelection[];
|
|
38
|
+
chars: NumberSelection[];
|
|
39
|
+
paths: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface NumberSelection {
|
|
42
|
+
start: number;
|
|
43
|
+
end?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SedArgs {
|
|
46
|
+
expression: string;
|
|
47
|
+
paths: string[];
|
|
48
|
+
quiet: boolean;
|
|
49
|
+
inPlace: boolean;
|
|
50
|
+
backupSuffix?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface UniqArgs {
|
|
53
|
+
count: boolean;
|
|
54
|
+
repeatedOnly: boolean;
|
|
55
|
+
uniqueOnly: boolean;
|
|
56
|
+
ignoreCase: boolean;
|
|
57
|
+
paths: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface AwkArgs {
|
|
60
|
+
program: string;
|
|
61
|
+
fieldSeparator?: string;
|
|
62
|
+
paths: string[];
|
|
63
|
+
}
|
|
64
|
+
export declare function formatPrintf(args: string[]): string;
|
|
65
|
+
export declare function parseGrepArgs(args: string[]): GrepArgs;
|
|
66
|
+
export declare function makeTextMatcher(patterns: string[], options: {
|
|
67
|
+
fixedStrings: boolean;
|
|
68
|
+
ignoreCase: boolean;
|
|
69
|
+
}): (line: string) => boolean;
|
|
70
|
+
export declare function extractTextMatches(patterns: string[], line: string, options: {
|
|
71
|
+
fixedStrings: boolean;
|
|
72
|
+
ignoreCase: boolean;
|
|
73
|
+
}): string[];
|
|
74
|
+
export declare function parseWcArgs(args: string[]): WcArgs;
|
|
75
|
+
export declare function parseHeadTailArgs(args: string[], fallback: number, command?: string): HeadTailArgs;
|
|
76
|
+
export declare function parseCutArgs(args: string[]): CutArgs;
|
|
77
|
+
export declare function parseUniqArgs(args: string[]): UniqArgs;
|
|
78
|
+
export declare function parseSedArgs(args: string[]): SedArgs;
|
|
79
|
+
export declare function parseAwkArgs(args: string[]): AwkArgs;
|
|
80
|
+
export declare function applyUniq(input: string, options: UniqArgs): string;
|
|
81
|
+
export declare function applySed(input: string, expression: string, options?: {
|
|
82
|
+
quiet?: boolean;
|
|
83
|
+
}): string;
|
|
84
|
+
export declare function applyAwk(input: string, program: string, options?: {
|
|
85
|
+
fieldSeparator?: string;
|
|
86
|
+
}): string;
|
|
87
|
+
export declare function translateText(input: string, args: string[]): string;
|
|
88
|
+
export declare function takeLines(input: string, count: number, side: 'head' | 'tail', fromLine?: number): string;
|
|
89
|
+
export declare function takeBytes(input: string, count: number, side: 'head' | 'tail', fromByte?: number): string;
|
|
90
|
+
export declare function splitLines(input: string): string[];
|