gitx.do 0.1.1 → 0.1.3
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 +40 -353
- package/dist/do/logger.d.ts +50 -0
- package/dist/do/logger.d.ts.map +1 -0
- package/dist/do/logger.js +122 -0
- package/dist/do/logger.js.map +1 -0
- package/dist/{durable-object → do}/schema.d.ts +3 -3
- package/dist/do/schema.d.ts.map +1 -0
- package/dist/{durable-object → do}/schema.js +4 -3
- package/dist/do/schema.js.map +1 -0
- package/dist/do/types.d.ts +267 -0
- package/dist/do/types.d.ts.map +1 -0
- package/dist/do/types.js +62 -0
- package/dist/do/types.js.map +1 -0
- package/dist/index.d.ts +15 -469
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -481
- package/dist/index.js.map +1 -1
- package/dist/mcp/auth.d.ts +77 -0
- package/dist/mcp/auth.d.ts.map +1 -0
- package/dist/mcp/auth.js +278 -0
- package/dist/mcp/auth.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +19 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +200 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +275 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +47 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js +284 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/tools.d.ts +103 -515
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +676 -3087
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +124 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +9 -0
- package/dist/mcp/types.js.map +1 -0
- package/package.json +19 -21
- package/dist/cli/commands/add.d.ts +0 -176
- package/dist/cli/commands/add.d.ts.map +0 -1
- package/dist/cli/commands/add.js +0 -979
- package/dist/cli/commands/add.js.map +0 -1
- package/dist/cli/commands/blame.d.ts +0 -259
- package/dist/cli/commands/blame.d.ts.map +0 -1
- package/dist/cli/commands/blame.js +0 -609
- package/dist/cli/commands/blame.js.map +0 -1
- package/dist/cli/commands/branch.d.ts +0 -249
- package/dist/cli/commands/branch.d.ts.map +0 -1
- package/dist/cli/commands/branch.js +0 -693
- package/dist/cli/commands/branch.js.map +0 -1
- package/dist/cli/commands/checkout.d.ts +0 -73
- package/dist/cli/commands/checkout.d.ts.map +0 -1
- package/dist/cli/commands/checkout.js +0 -725
- package/dist/cli/commands/checkout.js.map +0 -1
- package/dist/cli/commands/commit.d.ts +0 -182
- package/dist/cli/commands/commit.d.ts.map +0 -1
- package/dist/cli/commands/commit.js +0 -457
- package/dist/cli/commands/commit.js.map +0 -1
- package/dist/cli/commands/diff.d.ts +0 -464
- package/dist/cli/commands/diff.d.ts.map +0 -1
- package/dist/cli/commands/diff.js +0 -959
- package/dist/cli/commands/diff.js.map +0 -1
- package/dist/cli/commands/log.d.ts +0 -239
- package/dist/cli/commands/log.d.ts.map +0 -1
- package/dist/cli/commands/log.js +0 -535
- package/dist/cli/commands/log.js.map +0 -1
- package/dist/cli/commands/merge.d.ts +0 -106
- package/dist/cli/commands/merge.d.ts.map +0 -1
- package/dist/cli/commands/merge.js +0 -852
- package/dist/cli/commands/merge.js.map +0 -1
- package/dist/cli/commands/review.d.ts +0 -457
- package/dist/cli/commands/review.d.ts.map +0 -1
- package/dist/cli/commands/review.js +0 -558
- package/dist/cli/commands/review.js.map +0 -1
- package/dist/cli/commands/stash.d.ts +0 -157
- package/dist/cli/commands/stash.d.ts.map +0 -1
- package/dist/cli/commands/stash.js +0 -655
- package/dist/cli/commands/stash.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -269
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -492
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/web.d.ts +0 -199
- package/dist/cli/commands/web.d.ts.map +0 -1
- package/dist/cli/commands/web.js +0 -697
- package/dist/cli/commands/web.js.map +0 -1
- package/dist/cli/fs-adapter.d.ts +0 -656
- package/dist/cli/fs-adapter.d.ts.map +0 -1
- package/dist/cli/fs-adapter.js +0 -1177
- package/dist/cli/fs-adapter.js.map +0 -1
- package/dist/cli/fsx-cli-adapter.d.ts +0 -359
- package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
- package/dist/cli/fsx-cli-adapter.js +0 -619
- package/dist/cli/fsx-cli-adapter.js.map +0 -1
- package/dist/cli/index.d.ts +0 -387
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -579
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/ui/components/DiffView.d.ts +0 -12
- package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
- package/dist/cli/ui/components/DiffView.js +0 -11
- package/dist/cli/ui/components/DiffView.js.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
- package/dist/cli/ui/components/ErrorDisplay.js +0 -11
- package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
- package/dist/cli/ui/components/FuzzySearch.js +0 -12
- package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
- package/dist/cli/ui/components/LoadingSpinner.js +0 -10
- package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
- package/dist/cli/ui/components/NavigationList.d.ts +0 -14
- package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
- package/dist/cli/ui/components/NavigationList.js +0 -11
- package/dist/cli/ui/components/NavigationList.js.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/cli/ui/components/ScrollableContent.js +0 -11
- package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
- package/dist/cli/ui/components/index.d.ts +0 -7
- package/dist/cli/ui/components/index.d.ts.map +0 -1
- package/dist/cli/ui/components/index.js +0 -9
- package/dist/cli/ui/components/index.js.map +0 -1
- package/dist/cli/ui/terminal-ui.d.ts +0 -85
- package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
- package/dist/cli/ui/terminal-ui.js +0 -121
- package/dist/cli/ui/terminal-ui.js.map +0 -1
- package/dist/do/BashModule.d.ts +0 -871
- package/dist/do/BashModule.d.ts.map +0 -1
- package/dist/do/BashModule.js +0 -1143
- package/dist/do/BashModule.js.map +0 -1
- package/dist/do/FsModule.d.ts +0 -612
- package/dist/do/FsModule.d.ts.map +0 -1
- package/dist/do/FsModule.js +0 -1120
- package/dist/do/FsModule.js.map +0 -1
- package/dist/do/GitModule.d.ts +0 -635
- package/dist/do/GitModule.d.ts.map +0 -1
- package/dist/do/GitModule.js +0 -784
- package/dist/do/GitModule.js.map +0 -1
- package/dist/do/GitRepoDO.d.ts +0 -281
- package/dist/do/GitRepoDO.d.ts.map +0 -1
- package/dist/do/GitRepoDO.js +0 -479
- package/dist/do/GitRepoDO.js.map +0 -1
- package/dist/do/bash-ast.d.ts +0 -246
- package/dist/do/bash-ast.d.ts.map +0 -1
- package/dist/do/bash-ast.js +0 -888
- package/dist/do/bash-ast.js.map +0 -1
- package/dist/do/container-executor.d.ts +0 -491
- package/dist/do/container-executor.d.ts.map +0 -1
- package/dist/do/container-executor.js +0 -731
- package/dist/do/container-executor.js.map +0 -1
- package/dist/do/index.d.ts +0 -53
- package/dist/do/index.d.ts.map +0 -1
- package/dist/do/index.js +0 -91
- package/dist/do/index.js.map +0 -1
- package/dist/do/tiered-storage.d.ts +0 -403
- package/dist/do/tiered-storage.d.ts.map +0 -1
- package/dist/do/tiered-storage.js +0 -689
- package/dist/do/tiered-storage.js.map +0 -1
- package/dist/do/withBash.d.ts +0 -231
- package/dist/do/withBash.d.ts.map +0 -1
- package/dist/do/withBash.js +0 -244
- package/dist/do/withBash.js.map +0 -1
- package/dist/do/withFs.d.ts +0 -237
- package/dist/do/withFs.d.ts.map +0 -1
- package/dist/do/withFs.js +0 -387
- package/dist/do/withFs.js.map +0 -1
- package/dist/do/withGit.d.ts +0 -180
- package/dist/do/withGit.d.ts.map +0 -1
- package/dist/do/withGit.js +0 -271
- package/dist/do/withGit.js.map +0 -1
- package/dist/durable-object/object-store.d.ts +0 -633
- package/dist/durable-object/object-store.d.ts.map +0 -1
- package/dist/durable-object/object-store.js +0 -1164
- package/dist/durable-object/object-store.js.map +0 -1
- package/dist/durable-object/schema.d.ts.map +0 -1
- package/dist/durable-object/schema.js.map +0 -1
- package/dist/durable-object/wal.d.ts +0 -416
- package/dist/durable-object/wal.d.ts.map +0 -1
- package/dist/durable-object/wal.js +0 -445
- package/dist/durable-object/wal.js.map +0 -1
- package/dist/mcp/adapter.d.ts +0 -772
- package/dist/mcp/adapter.d.ts.map +0 -1
- package/dist/mcp/adapter.js +0 -895
- package/dist/mcp/adapter.js.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
- package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
- package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
- package/dist/mcp/sandbox/object-store-proxy.js +0 -30
- package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
- package/dist/mcp/sandbox/template.d.ts +0 -17
- package/dist/mcp/sandbox/template.d.ts.map +0 -1
- package/dist/mcp/sandbox/template.js +0 -71
- package/dist/mcp/sandbox/template.js.map +0 -1
- package/dist/mcp/sandbox.d.ts +0 -764
- package/dist/mcp/sandbox.d.ts.map +0 -1
- package/dist/mcp/sandbox.js +0 -1362
- package/dist/mcp/sandbox.js.map +0 -1
- package/dist/mcp/sdk-adapter.d.ts +0 -835
- package/dist/mcp/sdk-adapter.d.ts.map +0 -1
- package/dist/mcp/sdk-adapter.js +0 -974
- package/dist/mcp/sdk-adapter.js.map +0 -1
- package/dist/mcp/tools/do.d.ts +0 -32
- package/dist/mcp/tools/do.d.ts.map +0 -1
- package/dist/mcp/tools/do.js +0 -117
- package/dist/mcp/tools/do.js.map +0 -1
- package/dist/ops/blame.d.ts +0 -551
- package/dist/ops/blame.d.ts.map +0 -1
- package/dist/ops/blame.js +0 -1037
- package/dist/ops/blame.js.map +0 -1
- package/dist/ops/branch.d.ts +0 -766
- package/dist/ops/branch.d.ts.map +0 -1
- package/dist/ops/branch.js +0 -950
- package/dist/ops/branch.js.map +0 -1
- package/dist/ops/commit-traversal.d.ts +0 -349
- package/dist/ops/commit-traversal.d.ts.map +0 -1
- package/dist/ops/commit-traversal.js +0 -821
- package/dist/ops/commit-traversal.js.map +0 -1
- package/dist/ops/commit.d.ts +0 -555
- package/dist/ops/commit.d.ts.map +0 -1
- package/dist/ops/commit.js +0 -826
- package/dist/ops/commit.js.map +0 -1
- package/dist/ops/merge-base.d.ts +0 -397
- package/dist/ops/merge-base.d.ts.map +0 -1
- package/dist/ops/merge-base.js +0 -691
- package/dist/ops/merge-base.js.map +0 -1
- package/dist/ops/merge.d.ts +0 -855
- package/dist/ops/merge.d.ts.map +0 -1
- package/dist/ops/merge.js +0 -1551
- package/dist/ops/merge.js.map +0 -1
- package/dist/ops/tag.d.ts +0 -247
- package/dist/ops/tag.d.ts.map +0 -1
- package/dist/ops/tag.js +0 -649
- package/dist/ops/tag.js.map +0 -1
- package/dist/ops/tree-builder.d.ts +0 -178
- package/dist/ops/tree-builder.d.ts.map +0 -1
- package/dist/ops/tree-builder.js +0 -271
- package/dist/ops/tree-builder.js.map +0 -1
- package/dist/ops/tree-diff.d.ts +0 -291
- package/dist/ops/tree-diff.d.ts.map +0 -1
- package/dist/ops/tree-diff.js +0 -705
- package/dist/ops/tree-diff.js.map +0 -1
- package/dist/pack/delta.d.ts +0 -248
- package/dist/pack/delta.d.ts.map +0 -1
- package/dist/pack/delta.js +0 -740
- package/dist/pack/delta.js.map +0 -1
- package/dist/pack/format.d.ts +0 -446
- package/dist/pack/format.d.ts.map +0 -1
- package/dist/pack/format.js +0 -572
- package/dist/pack/format.js.map +0 -1
- package/dist/pack/full-generation.d.ts +0 -612
- package/dist/pack/full-generation.d.ts.map +0 -1
- package/dist/pack/full-generation.js +0 -1378
- package/dist/pack/full-generation.js.map +0 -1
- package/dist/pack/generation.d.ts +0 -441
- package/dist/pack/generation.d.ts.map +0 -1
- package/dist/pack/generation.js +0 -707
- package/dist/pack/generation.js.map +0 -1
- package/dist/pack/index.d.ts +0 -502
- package/dist/pack/index.d.ts.map +0 -1
- package/dist/pack/index.js +0 -833
- package/dist/pack/index.js.map +0 -1
- package/dist/refs/branch.d.ts +0 -683
- package/dist/refs/branch.d.ts.map +0 -1
- package/dist/refs/branch.js +0 -881
- package/dist/refs/branch.js.map +0 -1
- package/dist/refs/storage.d.ts +0 -833
- package/dist/refs/storage.d.ts.map +0 -1
- package/dist/refs/storage.js +0 -1023
- package/dist/refs/storage.js.map +0 -1
- package/dist/refs/tag.d.ts +0 -860
- package/dist/refs/tag.d.ts.map +0 -1
- package/dist/refs/tag.js +0 -996
- package/dist/refs/tag.js.map +0 -1
- package/dist/storage/backend.d.ts +0 -425
- package/dist/storage/backend.d.ts.map +0 -1
- package/dist/storage/backend.js +0 -41
- package/dist/storage/backend.js.map +0 -1
- package/dist/storage/fsx-adapter.d.ts +0 -204
- package/dist/storage/fsx-adapter.d.ts.map +0 -1
- package/dist/storage/fsx-adapter.js +0 -518
- package/dist/storage/fsx-adapter.js.map +0 -1
- package/dist/storage/lru-cache.d.ts +0 -691
- package/dist/storage/lru-cache.d.ts.map +0 -1
- package/dist/storage/lru-cache.js +0 -813
- package/dist/storage/lru-cache.js.map +0 -1
- package/dist/storage/object-index.d.ts +0 -585
- package/dist/storage/object-index.d.ts.map +0 -1
- package/dist/storage/object-index.js +0 -532
- package/dist/storage/object-index.js.map +0 -1
- package/dist/storage/r2-pack.d.ts +0 -1257
- package/dist/storage/r2-pack.d.ts.map +0 -1
- package/dist/storage/r2-pack.js +0 -1773
- package/dist/storage/r2-pack.js.map +0 -1
- package/dist/tiered/cdc-pipeline.d.ts +0 -1888
- package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
- package/dist/tiered/cdc-pipeline.js +0 -1880
- package/dist/tiered/cdc-pipeline.js.map +0 -1
- package/dist/tiered/migration.d.ts +0 -1104
- package/dist/tiered/migration.d.ts.map +0 -1
- package/dist/tiered/migration.js +0 -1217
- package/dist/tiered/migration.js.map +0 -1
- package/dist/tiered/parquet-writer.d.ts +0 -1145
- package/dist/tiered/parquet-writer.d.ts.map +0 -1
- package/dist/tiered/parquet-writer.js +0 -1183
- package/dist/tiered/parquet-writer.js.map +0 -1
- package/dist/tiered/read-path.d.ts +0 -835
- package/dist/tiered/read-path.d.ts.map +0 -1
- package/dist/tiered/read-path.js +0 -487
- package/dist/tiered/read-path.js.map +0 -1
- package/dist/types/capability.d.ts +0 -1385
- package/dist/types/capability.d.ts.map +0 -1
- package/dist/types/capability.js +0 -36
- package/dist/types/capability.js.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/types/index.js.map +0 -1
- package/dist/types/interfaces.d.ts +0 -673
- package/dist/types/interfaces.d.ts.map +0 -1
- package/dist/types/interfaces.js +0 -26
- package/dist/types/interfaces.js.map +0 -1
- package/dist/types/objects.d.ts +0 -692
- package/dist/types/objects.d.ts.map +0 -1
- package/dist/types/objects.js +0 -837
- package/dist/types/objects.js.map +0 -1
- package/dist/types/storage.d.ts +0 -603
- package/dist/types/storage.d.ts.map +0 -1
- package/dist/types/storage.js +0 -191
- package/dist/types/storage.js.map +0 -1
- package/dist/types/worker-loader.d.ts +0 -60
- package/dist/types/worker-loader.d.ts.map +0 -1
- package/dist/types/worker-loader.js +0 -62
- package/dist/types/worker-loader.js.map +0 -1
- package/dist/utils/hash.d.ts +0 -198
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/hash.js +0 -272
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/sha1.d.ts +0 -325
- package/dist/utils/sha1.d.ts.map +0 -1
- package/dist/utils/sha1.js +0 -635
- package/dist/utils/sha1.js.map +0 -1
- package/dist/wire/capabilities.d.ts +0 -1044
- package/dist/wire/capabilities.d.ts.map +0 -1
- package/dist/wire/capabilities.js +0 -941
- package/dist/wire/capabilities.js.map +0 -1
- package/dist/wire/path-security.d.ts +0 -157
- package/dist/wire/path-security.d.ts.map +0 -1
- package/dist/wire/path-security.js +0 -307
- package/dist/wire/path-security.js.map +0 -1
- package/dist/wire/pkt-line.d.ts +0 -345
- package/dist/wire/pkt-line.d.ts.map +0 -1
- package/dist/wire/pkt-line.js +0 -381
- package/dist/wire/pkt-line.js.map +0 -1
- package/dist/wire/receive-pack.d.ts +0 -1059
- package/dist/wire/receive-pack.d.ts.map +0 -1
- package/dist/wire/receive-pack.js +0 -1414
- package/dist/wire/receive-pack.js.map +0 -1
- package/dist/wire/smart-http.d.ts +0 -799
- package/dist/wire/smart-http.d.ts.map +0 -1
- package/dist/wire/smart-http.js +0 -945
- package/dist/wire/smart-http.js.map +0 -1
- package/dist/wire/upload-pack.d.ts +0 -727
- package/dist/wire/upload-pack.d.ts.map +0 -1
- package/dist/wire/upload-pack.js +0 -1141
- package/dist/wire/upload-pack.js.map +0 -1
package/dist/do/BashModule.d.ts
DELETED
|
@@ -1,871 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview BashModule for Durable Object Integration
|
|
3
|
-
*
|
|
4
|
-
* This module provides a BashModule class that integrates with dotdo's $ WorkflowContext,
|
|
5
|
-
* providing $.bash.exec(), $.bash.run(), and bash execution functionality.
|
|
6
|
-
*
|
|
7
|
-
* The module depends on FsModule for file system operations during command execution,
|
|
8
|
-
* enabling sandboxed bash operations within the DO's virtual filesystem.
|
|
9
|
-
*
|
|
10
|
-
* Features:
|
|
11
|
-
* - AST-based safety analysis for command parsing
|
|
12
|
-
* - Configurable command blocking and confirmation requirements
|
|
13
|
-
* - Support for database-backed execution policies
|
|
14
|
-
*
|
|
15
|
-
* @module do/BashModule
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { BashModule } from 'gitx.do/do'
|
|
20
|
-
*
|
|
21
|
-
* class MyDO extends DO {
|
|
22
|
-
* bash = new BashModule({
|
|
23
|
-
* executor: myExecutor,
|
|
24
|
-
* fs: this.$.fs
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* async buildProject() {
|
|
28
|
-
* const result = await this.bash.exec('npm', ['run', 'build'])
|
|
29
|
-
* if (result.exitCode !== 0) {
|
|
30
|
-
* throw new Error(`Build failed: ${result.stderr}`)
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
import { type SafetyIssue } from './bash-ast';
|
|
37
|
-
/**
|
|
38
|
-
* Filesystem capability interface that BashModule depends on.
|
|
39
|
-
* Mirrors the FsCapability from dotdo's WorkflowContext.
|
|
40
|
-
*/
|
|
41
|
-
export interface FsCapability {
|
|
42
|
-
readFile(path: string): Promise<string | Buffer>;
|
|
43
|
-
writeFile(path: string, content: string | Buffer): Promise<void>;
|
|
44
|
-
readDir(path: string): Promise<string[]>;
|
|
45
|
-
exists(path: string): Promise<boolean>;
|
|
46
|
-
mkdir(path: string, options?: {
|
|
47
|
-
recursive?: boolean;
|
|
48
|
-
}): Promise<void>;
|
|
49
|
-
rm(path: string, options?: {
|
|
50
|
-
recursive?: boolean;
|
|
51
|
-
force?: boolean;
|
|
52
|
-
}): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Result of a bash command execution.
|
|
56
|
-
*/
|
|
57
|
-
export interface BashResult {
|
|
58
|
-
/**
|
|
59
|
-
* The original command that was executed.
|
|
60
|
-
*/
|
|
61
|
-
command: string;
|
|
62
|
-
/**
|
|
63
|
-
* Standard output from the command.
|
|
64
|
-
*/
|
|
65
|
-
stdout: string;
|
|
66
|
-
/**
|
|
67
|
-
* Standard error from the command.
|
|
68
|
-
*/
|
|
69
|
-
stderr: string;
|
|
70
|
-
/**
|
|
71
|
-
* Exit code of the command. 0 typically indicates success.
|
|
72
|
-
*/
|
|
73
|
-
exitCode: number;
|
|
74
|
-
/**
|
|
75
|
-
* Whether the command was blocked due to safety concerns.
|
|
76
|
-
*/
|
|
77
|
-
blocked?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Reason the command was blocked, if applicable.
|
|
80
|
-
*/
|
|
81
|
-
blockReason?: string;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Options for executing bash commands.
|
|
85
|
-
*/
|
|
86
|
-
export interface ExecOptions {
|
|
87
|
-
/**
|
|
88
|
-
* Maximum execution time in milliseconds.
|
|
89
|
-
* @default 30000
|
|
90
|
-
*/
|
|
91
|
-
timeout?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Working directory for command execution.
|
|
94
|
-
*/
|
|
95
|
-
cwd?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Environment variables to set for the command.
|
|
98
|
-
*/
|
|
99
|
-
env?: Record<string, string>;
|
|
100
|
-
/**
|
|
101
|
-
* Confirm execution of dangerous commands.
|
|
102
|
-
* @default false
|
|
103
|
-
*/
|
|
104
|
-
confirm?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Run in dry-run mode - analyze without executing.
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
dryRun?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Provide stdin input for the command.
|
|
112
|
-
*/
|
|
113
|
-
stdin?: string;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Options for streaming command execution.
|
|
117
|
-
*/
|
|
118
|
-
export interface SpawnOptions extends ExecOptions {
|
|
119
|
-
/**
|
|
120
|
-
* Callback for stdout data chunks.
|
|
121
|
-
*/
|
|
122
|
-
onStdout?: (chunk: string) => void;
|
|
123
|
-
/**
|
|
124
|
-
* Callback for stderr data chunks.
|
|
125
|
-
*/
|
|
126
|
-
onStderr?: (chunk: string) => void;
|
|
127
|
-
/**
|
|
128
|
-
* Callback when the process exits.
|
|
129
|
-
*/
|
|
130
|
-
onExit?: (exitCode: number) => void;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Handle for a spawned process.
|
|
134
|
-
*/
|
|
135
|
-
export interface SpawnHandle {
|
|
136
|
-
/**
|
|
137
|
-
* Process ID of the spawned process.
|
|
138
|
-
*/
|
|
139
|
-
pid: number;
|
|
140
|
-
/**
|
|
141
|
-
* Promise that resolves when the process exits.
|
|
142
|
-
*/
|
|
143
|
-
done: Promise<BashResult>;
|
|
144
|
-
/**
|
|
145
|
-
* Kill the spawned process.
|
|
146
|
-
*/
|
|
147
|
-
kill(signal?: 'SIGTERM' | 'SIGKILL' | 'SIGINT'): void;
|
|
148
|
-
/**
|
|
149
|
-
* Write to the process stdin.
|
|
150
|
-
*/
|
|
151
|
-
write(data: string): void;
|
|
152
|
-
/**
|
|
153
|
-
* Close stdin to signal end of input.
|
|
154
|
-
*/
|
|
155
|
-
closeStdin(): void;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Interface for external command executors.
|
|
159
|
-
* BashModule delegates actual command execution to an executor.
|
|
160
|
-
*/
|
|
161
|
-
export interface BashExecutor {
|
|
162
|
-
/**
|
|
163
|
-
* Execute a command and return the result.
|
|
164
|
-
*/
|
|
165
|
-
execute(command: string, options?: ExecOptions): Promise<BashResult>;
|
|
166
|
-
/**
|
|
167
|
-
* Spawn a command for streaming execution (optional).
|
|
168
|
-
*/
|
|
169
|
-
spawn?(command: string, args?: string[], options?: SpawnOptions): Promise<SpawnHandle>;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Database storage interface for BashModule persistence.
|
|
173
|
-
* Provides access to the exec table for safety settings and policies.
|
|
174
|
-
*/
|
|
175
|
-
export interface BashStorage {
|
|
176
|
-
/**
|
|
177
|
-
* SQL execution interface.
|
|
178
|
-
*/
|
|
179
|
-
sql: {
|
|
180
|
-
/**
|
|
181
|
-
* Execute a SQL query with optional parameters.
|
|
182
|
-
* @param query - SQL query string (can use ? placeholders)
|
|
183
|
-
* @param params - Parameter values for placeholders
|
|
184
|
-
* @returns Result object with toArray() method for reading rows
|
|
185
|
-
*/
|
|
186
|
-
exec(query: string, ...params: unknown[]): {
|
|
187
|
-
toArray(): unknown[];
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Row structure for the exec table.
|
|
193
|
-
* Represents an execution policy with safety settings.
|
|
194
|
-
*/
|
|
195
|
-
export interface ExecRow {
|
|
196
|
-
id: number;
|
|
197
|
-
name: string;
|
|
198
|
-
blocked_commands: string | null;
|
|
199
|
-
require_confirmation: number;
|
|
200
|
-
default_timeout: number;
|
|
201
|
-
default_cwd: string;
|
|
202
|
-
allowed_patterns: string | null;
|
|
203
|
-
denied_patterns: string | null;
|
|
204
|
-
max_concurrent: number;
|
|
205
|
-
enabled: number;
|
|
206
|
-
created_at: number | null;
|
|
207
|
-
updated_at: number | null;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Execution policy configuration.
|
|
211
|
-
* Used to define and persist execution safety settings.
|
|
212
|
-
*/
|
|
213
|
-
export interface ExecPolicy {
|
|
214
|
-
/**
|
|
215
|
-
* Unique name for this policy.
|
|
216
|
-
*/
|
|
217
|
-
name: string;
|
|
218
|
-
/**
|
|
219
|
-
* List of commands that are blocked from execution.
|
|
220
|
-
*/
|
|
221
|
-
blockedCommands: string[];
|
|
222
|
-
/**
|
|
223
|
-
* Whether to require confirmation for dangerous commands.
|
|
224
|
-
* @default true
|
|
225
|
-
*/
|
|
226
|
-
requireConfirmation: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Default timeout for commands in milliseconds.
|
|
229
|
-
* @default 30000
|
|
230
|
-
*/
|
|
231
|
-
defaultTimeout: number;
|
|
232
|
-
/**
|
|
233
|
-
* Default working directory for commands.
|
|
234
|
-
* @default '/'
|
|
235
|
-
*/
|
|
236
|
-
defaultCwd: string;
|
|
237
|
-
/**
|
|
238
|
-
* Regex patterns for allowed commands.
|
|
239
|
-
* If specified, only matching commands are allowed.
|
|
240
|
-
*/
|
|
241
|
-
allowedPatterns?: string[];
|
|
242
|
-
/**
|
|
243
|
-
* Regex patterns for denied commands.
|
|
244
|
-
* Matching commands are blocked regardless of other settings.
|
|
245
|
-
*/
|
|
246
|
-
deniedPatterns?: string[];
|
|
247
|
-
/**
|
|
248
|
-
* Maximum number of concurrent executions.
|
|
249
|
-
* @default 5
|
|
250
|
-
*/
|
|
251
|
-
maxConcurrent: number;
|
|
252
|
-
/**
|
|
253
|
-
* Whether this policy is enabled.
|
|
254
|
-
* @default true
|
|
255
|
-
*/
|
|
256
|
-
enabled: boolean;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Configuration options for BashModule.
|
|
260
|
-
*/
|
|
261
|
-
export interface BashModuleOptions {
|
|
262
|
-
/**
|
|
263
|
-
* The executor to use for running commands.
|
|
264
|
-
* Required for actual command execution.
|
|
265
|
-
*/
|
|
266
|
-
executor?: BashExecutor;
|
|
267
|
-
/**
|
|
268
|
-
* Filesystem capability for file operations.
|
|
269
|
-
* Used for cwd management and file-based command I/O.
|
|
270
|
-
*/
|
|
271
|
-
fs?: FsCapability;
|
|
272
|
-
/**
|
|
273
|
-
* Default working directory for commands.
|
|
274
|
-
* @default '/'
|
|
275
|
-
*/
|
|
276
|
-
cwd?: string;
|
|
277
|
-
/**
|
|
278
|
-
* Default timeout for commands in milliseconds.
|
|
279
|
-
* @default 30000
|
|
280
|
-
*/
|
|
281
|
-
defaultTimeout?: number;
|
|
282
|
-
/**
|
|
283
|
-
* List of commands that are blocked from execution.
|
|
284
|
-
*/
|
|
285
|
-
blockedCommands?: string[];
|
|
286
|
-
/**
|
|
287
|
-
* Whether to require confirmation for dangerous commands.
|
|
288
|
-
* @default true
|
|
289
|
-
*/
|
|
290
|
-
requireConfirmation?: boolean;
|
|
291
|
-
/**
|
|
292
|
-
* Database storage for persistent settings.
|
|
293
|
-
* When provided, BashModule will persist settings to the exec table.
|
|
294
|
-
*/
|
|
295
|
-
storage?: BashStorage;
|
|
296
|
-
/**
|
|
297
|
-
* Policy name to use when persisting settings.
|
|
298
|
-
* @default 'default'
|
|
299
|
-
*/
|
|
300
|
-
policyName?: string;
|
|
301
|
-
/**
|
|
302
|
-
* Whether to use AST-based safety analysis.
|
|
303
|
-
* When true, commands are parsed into an AST for more accurate safety analysis.
|
|
304
|
-
* @default true
|
|
305
|
-
*/
|
|
306
|
-
useAST?: boolean;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Safety level classification for commands.
|
|
310
|
-
* - 'safe': Command can be executed without confirmation
|
|
311
|
-
* - 'dangerous': Command requires confirmation but can be executed with confirm flag
|
|
312
|
-
* - 'critical': Command is ALWAYS blocked regardless of confirmation
|
|
313
|
-
*/
|
|
314
|
-
export type SafetyLevel = 'safe' | 'dangerous' | 'critical';
|
|
315
|
-
/**
|
|
316
|
-
* Safety analysis result for a command.
|
|
317
|
-
*/
|
|
318
|
-
export interface SafetyAnalysis {
|
|
319
|
-
/**
|
|
320
|
-
* Whether the command is considered dangerous.
|
|
321
|
-
*/
|
|
322
|
-
dangerous: boolean;
|
|
323
|
-
/**
|
|
324
|
-
* Safety level classification.
|
|
325
|
-
* - 'safe': Can execute without confirmation
|
|
326
|
-
* - 'dangerous': Requires confirmation (confirm flag allows execution)
|
|
327
|
-
* - 'critical': Always blocked, cannot be executed even with confirmation
|
|
328
|
-
*/
|
|
329
|
-
safetyLevel?: SafetyLevel;
|
|
330
|
-
/**
|
|
331
|
-
* Reason for the classification.
|
|
332
|
-
*/
|
|
333
|
-
reason?: string;
|
|
334
|
-
/**
|
|
335
|
-
* Commands identified in the input.
|
|
336
|
-
*/
|
|
337
|
-
commands: string[];
|
|
338
|
-
/**
|
|
339
|
-
* Impact level of the command.
|
|
340
|
-
*/
|
|
341
|
-
impact: 'none' | 'low' | 'medium' | 'high' | 'critical';
|
|
342
|
-
/**
|
|
343
|
-
* Detailed issues found during AST analysis.
|
|
344
|
-
* Only populated when useAST option is true.
|
|
345
|
-
*/
|
|
346
|
-
issues?: SafetyIssue[];
|
|
347
|
-
/**
|
|
348
|
-
* Whether AST-based analysis was used.
|
|
349
|
-
*/
|
|
350
|
-
usedAST?: boolean;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* BashModule class for integration with dotdo's $ WorkflowContext.
|
|
354
|
-
*
|
|
355
|
-
* @description
|
|
356
|
-
* Provides bash execution functionality as a capability module that integrates
|
|
357
|
-
* with dotdo's Durable Object framework. The module:
|
|
358
|
-
*
|
|
359
|
-
* - Depends on FsModule for file system operations during execution
|
|
360
|
-
* - Delegates actual command execution to a configurable executor
|
|
361
|
-
* - Provides safety analysis and command blocking
|
|
362
|
-
* - Supports both exec (wait for completion) and spawn (streaming) modes
|
|
363
|
-
*
|
|
364
|
-
* @example
|
|
365
|
-
* ```typescript
|
|
366
|
-
* // In a Durable Object
|
|
367
|
-
* class MyDO extends DO {
|
|
368
|
-
* private bash: BashModule
|
|
369
|
-
*
|
|
370
|
-
* constructor(state: DurableObjectState, env: Env) {
|
|
371
|
-
* super(state, env)
|
|
372
|
-
* this.bash = new BashModule({
|
|
373
|
-
* executor: containerExecutor,
|
|
374
|
-
* fs: this.$.fs,
|
|
375
|
-
* cwd: '/app'
|
|
376
|
-
* })
|
|
377
|
-
* }
|
|
378
|
-
*
|
|
379
|
-
* async fetch(request: Request) {
|
|
380
|
-
* // Execute a command
|
|
381
|
-
* const result = await this.bash.exec('npm', ['install'])
|
|
382
|
-
*
|
|
383
|
-
* // Run a script
|
|
384
|
-
* await this.bash.run(`
|
|
385
|
-
* set -e
|
|
386
|
-
* npm run build
|
|
387
|
-
* npm run test
|
|
388
|
-
* `)
|
|
389
|
-
*
|
|
390
|
-
* return new Response('OK')
|
|
391
|
-
* }
|
|
392
|
-
* }
|
|
393
|
-
* ```
|
|
394
|
-
*/
|
|
395
|
-
export declare class BashModule {
|
|
396
|
-
/**
|
|
397
|
-
* Capability module name for identification.
|
|
398
|
-
*/
|
|
399
|
-
readonly name: "bash";
|
|
400
|
-
/**
|
|
401
|
-
* The executor used for running commands.
|
|
402
|
-
*/
|
|
403
|
-
private readonly executor?;
|
|
404
|
-
/**
|
|
405
|
-
* Filesystem capability for file operations.
|
|
406
|
-
*/
|
|
407
|
-
private readonly fs?;
|
|
408
|
-
/**
|
|
409
|
-
* Default working directory.
|
|
410
|
-
*/
|
|
411
|
-
private defaultCwd;
|
|
412
|
-
/**
|
|
413
|
-
* Default timeout in milliseconds.
|
|
414
|
-
*/
|
|
415
|
-
private defaultTimeout;
|
|
416
|
-
/**
|
|
417
|
-
* List of blocked commands.
|
|
418
|
-
*/
|
|
419
|
-
private blockedCommands;
|
|
420
|
-
/**
|
|
421
|
-
* Whether to require confirmation for dangerous commands.
|
|
422
|
-
*/
|
|
423
|
-
private requireConfirmation;
|
|
424
|
-
/**
|
|
425
|
-
* Database storage for persistence.
|
|
426
|
-
*/
|
|
427
|
-
private readonly storage?;
|
|
428
|
-
/**
|
|
429
|
-
* Policy name for database operations.
|
|
430
|
-
*/
|
|
431
|
-
private readonly policyName;
|
|
432
|
-
/**
|
|
433
|
-
* Database row ID for this policy.
|
|
434
|
-
*/
|
|
435
|
-
private policyId?;
|
|
436
|
-
/**
|
|
437
|
-
* Allowed command patterns (regex).
|
|
438
|
-
*/
|
|
439
|
-
private allowedPatterns;
|
|
440
|
-
/**
|
|
441
|
-
* Denied command patterns (regex).
|
|
442
|
-
*/
|
|
443
|
-
private deniedPatterns;
|
|
444
|
-
/**
|
|
445
|
-
* Maximum concurrent executions.
|
|
446
|
-
*/
|
|
447
|
-
private maxConcurrent;
|
|
448
|
-
/**
|
|
449
|
-
* Whether the policy is enabled.
|
|
450
|
-
*/
|
|
451
|
-
private enabled;
|
|
452
|
-
/**
|
|
453
|
-
* Whether to use AST-based safety analysis.
|
|
454
|
-
*/
|
|
455
|
-
private readonly useAST;
|
|
456
|
-
/**
|
|
457
|
-
* Commands considered dangerous and requiring confirmation.
|
|
458
|
-
*/
|
|
459
|
-
private static readonly DANGEROUS_COMMANDS;
|
|
460
|
-
/**
|
|
461
|
-
* Critical patterns that should ALWAYS be blocked, regardless of confirmation.
|
|
462
|
-
* These patterns represent commands that could cause catastrophic, irreversible damage.
|
|
463
|
-
*/
|
|
464
|
-
private static readonly CRITICAL_PATTERNS;
|
|
465
|
-
/**
|
|
466
|
-
* Dangerous flag patterns (require confirmation but can be executed with confirm).
|
|
467
|
-
*/
|
|
468
|
-
private static readonly DANGEROUS_PATTERNS;
|
|
469
|
-
/**
|
|
470
|
-
* Create a new BashModule instance.
|
|
471
|
-
*
|
|
472
|
-
* @param options - Configuration options
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```typescript
|
|
476
|
-
* const bash = new BashModule({
|
|
477
|
-
* executor: containerExecutor,
|
|
478
|
-
* fs: workflowContext.fs,
|
|
479
|
-
* cwd: '/app'
|
|
480
|
-
* })
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
constructor(options?: BashModuleOptions);
|
|
484
|
-
/**
|
|
485
|
-
* Optional initialization hook.
|
|
486
|
-
* Called when the module is first loaded.
|
|
487
|
-
* When storage is provided, loads or creates the execution policy from the database.
|
|
488
|
-
*/
|
|
489
|
-
initialize(): Promise<void>;
|
|
490
|
-
/**
|
|
491
|
-
* Load settings from a database row.
|
|
492
|
-
*/
|
|
493
|
-
private loadFromRow;
|
|
494
|
-
/**
|
|
495
|
-
* Persist current policy settings to the database.
|
|
496
|
-
*/
|
|
497
|
-
private persistPolicy;
|
|
498
|
-
/**
|
|
499
|
-
* Optional cleanup hook.
|
|
500
|
-
* Called when the capability is unloaded.
|
|
501
|
-
*/
|
|
502
|
-
dispose(): Promise<void>;
|
|
503
|
-
/**
|
|
504
|
-
* Check if FsCapability is available.
|
|
505
|
-
*
|
|
506
|
-
* @returns True if FsCapability is configured
|
|
507
|
-
*/
|
|
508
|
-
get hasFsCapability(): boolean;
|
|
509
|
-
/**
|
|
510
|
-
* Check if an executor is available.
|
|
511
|
-
*
|
|
512
|
-
* @returns True if an executor is configured
|
|
513
|
-
*/
|
|
514
|
-
get hasExecutor(): boolean;
|
|
515
|
-
/**
|
|
516
|
-
* Execute a command and wait for completion.
|
|
517
|
-
*
|
|
518
|
-
* @param command - The command to execute (e.g., 'git', 'npm', 'ls')
|
|
519
|
-
* @param args - Optional array of command arguments
|
|
520
|
-
* @param options - Optional execution options
|
|
521
|
-
* @returns Promise resolving to the execution result
|
|
522
|
-
*
|
|
523
|
-
* @example
|
|
524
|
-
* ```typescript
|
|
525
|
-
* // Simple command
|
|
526
|
-
* const result = await bash.exec('ls')
|
|
527
|
-
*
|
|
528
|
-
* // With arguments
|
|
529
|
-
* const result = await bash.exec('git', ['status', '--short'])
|
|
530
|
-
*
|
|
531
|
-
* // With options
|
|
532
|
-
* const result = await bash.exec('npm', ['install'], {
|
|
533
|
-
* cwd: '/app',
|
|
534
|
-
* timeout: 60000
|
|
535
|
-
* })
|
|
536
|
-
* ```
|
|
537
|
-
*/
|
|
538
|
-
exec(command: string, args?: string[], options?: ExecOptions): Promise<BashResult>;
|
|
539
|
-
/**
|
|
540
|
-
* Spawn a command for streaming execution.
|
|
541
|
-
*
|
|
542
|
-
* @param command - The command to spawn
|
|
543
|
-
* @param args - Optional array of command arguments
|
|
544
|
-
* @param options - Optional spawn options including stream callbacks
|
|
545
|
-
* @returns Promise resolving to a spawn handle
|
|
546
|
-
*
|
|
547
|
-
* @example
|
|
548
|
-
* ```typescript
|
|
549
|
-
* const handle = await bash.spawn('tail', ['-f', '/var/log/app.log'], {
|
|
550
|
-
* onStdout: (chunk) => console.log(chunk),
|
|
551
|
-
* onStderr: (chunk) => console.error(chunk)
|
|
552
|
-
* })
|
|
553
|
-
*
|
|
554
|
-
* // Later, stop the process
|
|
555
|
-
* handle.kill()
|
|
556
|
-
*
|
|
557
|
-
* // Wait for it to finish
|
|
558
|
-
* const result = await handle.done
|
|
559
|
-
* ```
|
|
560
|
-
*/
|
|
561
|
-
spawn(command: string, args?: string[], options?: SpawnOptions): Promise<SpawnHandle>;
|
|
562
|
-
/**
|
|
563
|
-
* Run a shell script.
|
|
564
|
-
*
|
|
565
|
-
* @param script - The bash script to execute
|
|
566
|
-
* @param options - Optional execution options
|
|
567
|
-
* @returns Promise resolving to the execution result
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* ```typescript
|
|
571
|
-
* const result = await bash.run(`
|
|
572
|
-
* set -e
|
|
573
|
-
* cd /app
|
|
574
|
-
* npm install
|
|
575
|
-
* npm run build
|
|
576
|
-
* `)
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
run(script: string, options?: ExecOptions): Promise<BashResult>;
|
|
580
|
-
/**
|
|
581
|
-
* Analyze a command for safety.
|
|
582
|
-
*
|
|
583
|
-
* Uses AST-based analysis by default for more accurate command parsing
|
|
584
|
-
* and safety classification. Falls back to regex-based analysis if
|
|
585
|
-
* useAST is disabled.
|
|
586
|
-
*
|
|
587
|
-
* @param input - The command or script to analyze
|
|
588
|
-
* @returns Safety analysis result
|
|
589
|
-
*
|
|
590
|
-
* @example
|
|
591
|
-
* ```typescript
|
|
592
|
-
* const analysis = bash.analyze('rm -rf /')
|
|
593
|
-
* if (analysis.dangerous) {
|
|
594
|
-
* console.warn(analysis.reason)
|
|
595
|
-
* }
|
|
596
|
-
* ```
|
|
597
|
-
*/
|
|
598
|
-
analyze(input: string): SafetyAnalysis;
|
|
599
|
-
/**
|
|
600
|
-
* Analyze a command using AST-based parsing.
|
|
601
|
-
*
|
|
602
|
-
* Parses the command into an AST and inspects nodes for safety issues.
|
|
603
|
-
* This provides more accurate analysis than regex patterns because it
|
|
604
|
-
* understands command structure, arguments, and pipelines.
|
|
605
|
-
*
|
|
606
|
-
* @param input - The command or script to analyze
|
|
607
|
-
* @returns Safety analysis result with AST details
|
|
608
|
-
* @internal
|
|
609
|
-
*/
|
|
610
|
-
private analyzeWithAST;
|
|
611
|
-
/**
|
|
612
|
-
* Analyze a command using regex patterns.
|
|
613
|
-
*
|
|
614
|
-
* This is the fallback analysis method when AST parsing is disabled
|
|
615
|
-
* or fails. It uses simple pattern matching.
|
|
616
|
-
*
|
|
617
|
-
* @param input - The command or script to analyze
|
|
618
|
-
* @returns Safety analysis result
|
|
619
|
-
* @internal
|
|
620
|
-
*/
|
|
621
|
-
private analyzeWithRegex;
|
|
622
|
-
/**
|
|
623
|
-
* Check if a command is dangerous.
|
|
624
|
-
*
|
|
625
|
-
* @param input - The command to check
|
|
626
|
-
* @returns Object indicating if dangerous and why
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```typescript
|
|
630
|
-
* const check = bash.isDangerous('rm -rf /')
|
|
631
|
-
* if (check.dangerous) {
|
|
632
|
-
* console.warn(check.reason)
|
|
633
|
-
* }
|
|
634
|
-
* ```
|
|
635
|
-
*/
|
|
636
|
-
isDangerous(input: string): {
|
|
637
|
-
dangerous: boolean;
|
|
638
|
-
reason?: string;
|
|
639
|
-
};
|
|
640
|
-
/**
|
|
641
|
-
* Add a command to the blocked list.
|
|
642
|
-
* Persists the change to the database if storage is configured.
|
|
643
|
-
*
|
|
644
|
-
* @param command - Command to block
|
|
645
|
-
*/
|
|
646
|
-
block(command: string): void;
|
|
647
|
-
/**
|
|
648
|
-
* Remove a command from the blocked list.
|
|
649
|
-
* Persists the change to the database if storage is configured.
|
|
650
|
-
*
|
|
651
|
-
* @param command - Command to unblock
|
|
652
|
-
*/
|
|
653
|
-
unblock(command: string): void;
|
|
654
|
-
/**
|
|
655
|
-
* Get the list of blocked commands.
|
|
656
|
-
*
|
|
657
|
-
* @returns Array of blocked command names
|
|
658
|
-
*/
|
|
659
|
-
getBlockedCommands(): string[];
|
|
660
|
-
/**
|
|
661
|
-
* Get the current execution policy.
|
|
662
|
-
*
|
|
663
|
-
* @returns Current policy configuration
|
|
664
|
-
*/
|
|
665
|
-
getPolicy(): ExecPolicy;
|
|
666
|
-
/**
|
|
667
|
-
* Update the execution policy.
|
|
668
|
-
* Persists the changes to the database if storage is configured.
|
|
669
|
-
*
|
|
670
|
-
* @param policy - Partial policy configuration to update
|
|
671
|
-
*/
|
|
672
|
-
updatePolicy(policy: Partial<Omit<ExecPolicy, 'name'>>): Promise<void>;
|
|
673
|
-
/**
|
|
674
|
-
* Check if the policy is enabled.
|
|
675
|
-
*
|
|
676
|
-
* @returns True if the policy is enabled
|
|
677
|
-
*/
|
|
678
|
-
isEnabled(): boolean;
|
|
679
|
-
/**
|
|
680
|
-
* Check if database storage is available.
|
|
681
|
-
*
|
|
682
|
-
* @returns True if storage is configured
|
|
683
|
-
*/
|
|
684
|
-
hasStorage(): boolean;
|
|
685
|
-
/**
|
|
686
|
-
* Extract the base command name from a command string.
|
|
687
|
-
*/
|
|
688
|
-
private extractBaseCommand;
|
|
689
|
-
/**
|
|
690
|
-
* Extract all command names from a script.
|
|
691
|
-
*/
|
|
692
|
-
private extractCommands;
|
|
693
|
-
/**
|
|
694
|
-
* Escape an argument for safe shell use.
|
|
695
|
-
*/
|
|
696
|
-
private escapeArg;
|
|
697
|
-
/**
|
|
698
|
-
* Tagged template literal for safe bash command execution.
|
|
699
|
-
*
|
|
700
|
-
* This method allows using template literal syntax for bash commands with
|
|
701
|
-
* automatic variable interpolation and escaping. Variables are safely
|
|
702
|
-
* escaped to prevent shell injection attacks.
|
|
703
|
-
*
|
|
704
|
-
* @param strings - Template literal string parts
|
|
705
|
-
* @param values - Interpolated values
|
|
706
|
-
* @returns Promise resolving to the execution result
|
|
707
|
-
*
|
|
708
|
-
* @example
|
|
709
|
-
* ```typescript
|
|
710
|
-
* // Simple usage
|
|
711
|
-
* const result = await this.$.bash`ls -la`
|
|
712
|
-
*
|
|
713
|
-
* // With interpolation
|
|
714
|
-
* const dir = '/tmp/my folder'
|
|
715
|
-
* const result = await this.$.bash`ls -la ${dir}`
|
|
716
|
-
*
|
|
717
|
-
* // With multiple variables
|
|
718
|
-
* const src = 'file.txt'
|
|
719
|
-
* const dest = 'backup/file.txt'
|
|
720
|
-
* const result = await this.$.bash`cp ${src} ${dest}`
|
|
721
|
-
* ```
|
|
722
|
-
*/
|
|
723
|
-
tag(strings: TemplateStringsArray, ...values: unknown[]): Promise<BashResult>;
|
|
724
|
-
/**
|
|
725
|
-
* Build a command string from template literal parts with safe escaping.
|
|
726
|
-
*
|
|
727
|
-
* @param strings - Template literal string parts
|
|
728
|
-
* @param values - Interpolated values
|
|
729
|
-
* @returns The constructed command string with escaped values
|
|
730
|
-
* @internal
|
|
731
|
-
*/
|
|
732
|
-
private buildCommandFromTemplate;
|
|
733
|
-
/**
|
|
734
|
-
* Escape a template literal value for safe shell interpolation.
|
|
735
|
-
*
|
|
736
|
-
* Handles various types of values:
|
|
737
|
-
* - null/undefined: empty string
|
|
738
|
-
* - string: escaped with single quotes if needed
|
|
739
|
-
* - number/boolean: converted to string directly
|
|
740
|
-
* - array: each element escaped and joined with spaces
|
|
741
|
-
* - object: JSON stringified and escaped
|
|
742
|
-
*
|
|
743
|
-
* @param value - The value to escape
|
|
744
|
-
* @returns The escaped string representation
|
|
745
|
-
* @internal
|
|
746
|
-
*/
|
|
747
|
-
private escapeTemplateValue;
|
|
748
|
-
/**
|
|
749
|
-
* Escape a string for safe shell use.
|
|
750
|
-
*
|
|
751
|
-
* Uses single-quote escaping which is the safest form of escaping
|
|
752
|
-
* for bash. Single quotes prevent all special character interpretation
|
|
753
|
-
* except for the single quote itself.
|
|
754
|
-
*
|
|
755
|
-
* @param str - The string to escape
|
|
756
|
-
* @returns The escaped string
|
|
757
|
-
* @internal
|
|
758
|
-
*/
|
|
759
|
-
private escapeShellString;
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Create a BashModule instance with the given options.
|
|
763
|
-
*
|
|
764
|
-
* @param options - Configuration options for the module
|
|
765
|
-
* @returns A new BashModule instance
|
|
766
|
-
*
|
|
767
|
-
* @example
|
|
768
|
-
* ```typescript
|
|
769
|
-
* import { createBashModule } from 'gitx.do/do'
|
|
770
|
-
*
|
|
771
|
-
* const bash = createBashModule({
|
|
772
|
-
* executor: containerExecutor,
|
|
773
|
-
* fs: workflowContext.fs,
|
|
774
|
-
* cwd: '/app'
|
|
775
|
-
* })
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
export declare function createBashModule(options?: BashModuleOptions): BashModule;
|
|
779
|
-
/**
|
|
780
|
-
* Tagged template function signature for bash commands.
|
|
781
|
-
*
|
|
782
|
-
* @example
|
|
783
|
-
* ```typescript
|
|
784
|
-
* const result = await bash`ls -la ${dir}`
|
|
785
|
-
* ```
|
|
786
|
-
*/
|
|
787
|
-
export interface BashTagFunction {
|
|
788
|
-
(strings: TemplateStringsArray, ...values: unknown[]): Promise<BashResult>;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* A BashModule that can also be called directly as a tagged template literal.
|
|
792
|
-
*
|
|
793
|
-
* This type represents a BashModule instance that has been wrapped with
|
|
794
|
-
* a Proxy to enable both direct method calls and tagged template syntax.
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```typescript
|
|
798
|
-
* // Create a callable bash module
|
|
799
|
-
* const bash = createCallableBashModule({ executor })
|
|
800
|
-
*
|
|
801
|
-
* // Use as tagged template
|
|
802
|
-
* const result = await bash`ls -la ${dir}`
|
|
803
|
-
*
|
|
804
|
-
* // Use as regular module
|
|
805
|
-
* const result2 = await bash.exec('git', ['status'])
|
|
806
|
-
* ```
|
|
807
|
-
*/
|
|
808
|
-
export type CallableBashModule = BashModule & BashTagFunction;
|
|
809
|
-
/**
|
|
810
|
-
* Create a callable BashModule instance that supports tagged template literals.
|
|
811
|
-
*
|
|
812
|
-
* This factory creates a BashModule wrapped in a Proxy that allows both:
|
|
813
|
-
* - Standard method calls: `bash.exec('ls', ['-la'])`
|
|
814
|
-
* - Tagged template syntax: `bash\`ls -la ${dir}\``
|
|
815
|
-
*
|
|
816
|
-
* The tagged template syntax automatically escapes interpolated values
|
|
817
|
-
* to prevent shell injection attacks.
|
|
818
|
-
*
|
|
819
|
-
* @param options - Configuration options for the module
|
|
820
|
-
* @returns A callable BashModule instance
|
|
821
|
-
*
|
|
822
|
-
* @example
|
|
823
|
-
* ```typescript
|
|
824
|
-
* import { createCallableBashModule } from 'gitx.do/do'
|
|
825
|
-
*
|
|
826
|
-
* // In a Durable Object
|
|
827
|
-
* class MyDO extends DO {
|
|
828
|
-
* bash = createCallableBashModule({
|
|
829
|
-
* executor: containerExecutor,
|
|
830
|
-
* fs: this.$.fs,
|
|
831
|
-
* cwd: '/app'
|
|
832
|
-
* })
|
|
833
|
-
*
|
|
834
|
-
* async listFiles(dir: string) {
|
|
835
|
-
* // Use tagged template syntax
|
|
836
|
-
* const result = await this.bash`ls -la ${dir}`
|
|
837
|
-
* return result.stdout
|
|
838
|
-
* }
|
|
839
|
-
*
|
|
840
|
-
* async runWithArgs() {
|
|
841
|
-
* // Or use regular methods
|
|
842
|
-
* const result = await this.bash.exec('npm', ['install'])
|
|
843
|
-
* return result
|
|
844
|
-
* }
|
|
845
|
-
* }
|
|
846
|
-
* ```
|
|
847
|
-
*
|
|
848
|
-
* @example
|
|
849
|
-
* ```typescript
|
|
850
|
-
* // Handle special characters safely
|
|
851
|
-
* const filename = "file with 'quotes' and spaces"
|
|
852
|
-
* const result = await bash`cat ${filename}`
|
|
853
|
-
* // Executes: cat 'file with '\''quotes'\'' and spaces'
|
|
854
|
-
* ```
|
|
855
|
-
*/
|
|
856
|
-
export declare function createCallableBashModule(options?: BashModuleOptions): CallableBashModule;
|
|
857
|
-
/**
|
|
858
|
-
* Check if a value is a BashModule instance.
|
|
859
|
-
*
|
|
860
|
-
* @param value - Value to check
|
|
861
|
-
* @returns True if value is a BashModule
|
|
862
|
-
*/
|
|
863
|
-
export declare function isBashModule(value: unknown): value is BashModule;
|
|
864
|
-
/**
|
|
865
|
-
* Check if a value is a CallableBashModule.
|
|
866
|
-
*
|
|
867
|
-
* @param value - Value to check
|
|
868
|
-
* @returns True if value is a CallableBashModule
|
|
869
|
-
*/
|
|
870
|
-
export declare function isCallableBashModule(value: unknown): value is CallableBashModule;
|
|
871
|
-
//# sourceMappingURL=BashModule.d.ts.map
|