@aria-cli/tools 1.0.9 → 1.0.10
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/package.json +8 -5
- package/dist-cjs/.tsbuildinfo +0 -1
- package/dist-cjs/ask-user-interaction.d.ts +0 -10
- package/dist-cjs/ask-user-interaction.js +0 -28
- package/dist-cjs/ask-user-interaction.js.map +0 -1
- package/dist-cjs/cache/web-cache.d.ts +0 -52
- package/dist-cjs/cache/web-cache.js +0 -71
- package/dist-cjs/cache/web-cache.js.map +0 -1
- package/dist-cjs/definitions/arion.d.ts +0 -8
- package/dist-cjs/definitions/arion.js +0 -108
- package/dist-cjs/definitions/arion.js.map +0 -1
- package/dist-cjs/definitions/browser/browser.d.ts +0 -2
- package/dist-cjs/definitions/browser/browser.js +0 -422
- package/dist-cjs/definitions/browser/browser.js.map +0 -1
- package/dist-cjs/definitions/browser/index.d.ts +0 -1
- package/dist-cjs/definitions/browser/index.js +0 -9
- package/dist-cjs/definitions/browser/index.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-downloads.d.ts +0 -13
- package/dist-cjs/definitions/browser/pw-downloads.js +0 -118
- package/dist-cjs/definitions/browser/pw-downloads.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-interactions.d.ts +0 -78
- package/dist-cjs/definitions/browser/pw-interactions.js +0 -214
- package/dist-cjs/definitions/browser/pw-interactions.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-responses.d.ts +0 -28
- package/dist-cjs/definitions/browser/pw-responses.js +0 -85
- package/dist-cjs/definitions/browser/pw-responses.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-session.d.ts +0 -65
- package/dist-cjs/definitions/browser/pw-session.js +0 -327
- package/dist-cjs/definitions/browser/pw-session.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-shared.d.ts +0 -22
- package/dist-cjs/definitions/browser/pw-shared.js +0 -73
- package/dist-cjs/definitions/browser/pw-shared.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-snapshot.d.ts +0 -34
- package/dist-cjs/definitions/browser/pw-snapshot.js +0 -308
- package/dist-cjs/definitions/browser/pw-snapshot.js.map +0 -1
- package/dist-cjs/definitions/browser/pw-state.d.ts +0 -22
- package/dist-cjs/definitions/browser/pw-state.js +0 -71
- package/dist-cjs/definitions/browser/pw-state.js.map +0 -1
- package/dist-cjs/definitions/browser/types.d.ts +0 -277
- package/dist-cjs/definitions/browser/types.js +0 -6
- package/dist-cjs/definitions/browser/types.js.map +0 -1
- package/dist-cjs/definitions/code-intelligence.d.ts +0 -8
- package/dist-cjs/definitions/code-intelligence.js +0 -474
- package/dist-cjs/definitions/code-intelligence.js.map +0 -1
- package/dist-cjs/definitions/core.d.ts +0 -47
- package/dist-cjs/definitions/core.js +0 -134
- package/dist-cjs/definitions/core.js.map +0 -1
- package/dist-cjs/definitions/delegation.d.ts +0 -11
- package/dist-cjs/definitions/delegation.js +0 -516
- package/dist-cjs/definitions/delegation.js.map +0 -1
- package/dist-cjs/definitions/deploy.d.ts +0 -15
- package/dist-cjs/definitions/deploy.js +0 -69
- package/dist-cjs/definitions/deploy.js.map +0 -1
- package/dist-cjs/definitions/filesystem.d.ts +0 -9
- package/dist-cjs/definitions/filesystem.js +0 -200
- package/dist-cjs/definitions/filesystem.js.map +0 -1
- package/dist-cjs/definitions/frg.d.ts +0 -3
- package/dist-cjs/definitions/frg.js +0 -67
- package/dist-cjs/definitions/frg.js.map +0 -1
- package/dist-cjs/definitions/index.d.ts +0 -19
- package/dist-cjs/definitions/index.js +0 -44
- package/dist-cjs/definitions/index.js.map +0 -1
- package/dist-cjs/definitions/memory.d.ts +0 -8
- package/dist-cjs/definitions/memory.js +0 -127
- package/dist-cjs/definitions/memory.js.map +0 -1
- package/dist-cjs/definitions/messaging.d.ts +0 -11
- package/dist-cjs/definitions/messaging.js +0 -632
- package/dist-cjs/definitions/messaging.js.map +0 -1
- package/dist-cjs/definitions/meta.d.ts +0 -11
- package/dist-cjs/definitions/meta.js +0 -353
- package/dist-cjs/definitions/meta.js.map +0 -1
- package/dist-cjs/definitions/network.d.ts +0 -11
- package/dist-cjs/definitions/network.js +0 -163
- package/dist-cjs/definitions/network.js.map +0 -1
- package/dist-cjs/definitions/outlook.d.ts +0 -2
- package/dist-cjs/definitions/outlook.js +0 -281
- package/dist-cjs/definitions/outlook.js.map +0 -1
- package/dist-cjs/definitions/patch/apply-patch.d.ts +0 -11
- package/dist-cjs/definitions/patch/apply-patch.js +0 -192
- package/dist-cjs/definitions/patch/apply-patch.js.map +0 -1
- package/dist-cjs/definitions/patch/fuzzy-match.d.ts +0 -10
- package/dist-cjs/definitions/patch/fuzzy-match.js +0 -173
- package/dist-cjs/definitions/patch/fuzzy-match.js.map +0 -1
- package/dist-cjs/definitions/patch/index.d.ts +0 -1
- package/dist-cjs/definitions/patch/index.js +0 -6
- package/dist-cjs/definitions/patch/index.js.map +0 -1
- package/dist-cjs/definitions/patch/patch-parser.d.ts +0 -50
- package/dist-cjs/definitions/patch/patch-parser.js +0 -216
- package/dist-cjs/definitions/patch/patch-parser.js.map +0 -1
- package/dist-cjs/definitions/patch/sandbox-paths.d.ts +0 -18
- package/dist-cjs/definitions/patch/sandbox-paths.js +0 -114
- package/dist-cjs/definitions/patch/sandbox-paths.js.map +0 -1
- package/dist-cjs/definitions/process/index.d.ts +0 -1
- package/dist-cjs/definitions/process/index.js +0 -9
- package/dist-cjs/definitions/process/index.js.map +0 -1
- package/dist-cjs/definitions/process/process-registry.d.ts +0 -67
- package/dist-cjs/definitions/process/process-registry.js +0 -232
- package/dist-cjs/definitions/process/process-registry.js.map +0 -1
- package/dist-cjs/definitions/process/process.d.ts +0 -9
- package/dist-cjs/definitions/process/process.js +0 -390
- package/dist-cjs/definitions/process/process.js.map +0 -1
- package/dist-cjs/definitions/process/pty-keys.d.ts +0 -13
- package/dist-cjs/definitions/process/pty-keys.js +0 -260
- package/dist-cjs/definitions/process/pty-keys.js.map +0 -1
- package/dist-cjs/definitions/process/session-slug.d.ts +0 -1
- package/dist-cjs/definitions/process/session-slug.js +0 -146
- package/dist-cjs/definitions/process/session-slug.js.map +0 -1
- package/dist-cjs/definitions/quip.d.ts +0 -2
- package/dist-cjs/definitions/quip.js +0 -199
- package/dist-cjs/definitions/quip.js.map +0 -1
- package/dist-cjs/definitions/search.d.ts +0 -9
- package/dist-cjs/definitions/search.js +0 -64
- package/dist-cjs/definitions/search.js.map +0 -1
- package/dist-cjs/definitions/session-history.d.ts +0 -11
- package/dist-cjs/definitions/session-history.js +0 -73
- package/dist-cjs/definitions/session-history.js.map +0 -1
- package/dist-cjs/definitions/shell.d.ts +0 -8
- package/dist-cjs/definitions/shell.js +0 -185
- package/dist-cjs/definitions/shell.js.map +0 -1
- package/dist-cjs/definitions/slack.d.ts +0 -2
- package/dist-cjs/definitions/slack.js +0 -184
- package/dist-cjs/definitions/slack.js.map +0 -1
- package/dist-cjs/definitions/web.d.ts +0 -8
- package/dist-cjs/definitions/web.js +0 -113
- package/dist-cjs/definitions/web.js.map +0 -1
- package/dist-cjs/executors/apply-patch.d.ts +0 -51
- package/dist-cjs/executors/apply-patch.js +0 -939
- package/dist-cjs/executors/apply-patch.js.map +0 -1
- package/dist-cjs/executors/arion.d.ts +0 -50
- package/dist-cjs/executors/arion.js +0 -126
- package/dist-cjs/executors/arion.js.map +0 -1
- package/dist-cjs/executors/code-intelligence.d.ts +0 -138
- package/dist-cjs/executors/code-intelligence.js +0 -926
- package/dist-cjs/executors/code-intelligence.js.map +0 -1
- package/dist-cjs/executors/deploy.d.ts +0 -169
- package/dist-cjs/executors/deploy.js +0 -870
- package/dist-cjs/executors/deploy.js.map +0 -1
- package/dist-cjs/executors/filesystem.d.ts +0 -150
- package/dist-cjs/executors/filesystem.js +0 -1168
- package/dist-cjs/executors/filesystem.js.map +0 -1
- package/dist-cjs/executors/frg-freshness.d.ts +0 -93
- package/dist-cjs/executors/frg-freshness.js +0 -628
- package/dist-cjs/executors/frg-freshness.js.map +0 -1
- package/dist-cjs/executors/frg.d.ts +0 -27
- package/dist-cjs/executors/frg.js +0 -335
- package/dist-cjs/executors/frg.js.map +0 -1
- package/dist-cjs/executors/index.d.ts +0 -44
- package/dist-cjs/executors/index.js +0 -144
- package/dist-cjs/executors/index.js.map +0 -1
- package/dist-cjs/executors/learning-meta.d.ts +0 -87
- package/dist-cjs/executors/learning-meta.js +0 -1166
- package/dist-cjs/executors/learning-meta.js.map +0 -1
- package/dist-cjs/executors/lsp-client.d.ts +0 -38
- package/dist-cjs/executors/lsp-client.js +0 -311
- package/dist-cjs/executors/lsp-client.js.map +0 -1
- package/dist-cjs/executors/memory.d.ts +0 -203
- package/dist-cjs/executors/memory.js +0 -797
- package/dist-cjs/executors/memory.js.map +0 -1
- package/dist-cjs/executors/meta.d.ts +0 -73
- package/dist-cjs/executors/meta.js +0 -227
- package/dist-cjs/executors/meta.js.map +0 -1
- package/dist-cjs/executors/process-registry.d.ts +0 -98
- package/dist-cjs/executors/process-registry.js +0 -470
- package/dist-cjs/executors/process-registry.js.map +0 -1
- package/dist-cjs/executors/pty-session-store.d.ts +0 -14
- package/dist-cjs/executors/pty-session-store.js +0 -35
- package/dist-cjs/executors/pty-session-store.js.map +0 -1
- package/dist-cjs/executors/pty.d.ts +0 -133
- package/dist-cjs/executors/pty.js +0 -313
- package/dist-cjs/executors/pty.js.map +0 -1
- package/dist-cjs/executors/restart.d.ts +0 -13
- package/dist-cjs/executors/restart.js +0 -156
- package/dist-cjs/executors/restart.js.map +0 -1
- package/dist-cjs/executors/search-freshness.d.ts +0 -50
- package/dist-cjs/executors/search-freshness.js +0 -235
- package/dist-cjs/executors/search-freshness.js.map +0 -1
- package/dist-cjs/executors/search-types.d.ts +0 -52
- package/dist-cjs/executors/search-types.js +0 -57
- package/dist-cjs/executors/search-types.js.map +0 -1
- package/dist-cjs/executors/search.d.ts +0 -11
- package/dist-cjs/executors/search.js +0 -103
- package/dist-cjs/executors/search.js.map +0 -1
- package/dist-cjs/executors/self-diagnose.d.ts +0 -89
- package/dist-cjs/executors/self-diagnose.js +0 -435
- package/dist-cjs/executors/self-diagnose.js.map +0 -1
- package/dist-cjs/executors/session-history.d.ts +0 -75
- package/dist-cjs/executors/session-history.js +0 -321
- package/dist-cjs/executors/session-history.js.map +0 -1
- package/dist-cjs/executors/shell-safety.d.ts +0 -27
- package/dist-cjs/executors/shell-safety.js +0 -479
- package/dist-cjs/executors/shell-safety.js.map +0 -1
- package/dist-cjs/executors/shell.d.ts +0 -168
- package/dist-cjs/executors/shell.js +0 -1002
- package/dist-cjs/executors/shell.js.map +0 -1
- package/dist-cjs/executors/utils.d.ts +0 -20
- package/dist-cjs/executors/utils.js +0 -74
- package/dist-cjs/executors/utils.js.map +0 -1
- package/dist-cjs/executors/web.d.ts +0 -89
- package/dist-cjs/executors/web.js +0 -548
- package/dist-cjs/executors/web.js.map +0 -1
- package/dist-cjs/extraction/content-extraction.d.ts +0 -48
- package/dist-cjs/extraction/content-extraction.js +0 -244
- package/dist-cjs/extraction/content-extraction.js.map +0 -1
- package/dist-cjs/extraction/index.d.ts +0 -4
- package/dist-cjs/extraction/index.js +0 -9
- package/dist-cjs/extraction/index.js.map +0 -1
- package/dist-cjs/headless-control-contract.d.ts +0 -3182
- package/dist-cjs/headless-control-contract.js +0 -973
- package/dist-cjs/headless-control-contract.js.map +0 -1
- package/dist-cjs/index.d.ts +0 -62
- package/dist-cjs/index.js +0 -438
- package/dist-cjs/index.js.map +0 -1
- package/dist-cjs/local-control-http-auth.d.ts +0 -2
- package/dist-cjs/local-control-http-auth.js +0 -6
- package/dist-cjs/local-control-http-auth.js.map +0 -1
- package/dist-cjs/mcp/client.d.ts +0 -68
- package/dist-cjs/mcp/client.js +0 -186
- package/dist-cjs/mcp/client.js.map +0 -1
- package/dist-cjs/mcp/connection.d.ts +0 -54
- package/dist-cjs/mcp/connection.js +0 -485
- package/dist-cjs/mcp/connection.js.map +0 -1
- package/dist-cjs/mcp/index.d.ts +0 -10
- package/dist-cjs/mcp/index.js +0 -31
- package/dist-cjs/mcp/index.js.map +0 -1
- package/dist-cjs/mcp/jsonrpc.d.ts +0 -36
- package/dist-cjs/mcp/jsonrpc.js +0 -149
- package/dist-cjs/mcp/jsonrpc.js.map +0 -1
- package/dist-cjs/mcp/types.d.ts +0 -178
- package/dist-cjs/mcp/types.js +0 -9
- package/dist-cjs/mcp/types.js.map +0 -1
- package/dist-cjs/network-control-adapter.d.ts +0 -4
- package/dist-cjs/network-control-adapter.js +0 -78
- package/dist-cjs/network-control-adapter.js.map +0 -1
- package/dist-cjs/network-runtime/address-types.d.ts +0 -201
- package/dist-cjs/network-runtime/address-types.js +0 -169
- package/dist-cjs/network-runtime/address-types.js.map +0 -1
- package/dist-cjs/network-runtime/db-owner-fencing.d.ts +0 -43
- package/dist-cjs/network-runtime/db-owner-fencing.js +0 -77
- package/dist-cjs/network-runtime/db-owner-fencing.js.map +0 -1
- package/dist-cjs/network-runtime/delivery-receipts.d.ts +0 -117
- package/dist-cjs/network-runtime/delivery-receipts.js +0 -277
- package/dist-cjs/network-runtime/delivery-receipts.js.map +0 -1
- package/dist-cjs/network-runtime/direct-endpoint-authority.d.ts +0 -8
- package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -30
- package/dist-cjs/network-runtime/direct-endpoint-authority.js.map +0 -1
- package/dist-cjs/network-runtime/index.d.ts +0 -24
- package/dist-cjs/network-runtime/index.js +0 -173
- package/dist-cjs/network-runtime/index.js.map +0 -1
- package/dist-cjs/network-runtime/local-control-contract.d.ts +0 -758
- package/dist-cjs/network-runtime/local-control-contract.js +0 -634
- package/dist-cjs/network-runtime/local-control-contract.js.map +0 -1
- package/dist-cjs/network-runtime/node-store-contract.d.ts +0 -49
- package/dist-cjs/network-runtime/node-store-contract.js +0 -39
- package/dist-cjs/network-runtime/node-store-contract.js.map +0 -1
- package/dist-cjs/network-runtime/pair-route-contract.d.ts +0 -100
- package/dist-cjs/network-runtime/pair-route-contract.js +0 -81
- package/dist-cjs/network-runtime/pair-route-contract.js.map +0 -1
- package/dist-cjs/network-runtime/peer-capabilities.d.ts +0 -10
- package/dist-cjs/network-runtime/peer-capabilities.js +0 -38
- package/dist-cjs/network-runtime/peer-capabilities.js.map +0 -1
- package/dist-cjs/network-runtime/peer-principal-ref.d.ts +0 -9
- package/dist-cjs/network-runtime/peer-principal-ref.js +0 -16
- package/dist-cjs/network-runtime/peer-principal-ref.js.map +0 -1
- package/dist-cjs/network-runtime/peer-state-machine.d.ts +0 -70
- package/dist-cjs/network-runtime/peer-state-machine.js +0 -130
- package/dist-cjs/network-runtime/peer-state-machine.js.map +0 -1
- package/dist-cjs/network-runtime/protocol-schemas.d.ts +0 -328
- package/dist-cjs/network-runtime/protocol-schemas.js +0 -213
- package/dist-cjs/network-runtime/protocol-schemas.js.map +0 -1
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.d.ts +0 -81
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -64
- package/dist-cjs/network-runtime/runtime-bootstrap-contract.js.map +0 -1
- package/dist-cjs/outlook/desktop-session.d.ts +0 -68
- package/dist-cjs/outlook/desktop-session.js +0 -319
- package/dist-cjs/outlook/desktop-session.js.map +0 -1
- package/dist-cjs/package.json +0 -3
- package/dist-cjs/policy.d.ts +0 -43
- package/dist-cjs/policy.js +0 -156
- package/dist-cjs/policy.js.map +0 -1
- package/dist-cjs/providers/brave.d.ts +0 -10
- package/dist-cjs/providers/brave.js +0 -67
- package/dist-cjs/providers/brave.js.map +0 -1
- package/dist-cjs/providers/duckduckgo.d.ts +0 -18
- package/dist-cjs/providers/duckduckgo.js +0 -181
- package/dist-cjs/providers/duckduckgo.js.map +0 -1
- package/dist-cjs/providers/exa.d.ts +0 -10
- package/dist-cjs/providers/exa.js +0 -68
- package/dist-cjs/providers/exa.js.map +0 -1
- package/dist-cjs/providers/firecrawl.d.ts +0 -10
- package/dist-cjs/providers/firecrawl.js +0 -60
- package/dist-cjs/providers/firecrawl.js.map +0 -1
- package/dist-cjs/providers/index.d.ts +0 -8
- package/dist-cjs/providers/index.js +0 -18
- package/dist-cjs/providers/index.js.map +0 -1
- package/dist-cjs/providers/jina.d.ts +0 -10
- package/dist-cjs/providers/jina.js +0 -54
- package/dist-cjs/providers/jina.js.map +0 -1
- package/dist-cjs/providers/router.d.ts +0 -21
- package/dist-cjs/providers/router.js +0 -101
- package/dist-cjs/providers/router.js.map +0 -1
- package/dist-cjs/providers/search-provider.d.ts +0 -35
- package/dist-cjs/providers/search-provider.js +0 -37
- package/dist-cjs/providers/search-provider.js.map +0 -1
- package/dist-cjs/providers/tavily.d.ts +0 -10
- package/dist-cjs/providers/tavily.js +0 -59
- package/dist-cjs/providers/tavily.js.map +0 -1
- package/dist-cjs/quip/desktop-session.d.ts +0 -69
- package/dist-cjs/quip/desktop-session.js +0 -354
- package/dist-cjs/quip/desktop-session.js.map +0 -1
- package/dist-cjs/registry/index.d.ts +0 -1
- package/dist-cjs/registry/index.js +0 -7
- package/dist-cjs/registry/index.js.map +0 -1
- package/dist-cjs/registry/registry.d.ts +0 -156
- package/dist-cjs/registry/registry.js +0 -762
- package/dist-cjs/registry/registry.js.map +0 -1
- package/dist-cjs/runtime-socket-local-control-client.d.ts +0 -10
- package/dist-cjs/runtime-socket-local-control-client.js +0 -368
- package/dist-cjs/runtime-socket-local-control-client.js.map +0 -1
- package/dist-cjs/security/dns-normalization.d.ts +0 -6
- package/dist-cjs/security/dns-normalization.js +0 -23
- package/dist-cjs/security/dns-normalization.js.map +0 -1
- package/dist-cjs/security/dns-pinning.d.ts +0 -27
- package/dist-cjs/security/dns-pinning.js +0 -161
- package/dist-cjs/security/dns-pinning.js.map +0 -1
- package/dist-cjs/security/external-content.d.ts +0 -40
- package/dist-cjs/security/external-content.js +0 -96
- package/dist-cjs/security/external-content.js.map +0 -1
- package/dist-cjs/security/ssrf.d.ts +0 -40
- package/dist-cjs/security/ssrf.js +0 -222
- package/dist-cjs/security/ssrf.js.map +0 -1
- package/dist-cjs/slack/desktop-session.d.ts +0 -69
- package/dist-cjs/slack/desktop-session.js +0 -367
- package/dist-cjs/slack/desktop-session.js.map +0 -1
- package/dist-cjs/tool-factory.d.ts +0 -46
- package/dist-cjs/tool-factory.js +0 -51
- package/dist-cjs/tool-factory.js.map +0 -1
- package/dist-cjs/types.d.ts +0 -1192
- package/dist-cjs/types.js +0 -9
- package/dist-cjs/types.js.map +0 -1
- package/dist-cjs/utils/retry.d.ts +0 -11
- package/dist-cjs/utils/retry.js +0 -170
- package/dist-cjs/utils/retry.js.map +0 -1
- package/dist-cjs/utils/safe-parse-json.d.ts +0 -26
- package/dist-cjs/utils/safe-parse-json.js +0 -165
- package/dist-cjs/utils/safe-parse-json.js.map +0 -1
- package/dist-cjs/utils/url.d.ts +0 -10
- package/dist-cjs/utils/url.js +0 -24
- package/dist-cjs/utils/url.js.map +0 -1
- package/src/__tests__/web-fetch-download.test.ts +0 -433
- package/src/__tests__/web-tools.test.ts +0 -619
- package/src/ask-user-interaction.ts +0 -33
- package/src/cache/web-cache.ts +0 -110
- package/src/definitions/arion.ts +0 -118
- package/src/definitions/browser/browser.ts +0 -502
- package/src/definitions/browser/index.ts +0 -5
- package/src/definitions/browser/pw-downloads.ts +0 -142
- package/src/definitions/browser/pw-interactions.ts +0 -282
- package/src/definitions/browser/pw-responses.ts +0 -98
- package/src/definitions/browser/pw-session.ts +0 -405
- package/src/definitions/browser/pw-shared.ts +0 -85
- package/src/definitions/browser/pw-snapshot.ts +0 -383
- package/src/definitions/browser/pw-state.ts +0 -101
- package/src/definitions/browser/types.ts +0 -203
- package/src/definitions/code-intelligence.ts +0 -526
- package/src/definitions/core.ts +0 -118
- package/src/definitions/delegation.ts +0 -567
- package/src/definitions/deploy.ts +0 -73
- package/src/definitions/filesystem.ts +0 -217
- package/src/definitions/frg.ts +0 -67
- package/src/definitions/index.ts +0 -28
- package/src/definitions/memory.ts +0 -150
- package/src/definitions/messaging.ts +0 -734
- package/src/definitions/meta.ts +0 -392
- package/src/definitions/network.ts +0 -179
- package/src/definitions/outlook.ts +0 -318
- package/src/definitions/patch/apply-patch.ts +0 -235
- package/src/definitions/patch/fuzzy-match.ts +0 -217
- package/src/definitions/patch/index.ts +0 -1
- package/src/definitions/patch/patch-parser.ts +0 -297
- package/src/definitions/patch/sandbox-paths.ts +0 -129
- package/src/definitions/process/index.ts +0 -5
- package/src/definitions/process/process-registry.ts +0 -303
- package/src/definitions/process/process.ts +0 -456
- package/src/definitions/process/pty-keys.ts +0 -298
- package/src/definitions/process/session-slug.ts +0 -147
- package/src/definitions/quip.ts +0 -225
- package/src/definitions/search.ts +0 -67
- package/src/definitions/session-history.ts +0 -79
- package/src/definitions/shell.ts +0 -202
- package/src/definitions/slack.ts +0 -211
- package/src/definitions/web.ts +0 -119
- package/src/executors/apply-patch.ts +0 -1035
- package/src/executors/arion.ts +0 -199
- package/src/executors/code-intelligence.ts +0 -1179
- package/src/executors/deploy.ts +0 -1066
- package/src/executors/filesystem.ts +0 -1428
- package/src/executors/frg-freshness.ts +0 -743
- package/src/executors/frg.ts +0 -394
- package/src/executors/index.ts +0 -280
- package/src/executors/learning-meta.ts +0 -1367
- package/src/executors/lsp-client.ts +0 -355
- package/src/executors/memory.ts +0 -978
- package/src/executors/meta.ts +0 -293
- package/src/executors/process-registry.ts +0 -570
- package/src/executors/pty-session-store.ts +0 -43
- package/src/executors/pty.ts +0 -342
- package/src/executors/restart.ts +0 -133
- package/src/executors/search-freshness.ts +0 -249
- package/src/executors/search-types.ts +0 -98
- package/src/executors/search.ts +0 -89
- package/src/executors/self-diagnose.ts +0 -552
- package/src/executors/session-history.ts +0 -435
- package/src/executors/shell-safety.ts +0 -519
- package/src/executors/shell.ts +0 -1243
- package/src/executors/utils.ts +0 -40
- package/src/executors/web.ts +0 -786
- package/src/extraction/content-extraction.ts +0 -281
- package/src/extraction/index.ts +0 -5
- package/src/headless-control-contract.ts +0 -1149
- package/src/index.ts +0 -788
- package/src/local-control-http-auth.ts +0 -2
- package/src/mcp/client.ts +0 -218
- package/src/mcp/connection.ts +0 -568
- package/src/mcp/index.ts +0 -11
- package/src/mcp/jsonrpc.ts +0 -195
- package/src/mcp/types.ts +0 -199
- package/src/network-control-adapter.ts +0 -88
- package/src/network-runtime/address-types.ts +0 -218
- package/src/network-runtime/db-owner-fencing.ts +0 -91
- package/src/network-runtime/delivery-receipts.ts +0 -372
- package/src/network-runtime/direct-endpoint-authority.ts +0 -35
- package/src/network-runtime/index.ts +0 -316
- package/src/network-runtime/local-control-contract.ts +0 -784
- package/src/network-runtime/node-store-contract.ts +0 -46
- package/src/network-runtime/pair-route-contract.ts +0 -97
- package/src/network-runtime/peer-capabilities.ts +0 -48
- package/src/network-runtime/peer-principal-ref.ts +0 -20
- package/src/network-runtime/peer-state-machine.ts +0 -160
- package/src/network-runtime/protocol-schemas.ts +0 -265
- package/src/network-runtime/runtime-bootstrap-contract.ts +0 -83
- package/src/outlook/desktop-session.ts +0 -409
- package/src/policy.ts +0 -171
- package/src/providers/brave.ts +0 -80
- package/src/providers/duckduckgo.ts +0 -199
- package/src/providers/exa.ts +0 -85
- package/src/providers/firecrawl.ts +0 -77
- package/src/providers/index.ts +0 -8
- package/src/providers/jina.ts +0 -70
- package/src/providers/router.ts +0 -121
- package/src/providers/search-provider.ts +0 -74
- package/src/providers/tavily.ts +0 -74
- package/src/quip/desktop-session.ts +0 -435
- package/src/registry/index.ts +0 -1
- package/src/registry/registry.ts +0 -905
- package/src/runtime-socket-local-control-client.ts +0 -632
- package/src/security/dns-normalization.ts +0 -34
- package/src/security/dns-pinning.ts +0 -138
- package/src/security/external-content.ts +0 -129
- package/src/security/ssrf.ts +0 -207
- package/src/slack/desktop-session.ts +0 -493
- package/src/tool-factory.ts +0 -91
- package/src/types.ts +0 -1341
- package/src/utils/retry.ts +0 -163
- package/src/utils/safe-parse-json.ts +0 -176
- package/src/utils/url.ts +0 -20
- package/tests/benchmarks/registry.bench.ts +0 -57
- package/tests/cache/web-cache.test.ts +0 -147
- package/tests/critical-integration.test.ts +0 -1465
- package/tests/definitions/apply-patch.test.ts +0 -586
- package/tests/definitions/browser.test.ts +0 -495
- package/tests/definitions/delegation-pause-resume.test.ts +0 -758
- package/tests/definitions/execution.test.ts +0 -671
- package/tests/definitions/messaging-inbox-scope.test.ts +0 -229
- package/tests/definitions/messaging.test.ts +0 -1468
- package/tests/definitions/outlook.test.ts +0 -30
- package/tests/definitions/process.test.ts +0 -469
- package/tests/definitions/slack.test.ts +0 -28
- package/tests/definitions/tool-inventory.test.ts +0 -218
- package/tests/e2e/delegation-quest-orchestration.e2e.test.ts +0 -433
- package/tests/e2e/memory-tool-discovery-contract.e2e.test.ts +0 -81
- package/tests/executors/apply-patch.test.ts +0 -538
- package/tests/executors/arion.test.ts +0 -309
- package/tests/executors/conversation-primitives.test.ts +0 -250
- package/tests/executors/deploy.test.ts +0 -746
- package/tests/executors/filesystem-tools.test.ts +0 -357
- package/tests/executors/filesystem.test.ts +0 -959
- package/tests/executors/frg-freshness.test.ts +0 -136
- package/tests/executors/frg-merge.test.ts +0 -70
- package/tests/executors/frg-session-content.test.ts +0 -40
- package/tests/executors/frg.test.ts +0 -56
- package/tests/executors/memory-bugfixes.test.ts +0 -257
- package/tests/executors/memory-real-memoria.integration.test.ts +0 -316
- package/tests/executors/memory.test.ts +0 -853
- package/tests/executors/meta-tools.test.ts +0 -411
- package/tests/executors/meta.test.ts +0 -683
- package/tests/executors/path-containment.test.ts +0 -51
- package/tests/executors/process-registry.test.ts +0 -505
- package/tests/executors/pty.test.ts +0 -664
- package/tests/executors/quest-security.test.ts +0 -249
- package/tests/executors/read-file-media.test.ts +0 -230
- package/tests/executors/recall-knowledge-schema.test.ts +0 -209
- package/tests/executors/recall-tags.test.ts +0 -278
- package/tests/executors/remember-null-safety.contract.test.ts +0 -41
- package/tests/executors/restart.test.ts +0 -67
- package/tests/executors/search-unified.test.ts +0 -381
- package/tests/executors/session-history.test.ts +0 -340
- package/tests/executors/session-transcript.test.ts +0 -561
- package/tests/executors/shell-abort.test.ts +0 -416
- package/tests/executors/shell-env-blocklist.test.ts +0 -648
- package/tests/executors/shell-env-process.test.ts +0 -245
- package/tests/executors/shell-process-registry.test.ts +0 -334
- package/tests/executors/shell-tools.test.ts +0 -393
- package/tests/executors/shell.test.ts +0 -690
- package/tests/executors/web-abort-vs-timeout.test.ts +0 -213
- package/tests/executors/web-integration.test.ts +0 -633
- package/tests/executors/web-symlink.test.ts +0 -18
- package/tests/executors/web.test.ts +0 -1400
- package/tests/executors/write-stdin.test.ts +0 -145
- package/tests/extraction/content-extraction.test.ts +0 -153
- package/tests/guards/tools-default-test-lane.integration.test.ts +0 -21
- package/tests/guards/tools-package-test-commands.e2e.test.ts +0 -43
- package/tests/guards/tools-test-lane-manifest.contract.test.ts +0 -76
- package/tests/guards/tools-vitest-workspace-alias.contract.test.ts +0 -63
- package/tests/helpers/async-waits.ts +0 -53
- package/tests/integration/headless-control-contract.integration.test.ts +0 -153
- package/tests/integration/memory-tool-schema-parity.integration.test.ts +0 -67
- package/tests/integration/meta-tools-round-trip.integration.test.ts +0 -506
- package/tests/integration/quest-round-trip.test.ts +0 -303
- package/tests/integration/registry-executor-flow.test.ts +0 -85
- package/tests/integration.test.ts +0 -177
- package/tests/loading-tier.test.ts +0 -126
- package/tests/mcp/client-reconnect.test.ts +0 -267
- package/tests/mcp/connection.test.ts +0 -846
- package/tests/mcp/injectable-logger.test.ts +0 -83
- package/tests/mcp/jsonrpc.test.ts +0 -109
- package/tests/mcp/lifecycle.test.ts +0 -879
- package/tests/network-runtime/address-types.contract.test.ts +0 -143
- package/tests/network-runtime/continuity-bind-schema.contract.test.ts +0 -203
- package/tests/network-runtime/local-control-contract.test.ts +0 -869
- package/tests/network-runtime/local-control-invite-token.contract.test.ts +0 -146
- package/tests/network-runtime/node-store-contract.test.ts +0 -11
- package/tests/network-runtime/pair-protocol-nodeid.contract.test.ts +0 -15
- package/tests/network-runtime/peer-state-machine.contract.test.ts +0 -148
- package/tests/network-runtime/protocol-schemas.contract.test.ts +0 -512
- package/tests/network-runtime/relay-pending-nodeid.contract.test.ts +0 -62
- package/tests/network-runtime/runtime-bootstrap-contract.test.ts +0 -227
- package/tests/network-runtime/runtime-socket-local-control-client.test.ts +0 -621
- package/tests/network-runtime/wait-for-message-script.test.ts +0 -288
- package/tests/parallel.test.ts +0 -71
- package/tests/policy.test.ts +0 -184
- package/tests/print-default-test-lane.ts +0 -14
- package/tests/print-test-lane-manifest.ts +0 -22
- package/tests/providers/brave.test.ts +0 -159
- package/tests/providers/duckduckgo.test.ts +0 -207
- package/tests/providers/exa.test.ts +0 -175
- package/tests/providers/firecrawl.test.ts +0 -168
- package/tests/providers/jina.test.ts +0 -144
- package/tests/providers/router.test.ts +0 -328
- package/tests/providers/tavily.test.ts +0 -165
- package/tests/registry/discovery.test.ts +0 -154
- package/tests/registry/injectable-logger.test.ts +0 -230
- package/tests/registry/input-validation.test.ts +0 -361
- package/tests/registry/interface-completeness.test.ts +0 -85
- package/tests/registry/mcp-integration.test.ts +0 -103
- package/tests/registry/mcp-read-only-hint.test.ts +0 -60
- package/tests/registry/memoria-discovery.test.ts +0 -390
- package/tests/registry/nested-validation.test.ts +0 -283
- package/tests/registry/pseudo-tool-filtering.test.ts +0 -258
- package/tests/registry/registration-lifecycle.test.ts +0 -133
- package/tests/registry-validation.test.ts +0 -424
- package/tests/registry.test.ts +0 -460
- package/tests/security/dns-pinning.test.ts +0 -162
- package/tests/security/external-content.test.ts +0 -144
- package/tests/security/ssrf.test.ts +0 -118
- package/tests/shell-safety-integration.test.ts +0 -32
- package/tests/shell-safety.test.ts +0 -365
- package/tests/slack/desktop-session.test.ts +0 -50
- package/tests/test-lane-manifest.ts +0 -440
- package/tests/test-utils.ts +0 -27
- package/tests/tool-factory.test.ts +0 -188
- package/tests/utils/retry.test.ts +0 -231
- package/tests/utils/url.test.ts +0 -63
- package/tsconfig.cjs.json +0 -24
- package/tsconfig.json +0 -12
- package/vitest.config.ts +0 -55
- package/vitest.e2e.config.ts +0 -24
- package/vitest.integration.config.ts +0 -24
- package/vitest.native.config.ts +0 -24
|
@@ -1,959 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @aria/tools - Filesystem executor tests
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
6
|
-
import * as fs from "node:fs/promises";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import * as os from "node:os";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
import type { ToolContext } from "../../src/types.js";
|
|
11
|
-
import {
|
|
12
|
-
executeReadFile,
|
|
13
|
-
executeWriteFile,
|
|
14
|
-
executeEditFile,
|
|
15
|
-
executeLs,
|
|
16
|
-
executeGlob,
|
|
17
|
-
executeGrep,
|
|
18
|
-
FILESYSTEM_OUTPUT_LIMITS,
|
|
19
|
-
LS_INTERNALS,
|
|
20
|
-
} from "../../src/executors/filesystem.js";
|
|
21
|
-
|
|
22
|
-
// Helper to create a unique temp directory for each test
|
|
23
|
-
const createTempDir = async (): Promise<string> => {
|
|
24
|
-
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "aria-test-"));
|
|
25
|
-
return tempDir;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Helper to clean up temp directory
|
|
29
|
-
const cleanupTempDir = async (dir: string): Promise<void> => {
|
|
30
|
-
await fs.rm(dir, { recursive: true, force: true });
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Helper to create a context
|
|
34
|
-
const createContext = (workingDir: string): ToolContext => ({
|
|
35
|
-
workingDir,
|
|
36
|
-
env: {},
|
|
37
|
-
confirm: async () => true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("Filesystem Executors", () => {
|
|
41
|
-
let tempDir: string;
|
|
42
|
-
let ctx: ToolContext;
|
|
43
|
-
|
|
44
|
-
beforeEach(async () => {
|
|
45
|
-
tempDir = await createTempDir();
|
|
46
|
-
ctx = createContext(tempDir);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
afterEach(async () => {
|
|
50
|
-
await cleanupTempDir(tempDir);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("executeReadFile", () => {
|
|
54
|
-
it("should read a file successfully", async () => {
|
|
55
|
-
const filePath = path.join(tempDir, "test.txt");
|
|
56
|
-
await fs.writeFile(filePath, "Hello, World!");
|
|
57
|
-
|
|
58
|
-
const result = await executeReadFile({ path: filePath }, ctx);
|
|
59
|
-
|
|
60
|
-
expect(result.success).toBe(true);
|
|
61
|
-
expect(result.data).toBe("Hello, World!");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should read a file with relative path", async () => {
|
|
65
|
-
const filePath = path.join(tempDir, "test.txt");
|
|
66
|
-
await fs.writeFile(filePath, "Relative test");
|
|
67
|
-
|
|
68
|
-
const result = await executeReadFile({ path: "test.txt" }, ctx);
|
|
69
|
-
|
|
70
|
-
expect(result.success).toBe(true);
|
|
71
|
-
expect(result.data).toBe("Relative test");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should support offset and limit", async () => {
|
|
75
|
-
const filePath = path.join(tempDir, "lines.txt");
|
|
76
|
-
await fs.writeFile(filePath, "line1\nline2\nline3\nline4\nline5");
|
|
77
|
-
|
|
78
|
-
const result = await executeReadFile({ path: filePath, offset: 1, limit: 2 }, ctx);
|
|
79
|
-
|
|
80
|
-
expect(result.success).toBe(true);
|
|
81
|
-
expect(result.data).toBe("line2\nline3");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should handle file with trailing newline correctly with offset/limit", async () => {
|
|
85
|
-
const filePath = path.join(tempDir, "trailing.txt");
|
|
86
|
-
// File ends with newline - common for text files
|
|
87
|
-
await fs.writeFile(filePath, "line1\nline2\nline3\n");
|
|
88
|
-
|
|
89
|
-
const result = await executeReadFile({ path: filePath, offset: 0, limit: 3 }, ctx);
|
|
90
|
-
|
|
91
|
-
expect(result.success).toBe(true);
|
|
92
|
-
// Should return 3 actual lines, not include empty line from trailing newline
|
|
93
|
-
expect(result.data).toBe("line1\nline2\nline3");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("should handle offset beyond file length", async () => {
|
|
97
|
-
const filePath = path.join(tempDir, "short.txt");
|
|
98
|
-
await fs.writeFile(filePath, "line1\nline2");
|
|
99
|
-
|
|
100
|
-
const result = await executeReadFile({ path: filePath, offset: 10, limit: 5 }, ctx);
|
|
101
|
-
|
|
102
|
-
expect(result.success).toBe(true);
|
|
103
|
-
expect(result.data).toBe("");
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("should truncate large reads by default and include resume offset guidance", async () => {
|
|
107
|
-
const filePath = path.join(tempDir, "large.txt");
|
|
108
|
-
const lines = Array.from({ length: 2500 }, (_, i) => `line-${i + 1}`);
|
|
109
|
-
await fs.writeFile(filePath, lines.join("\n"));
|
|
110
|
-
|
|
111
|
-
const result = await executeReadFile({ path: filePath }, ctx);
|
|
112
|
-
|
|
113
|
-
expect(result.success).toBe(true);
|
|
114
|
-
const data = result.data as string;
|
|
115
|
-
expect(data.split("\n").length).toBe(2000);
|
|
116
|
-
expect(result.message).toContain("truncated");
|
|
117
|
-
expect(result.message).toContain("offset=2000");
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("should reject invalid offset/limit values", async () => {
|
|
121
|
-
const filePath = path.join(tempDir, "invalid.txt");
|
|
122
|
-
await fs.writeFile(filePath, "x");
|
|
123
|
-
|
|
124
|
-
const badOffset = await executeReadFile({ path: filePath, offset: -1 }, ctx);
|
|
125
|
-
expect(badOffset.success).toBe(false);
|
|
126
|
-
expect(badOffset.message).toContain("offset");
|
|
127
|
-
|
|
128
|
-
const badLimit = await executeReadFile({ path: filePath, limit: 0 }, ctx);
|
|
129
|
-
expect(badLimit.success).toBe(false);
|
|
130
|
-
expect(badLimit.message).toContain("limit");
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should return error for non-existent file", async () => {
|
|
134
|
-
const result = await executeReadFile({ path: "nonexistent.txt" }, ctx);
|
|
135
|
-
|
|
136
|
-
expect(result.success).toBe(false);
|
|
137
|
-
expect(result.message).toContain("ENOENT");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should return error for directory", async () => {
|
|
141
|
-
const result = await executeReadFile({ path: tempDir }, ctx);
|
|
142
|
-
|
|
143
|
-
expect(result.success).toBe(false);
|
|
144
|
-
expect(result.message).toBeDefined();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("should reject absolute paths outside the working directory", async () => {
|
|
148
|
-
const outsideDir = await createTempDir();
|
|
149
|
-
try {
|
|
150
|
-
const outsideFile = path.join(outsideDir, "outside.txt");
|
|
151
|
-
await fs.writeFile(outsideFile, "outside");
|
|
152
|
-
|
|
153
|
-
const result = await executeReadFile({ path: outsideFile }, ctx);
|
|
154
|
-
expect(result.success).toBe(false);
|
|
155
|
-
expect(result.message).toContain("outside working directory");
|
|
156
|
-
} finally {
|
|
157
|
-
await cleanupTempDir(outsideDir);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("should reject prefix-collision absolute paths outside the working directory", async () => {
|
|
162
|
-
const siblingDir = `${tempDir}-evil`;
|
|
163
|
-
await fs.mkdir(siblingDir, { recursive: true });
|
|
164
|
-
const siblingFile = path.join(siblingDir, "outside.txt");
|
|
165
|
-
await fs.writeFile(siblingFile, "outside");
|
|
166
|
-
|
|
167
|
-
const result = await executeReadFile({ path: siblingFile }, ctx);
|
|
168
|
-
expect(result.success).toBe(false);
|
|
169
|
-
expect(result.message).toContain("outside working directory");
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe("home directory access", () => {
|
|
173
|
-
let fakeHome: string;
|
|
174
|
-
let originalHome: string | undefined;
|
|
175
|
-
|
|
176
|
-
beforeEach(async () => {
|
|
177
|
-
fakeHome = await createTempDir();
|
|
178
|
-
originalHome = process.env.HOME;
|
|
179
|
-
process.env.HOME = fakeHome;
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
afterEach(async () => {
|
|
183
|
-
process.env.HOME = originalHome;
|
|
184
|
-
await cleanupTempDir(fakeHome);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("should allow reading files under home directory", async () => {
|
|
188
|
-
const homeFile = path.join(fakeHome, "notes.txt");
|
|
189
|
-
await fs.writeFile(homeFile, "hello from home");
|
|
190
|
-
|
|
191
|
-
// workingDir is tempDir (different from fakeHome), so this tests the home fallback
|
|
192
|
-
const result = await executeReadFile({ path: homeFile }, ctx);
|
|
193
|
-
expect(result.success).toBe(true);
|
|
194
|
-
expect(result.message).toContain("notes.txt");
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("should block access to ~/.ssh", async () => {
|
|
198
|
-
const sshDir = path.join(fakeHome, ".ssh");
|
|
199
|
-
await fs.mkdir(sshDir, { recursive: true });
|
|
200
|
-
await fs.writeFile(path.join(sshDir, "id_rsa"), "secret-key");
|
|
201
|
-
|
|
202
|
-
const result = await executeReadFile({ path: path.join(sshDir, "id_rsa") }, ctx);
|
|
203
|
-
expect(result.success).toBe(false);
|
|
204
|
-
expect(result.message).toContain("sensitive home directory");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("should block access to ~/.aws", async () => {
|
|
208
|
-
const awsDir = path.join(fakeHome, ".aws");
|
|
209
|
-
await fs.mkdir(awsDir, { recursive: true });
|
|
210
|
-
await fs.writeFile(path.join(awsDir, "credentials"), "secret");
|
|
211
|
-
|
|
212
|
-
const result = await executeReadFile({ path: path.join(awsDir, "credentials") }, ctx);
|
|
213
|
-
expect(result.success).toBe(false);
|
|
214
|
-
expect(result.message).toContain("sensitive home directory");
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("should block access to ~/.gnupg", async () => {
|
|
218
|
-
const gpgDir = path.join(fakeHome, ".gnupg");
|
|
219
|
-
await fs.mkdir(gpgDir, { recursive: true });
|
|
220
|
-
await fs.writeFile(path.join(gpgDir, "private-keys"), "secret");
|
|
221
|
-
|
|
222
|
-
const result = await executeReadFile({ path: path.join(gpgDir, "private-keys") }, ctx);
|
|
223
|
-
expect(result.success).toBe(false);
|
|
224
|
-
expect(result.message).toContain("sensitive home directory");
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it("should block access to ~/.git-credentials", async () => {
|
|
228
|
-
const credFile = path.join(fakeHome, ".git-credentials");
|
|
229
|
-
await fs.writeFile(credFile, "https://user:token@github.com");
|
|
230
|
-
|
|
231
|
-
const result = await executeReadFile({ path: credFile }, ctx);
|
|
232
|
-
expect(result.success).toBe(false);
|
|
233
|
-
expect(result.message).toContain("sensitive home directory");
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it("should allow access to ~/.aria subdirectories", async () => {
|
|
237
|
-
const ariaDir = path.join(fakeHome, ".aria", "tools");
|
|
238
|
-
await fs.mkdir(ariaDir, { recursive: true });
|
|
239
|
-
await fs.writeFile(path.join(ariaDir, "my-tool.sh"), "#!/bin/bash\necho hi");
|
|
240
|
-
|
|
241
|
-
const result = await executeReadFile({ path: path.join(ariaDir, "my-tool.sh") }, ctx);
|
|
242
|
-
expect(result.success).toBe(true);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("should allow listing home subdirectories that are not blocked", async () => {
|
|
246
|
-
const projectsDir = path.join(fakeHome, "projects");
|
|
247
|
-
await fs.mkdir(projectsDir, { recursive: true });
|
|
248
|
-
await fs.writeFile(path.join(projectsDir, "file.ts"), "code");
|
|
249
|
-
|
|
250
|
-
const result = await executeLs({ path: projectsDir }, ctx);
|
|
251
|
-
expect(result.success).toBe(true);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("should block listing ~/.ssh", async () => {
|
|
255
|
-
const sshDir = path.join(fakeHome, ".ssh");
|
|
256
|
-
await fs.mkdir(sshDir, { recursive: true });
|
|
257
|
-
await fs.writeFile(path.join(sshDir, "config"), "Host *");
|
|
258
|
-
|
|
259
|
-
const result = await executeLs({ path: sshDir }, ctx);
|
|
260
|
-
expect(result.success).toBe(false);
|
|
261
|
-
expect(result.message).toContain("sensitive home directory");
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("should allow access to ~/.ssh when autonomy is 'full'", async () => {
|
|
265
|
-
const fullCtx = createContext(tempDir);
|
|
266
|
-
fullCtx.autonomy = "full";
|
|
267
|
-
|
|
268
|
-
const sshDir = path.join(fakeHome, ".ssh");
|
|
269
|
-
await fs.mkdir(sshDir, { recursive: true });
|
|
270
|
-
await fs.writeFile(path.join(sshDir, "config"), "Host *");
|
|
271
|
-
|
|
272
|
-
const result = await executeReadFile({ path: path.join(sshDir, "config") }, fullCtx);
|
|
273
|
-
expect(result.success).toBe(true);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("should still block ~/.ssh when autonomy is 'high'", async () => {
|
|
277
|
-
const highCtx = createContext(tempDir);
|
|
278
|
-
highCtx.autonomy = "high";
|
|
279
|
-
|
|
280
|
-
const sshDir = path.join(fakeHome, ".ssh");
|
|
281
|
-
await fs.mkdir(sshDir, { recursive: true });
|
|
282
|
-
await fs.writeFile(path.join(sshDir, "id_rsa"), "secret-key");
|
|
283
|
-
|
|
284
|
-
const result = await executeReadFile({ path: path.join(sshDir, "id_rsa") }, highCtx);
|
|
285
|
-
expect(result.success).toBe(false);
|
|
286
|
-
expect(result.message).toContain("sensitive home directory");
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
describe("executeWriteFile", () => {
|
|
292
|
-
it("should write a new file", async () => {
|
|
293
|
-
const filePath = path.join(tempDir, "new.txt");
|
|
294
|
-
|
|
295
|
-
const result = await executeWriteFile({ path: filePath, content: "New content" }, ctx);
|
|
296
|
-
|
|
297
|
-
expect(result.success).toBe(true);
|
|
298
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
299
|
-
expect(content).toBe("New content");
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it("should write with relative path", async () => {
|
|
303
|
-
const result = await executeWriteFile(
|
|
304
|
-
{ path: "relative.txt", content: "Relative content" },
|
|
305
|
-
ctx,
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
expect(result.success).toBe(true);
|
|
309
|
-
const content = await fs.readFile(path.join(tempDir, "relative.txt"), "utf-8");
|
|
310
|
-
expect(content).toBe("Relative content");
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it("should overwrite existing file by default", async () => {
|
|
314
|
-
const filePath = path.join(tempDir, "existing.txt");
|
|
315
|
-
await fs.writeFile(filePath, "Original");
|
|
316
|
-
|
|
317
|
-
const result = await executeWriteFile({ path: filePath, content: "Overwritten" }, ctx);
|
|
318
|
-
|
|
319
|
-
expect(result.success).toBe(true);
|
|
320
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
321
|
-
expect(content).toBe("Overwritten");
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it("should include structuredPatch for overwrites", async () => {
|
|
325
|
-
const filePath = path.join(tempDir, "diff-write.txt");
|
|
326
|
-
await fs.writeFile(filePath, "line 1\nline 2\nline 3\n");
|
|
327
|
-
|
|
328
|
-
const result = await executeWriteFile(
|
|
329
|
-
{ path: filePath, content: "line 1\nLINE TWO\nline 3\n" },
|
|
330
|
-
ctx,
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
expect(result.success).toBe(true);
|
|
334
|
-
const data = result.data as Record<string, unknown>;
|
|
335
|
-
expect(data.structuredPatch).toBeDefined();
|
|
336
|
-
const hunks = data.structuredPatch as Array<{ lines: string[] }>;
|
|
337
|
-
expect(hunks.length).toBeGreaterThan(0);
|
|
338
|
-
const allLines = hunks.flatMap((h) => h.lines);
|
|
339
|
-
expect(allLines).toContain("-line 2");
|
|
340
|
-
expect(allLines).toContain("+LINE TWO");
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it("should not include structuredPatch for new files", async () => {
|
|
344
|
-
const filePath = path.join(tempDir, "brand-new.txt");
|
|
345
|
-
|
|
346
|
-
const result = await executeWriteFile({ path: filePath, content: "new content" }, ctx);
|
|
347
|
-
|
|
348
|
-
expect(result.success).toBe(true);
|
|
349
|
-
const data = result.data as Record<string, unknown>;
|
|
350
|
-
expect(data.structuredPatch).toBeUndefined();
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it("should append when append option is true", async () => {
|
|
354
|
-
const filePath = path.join(tempDir, "append.txt");
|
|
355
|
-
await fs.writeFile(filePath, "Original");
|
|
356
|
-
|
|
357
|
-
const result = await executeWriteFile(
|
|
358
|
-
{ path: filePath, content: " appended", append: true },
|
|
359
|
-
ctx,
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
expect(result.success).toBe(true);
|
|
363
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
364
|
-
expect(content).toBe("Original appended");
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it("should create parent directories if needed", async () => {
|
|
368
|
-
const filePath = path.join(tempDir, "nested", "dir", "file.txt");
|
|
369
|
-
|
|
370
|
-
const result = await executeWriteFile({ path: filePath, content: "Nested content" }, ctx);
|
|
371
|
-
|
|
372
|
-
expect(result.success).toBe(true);
|
|
373
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
374
|
-
expect(content).toBe("Nested content");
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it("should enforce expectedHash optimistic concurrency", async () => {
|
|
378
|
-
const filePath = path.join(tempDir, "guarded.txt");
|
|
379
|
-
await fs.writeFile(filePath, "original");
|
|
380
|
-
|
|
381
|
-
const wrongHash = "a".repeat(64);
|
|
382
|
-
const rejected = await executeWriteFile(
|
|
383
|
-
{ path: filePath, content: "new", expectedHash: wrongHash },
|
|
384
|
-
ctx,
|
|
385
|
-
);
|
|
386
|
-
expect(rejected.success).toBe(false);
|
|
387
|
-
expect(rejected.message).toContain("Hash mismatch");
|
|
388
|
-
|
|
389
|
-
const sha256 = createHash("sha256").update("original", "utf8").digest("hex");
|
|
390
|
-
const accepted = await executeWriteFile(
|
|
391
|
-
{ path: filePath, content: "new", expectedHash: sha256 },
|
|
392
|
-
ctx,
|
|
393
|
-
);
|
|
394
|
-
expect(accepted.success).toBe(true);
|
|
395
|
-
expect((accepted.data as { currentHash: string }).currentHash).toHaveLength(64);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
describe("executeEditFile", () => {
|
|
400
|
-
it("should replace content in a file", async () => {
|
|
401
|
-
const filePath = path.join(tempDir, "edit.txt");
|
|
402
|
-
await fs.writeFile(filePath, "Hello World");
|
|
403
|
-
|
|
404
|
-
const result = await executeEditFile(
|
|
405
|
-
{ path: filePath, oldText: "World", newText: "Universe" },
|
|
406
|
-
ctx,
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
expect(result.success).toBe(true);
|
|
410
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
411
|
-
expect(content).toBe("Hello Universe");
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it("should include structuredPatch in result data", async () => {
|
|
415
|
-
const filePath = path.join(tempDir, "diff.txt");
|
|
416
|
-
await fs.writeFile(filePath, "line 1\nline 2\nline 3\nline 4\nline 5\n");
|
|
417
|
-
|
|
418
|
-
const result = await executeEditFile(
|
|
419
|
-
{ path: filePath, oldText: "line 3", newText: "LINE THREE" },
|
|
420
|
-
ctx,
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
expect(result.success).toBe(true);
|
|
424
|
-
const data = result.data as Record<string, unknown>;
|
|
425
|
-
expect(data.structuredPatch).toBeDefined();
|
|
426
|
-
expect(Array.isArray(data.structuredPatch)).toBe(true);
|
|
427
|
-
const hunks = data.structuredPatch as Array<{
|
|
428
|
-
oldStart: number;
|
|
429
|
-
newStart: number;
|
|
430
|
-
lines: string[];
|
|
431
|
-
}>;
|
|
432
|
-
expect(hunks.length).toBeGreaterThan(0);
|
|
433
|
-
// Verify the hunk contains the change
|
|
434
|
-
const allLines = hunks.flatMap((h) => h.lines);
|
|
435
|
-
expect(allLines).toContain("-line 3");
|
|
436
|
-
expect(allLines).toContain("+LINE THREE");
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it("should replace all occurrences when replaceAll is true", async () => {
|
|
440
|
-
const filePath = path.join(tempDir, "multi.txt");
|
|
441
|
-
await fs.writeFile(filePath, "foo bar foo baz foo");
|
|
442
|
-
|
|
443
|
-
const result = await executeEditFile(
|
|
444
|
-
{ path: filePath, oldText: "foo", newText: "qux", replaceAll: true },
|
|
445
|
-
ctx,
|
|
446
|
-
);
|
|
447
|
-
|
|
448
|
-
expect(result.success).toBe(true);
|
|
449
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
450
|
-
expect(content).toBe("qux bar qux baz qux");
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it("should replace only first occurrence by default", async () => {
|
|
454
|
-
const filePath = path.join(tempDir, "first.txt");
|
|
455
|
-
await fs.writeFile(filePath, "foo bar foo");
|
|
456
|
-
|
|
457
|
-
const result = await executeEditFile({ path: filePath, oldText: "foo", newText: "qux" }, ctx);
|
|
458
|
-
|
|
459
|
-
expect(result.success).toBe(true);
|
|
460
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
461
|
-
expect(content).toBe("qux bar foo");
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it("should return error if oldText not found", async () => {
|
|
465
|
-
const filePath = path.join(tempDir, "notfound.txt");
|
|
466
|
-
await fs.writeFile(filePath, "Hello World");
|
|
467
|
-
|
|
468
|
-
const result = await executeEditFile(
|
|
469
|
-
{ path: filePath, oldText: "notexist", newText: "new" },
|
|
470
|
-
ctx,
|
|
471
|
-
);
|
|
472
|
-
|
|
473
|
-
expect(result.success).toBe(false);
|
|
474
|
-
expect(result.message).toContain("not found");
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
it("should return error for non-existent file", async () => {
|
|
478
|
-
const result = await executeEditFile(
|
|
479
|
-
{ path: "nonexistent.txt", oldText: "a", newText: "b" },
|
|
480
|
-
ctx,
|
|
481
|
-
);
|
|
482
|
-
|
|
483
|
-
expect(result.success).toBe(false);
|
|
484
|
-
expect(result.message).toBeDefined();
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
it("should return error for empty oldText", async () => {
|
|
488
|
-
const filePath = path.join(tempDir, "edit.txt");
|
|
489
|
-
await fs.writeFile(filePath, "Hello World");
|
|
490
|
-
|
|
491
|
-
const result = await executeEditFile({ path: filePath, oldText: "", newText: "new" }, ctx);
|
|
492
|
-
|
|
493
|
-
expect(result.success).toBe(false);
|
|
494
|
-
expect(result.message).toContain("empty");
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
it("should enforce expectedReplacements when replaceAll is true", async () => {
|
|
498
|
-
const filePath = path.join(tempDir, "counts.txt");
|
|
499
|
-
await fs.writeFile(filePath, "foo bar foo");
|
|
500
|
-
|
|
501
|
-
const mismatch = await executeEditFile(
|
|
502
|
-
{
|
|
503
|
-
path: filePath,
|
|
504
|
-
oldText: "foo",
|
|
505
|
-
newText: "qux",
|
|
506
|
-
replaceAll: true,
|
|
507
|
-
expectedReplacements: 3,
|
|
508
|
-
},
|
|
509
|
-
ctx,
|
|
510
|
-
);
|
|
511
|
-
expect(mismatch.success).toBe(false);
|
|
512
|
-
expect(mismatch.message).toContain("expected 3");
|
|
513
|
-
|
|
514
|
-
const accepted = await executeEditFile(
|
|
515
|
-
{
|
|
516
|
-
path: filePath,
|
|
517
|
-
oldText: "foo",
|
|
518
|
-
newText: "qux",
|
|
519
|
-
replaceAll: true,
|
|
520
|
-
expectedReplacements: 2,
|
|
521
|
-
},
|
|
522
|
-
ctx,
|
|
523
|
-
);
|
|
524
|
-
expect(accepted.success).toBe(true);
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
it("should reject expectedReplacements > 1 without replaceAll", async () => {
|
|
528
|
-
const filePath = path.join(tempDir, "strict.txt");
|
|
529
|
-
await fs.writeFile(filePath, "foo foo");
|
|
530
|
-
|
|
531
|
-
const result = await executeEditFile(
|
|
532
|
-
{ path: filePath, oldText: "foo", newText: "bar", expectedReplacements: 2 },
|
|
533
|
-
ctx,
|
|
534
|
-
);
|
|
535
|
-
expect(result.success).toBe(false);
|
|
536
|
-
expect(result.message).toContain("replaceAll=true");
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
it("should enforce expectedHash before applying edit", async () => {
|
|
540
|
-
const filePath = path.join(tempDir, "guarded-edit.txt");
|
|
541
|
-
await fs.writeFile(filePath, "const x = 1;\n");
|
|
542
|
-
|
|
543
|
-
const wrongHash = "b".repeat(64);
|
|
544
|
-
const rejected = await executeEditFile(
|
|
545
|
-
{
|
|
546
|
-
path: filePath,
|
|
547
|
-
oldText: "1",
|
|
548
|
-
newText: "2",
|
|
549
|
-
expectedHash: wrongHash,
|
|
550
|
-
},
|
|
551
|
-
ctx,
|
|
552
|
-
);
|
|
553
|
-
expect(rejected.success).toBe(false);
|
|
554
|
-
expect(rejected.message).toContain("Hash mismatch");
|
|
555
|
-
|
|
556
|
-
const hash = createHash("sha256").update("const x = 1;\n", "utf8").digest("hex");
|
|
557
|
-
const accepted = await executeEditFile(
|
|
558
|
-
{
|
|
559
|
-
path: filePath,
|
|
560
|
-
oldText: "1",
|
|
561
|
-
newText: "2",
|
|
562
|
-
expectedHash: hash,
|
|
563
|
-
},
|
|
564
|
-
ctx,
|
|
565
|
-
);
|
|
566
|
-
expect(accepted.success).toBe(true);
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
it("should use fallback strategy when exact match fails due whitespace drift", async () => {
|
|
570
|
-
const filePath = path.join(tempDir, "fallback.ts");
|
|
571
|
-
await fs.writeFile(filePath, ["function run() {", " return 42;", "}", ""].join("\n"));
|
|
572
|
-
|
|
573
|
-
const result = await executeEditFile(
|
|
574
|
-
{
|
|
575
|
-
path: filePath,
|
|
576
|
-
oldText: "function run() {\nreturn 42;\n}",
|
|
577
|
-
newText: "function run() {\n return 7;\n}",
|
|
578
|
-
replaceAll: false,
|
|
579
|
-
},
|
|
580
|
-
ctx,
|
|
581
|
-
);
|
|
582
|
-
|
|
583
|
-
expect(result.success).toBe(true);
|
|
584
|
-
const data = result.data as { strategy: string };
|
|
585
|
-
expect(data.strategy).not.toBe("exact");
|
|
586
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
587
|
-
expect(content).toContain("return 7;");
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
it("should return canonical shape with filePath (not path)", async () => {
|
|
591
|
-
const filePath = path.join(tempDir, "canonical.txt");
|
|
592
|
-
await fs.writeFile(filePath, "line 1\nline 2\n");
|
|
593
|
-
const result = await executeEditFile(
|
|
594
|
-
{ path: filePath, oldText: "line 1", newText: "LINE ONE" },
|
|
595
|
-
ctx,
|
|
596
|
-
);
|
|
597
|
-
expect(result.success).toBe(true);
|
|
598
|
-
const data = result.data as Record<string, unknown>;
|
|
599
|
-
// Use realpath to handle macOS /var → /private/var symlink
|
|
600
|
-
const realFilePath = await fs.realpath(filePath);
|
|
601
|
-
expect(data.filePath).toBe(realFilePath);
|
|
602
|
-
expect(data).not.toHaveProperty("path");
|
|
603
|
-
expect(data.structuredPatch).toBeDefined();
|
|
604
|
-
});
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
describe("executeLs", () => {
|
|
608
|
-
it("should list directory contents", async () => {
|
|
609
|
-
await fs.writeFile(path.join(tempDir, "file1.txt"), "content1");
|
|
610
|
-
await fs.writeFile(path.join(tempDir, "file2.txt"), "content2");
|
|
611
|
-
await fs.mkdir(path.join(tempDir, "subdir"));
|
|
612
|
-
|
|
613
|
-
const result = await executeLs({ path: tempDir }, ctx);
|
|
614
|
-
|
|
615
|
-
expect(result.success).toBe(true);
|
|
616
|
-
const data = result.data as { entries: Array<{ name: string; type: string }> };
|
|
617
|
-
expect(data.entries.map((e) => e.name).sort()).toEqual(["file1.txt", "file2.txt", "subdir"]);
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
it("should list with relative path", async () => {
|
|
621
|
-
await fs.writeFile(path.join(tempDir, "file.txt"), "content");
|
|
622
|
-
|
|
623
|
-
const result = await executeLs({ path: "." }, ctx);
|
|
624
|
-
|
|
625
|
-
expect(result.success).toBe(true);
|
|
626
|
-
const data = result.data as { entries: Array<{ name: string }> };
|
|
627
|
-
expect(data.entries.some((e) => e.name === "file.txt")).toBe(true);
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
it("should include file type information", async () => {
|
|
631
|
-
await fs.writeFile(path.join(tempDir, "file.txt"), "content");
|
|
632
|
-
await fs.mkdir(path.join(tempDir, "dir"));
|
|
633
|
-
|
|
634
|
-
const result = await executeLs({ path: tempDir }, ctx);
|
|
635
|
-
|
|
636
|
-
expect(result.success).toBe(true);
|
|
637
|
-
const data = result.data as { entries: Array<{ name: string; type: string }> };
|
|
638
|
-
const file = data.entries.find((e) => e.name === "file.txt");
|
|
639
|
-
const dir = data.entries.find((e) => e.name === "dir");
|
|
640
|
-
expect(file?.type).toBe("file");
|
|
641
|
-
expect(dir?.type).toBe("directory");
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
it("should return error for non-existent directory", async () => {
|
|
645
|
-
const result = await executeLs({ path: "/nonexistent/dir" }, ctx);
|
|
646
|
-
|
|
647
|
-
expect(result.success).toBe(false);
|
|
648
|
-
expect(result.message).toBeDefined();
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
describe("executeLs — pagination", () => {
|
|
653
|
-
it("should return structured data with pagination metadata", async () => {
|
|
654
|
-
await fs.writeFile(path.join(tempDir, "alpha.txt"), "a");
|
|
655
|
-
await fs.mkdir(path.join(tempDir, "nested"), { recursive: true });
|
|
656
|
-
await fs.writeFile(path.join(tempDir, "nested", "beta.txt"), "b");
|
|
657
|
-
await fs.writeFile(path.join(tempDir, "nested", "skip.tmp"), "tmp");
|
|
658
|
-
|
|
659
|
-
const result = await executeLs(
|
|
660
|
-
{
|
|
661
|
-
path: ".",
|
|
662
|
-
depth: 2,
|
|
663
|
-
offset: 1,
|
|
664
|
-
limit: 1,
|
|
665
|
-
ignore: ["**/*.tmp"],
|
|
666
|
-
},
|
|
667
|
-
ctx,
|
|
668
|
-
);
|
|
669
|
-
|
|
670
|
-
expect(result.success).toBe(true);
|
|
671
|
-
expect(result.data).toMatchObject({
|
|
672
|
-
depth: 2,
|
|
673
|
-
offset: 1,
|
|
674
|
-
limit: 1,
|
|
675
|
-
ignore: ["**/*.tmp"],
|
|
676
|
-
truncated: true,
|
|
677
|
-
total: expect.any(Number),
|
|
678
|
-
entries: expect.any(Array),
|
|
679
|
-
});
|
|
680
|
-
const data = result.data as {
|
|
681
|
-
entries: Array<{ path: string; depth: number }>;
|
|
682
|
-
};
|
|
683
|
-
expect(data.entries).toHaveLength(1);
|
|
684
|
-
expect(data.entries[0]).toMatchObject({
|
|
685
|
-
path: expect.any(String),
|
|
686
|
-
depth: expect.any(Number),
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
it("should only resolve types for paged entries", async () => {
|
|
691
|
-
for (let i = 0; i < 12; i++) {
|
|
692
|
-
await fs.writeFile(path.join(tempDir, `file-${i}.txt`), String(i));
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
const originalReadType = LS_INTERNALS.readType;
|
|
696
|
-
let readTypeCalls = 0;
|
|
697
|
-
LS_INTERNALS.readType = async (entryPath: string) => {
|
|
698
|
-
readTypeCalls++;
|
|
699
|
-
return originalReadType(entryPath);
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
try {
|
|
703
|
-
const result = await executeLs({ path: ".", offset: 5, limit: 2 }, ctx);
|
|
704
|
-
expect(result.success).toBe(true);
|
|
705
|
-
expect(result.data).toMatchObject({
|
|
706
|
-
offset: 5,
|
|
707
|
-
limit: 2,
|
|
708
|
-
});
|
|
709
|
-
expect(readTypeCalls).toBeLessThanOrEqual(2);
|
|
710
|
-
} finally {
|
|
711
|
-
LS_INTERNALS.readType = originalReadType;
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
// executeMkdir, executeRm, executeMv, executeCp tests removed — tools deleted in aria-c3x
|
|
717
|
-
|
|
718
|
-
describe("executeGlob", () => {
|
|
719
|
-
it("should match files with glob pattern", async () => {
|
|
720
|
-
await fs.writeFile(path.join(tempDir, "file1.ts"), "content1");
|
|
721
|
-
await fs.writeFile(path.join(tempDir, "file2.ts"), "content2");
|
|
722
|
-
await fs.writeFile(path.join(tempDir, "file3.txt"), "content3");
|
|
723
|
-
|
|
724
|
-
const result = await executeGlob({ pattern: "*.ts" }, ctx);
|
|
725
|
-
|
|
726
|
-
expect(result.success).toBe(true);
|
|
727
|
-
const files = result.data as string[];
|
|
728
|
-
expect(files).toHaveLength(2);
|
|
729
|
-
expect(files.every((f) => f.endsWith(".ts"))).toBe(true);
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
it("should match nested files with ** pattern", async () => {
|
|
733
|
-
await fs.mkdir(path.join(tempDir, "nested", "deep"), { recursive: true });
|
|
734
|
-
await fs.writeFile(path.join(tempDir, "root.ts"), "content");
|
|
735
|
-
await fs.writeFile(path.join(tempDir, "nested", "nested.ts"), "content");
|
|
736
|
-
await fs.writeFile(path.join(tempDir, "nested", "deep", "deep.ts"), "content");
|
|
737
|
-
|
|
738
|
-
const result = await executeGlob({ pattern: "**/*.ts" }, ctx);
|
|
739
|
-
|
|
740
|
-
expect(result.success).toBe(true);
|
|
741
|
-
const files = result.data as string[];
|
|
742
|
-
expect(files.length).toBeGreaterThanOrEqual(3);
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
it("should work with absolute path pattern", async () => {
|
|
746
|
-
await fs.writeFile(path.join(tempDir, "file.txt"), "content");
|
|
747
|
-
|
|
748
|
-
const result = await executeGlob({ pattern: path.join(tempDir, "*.txt") }, ctx);
|
|
749
|
-
|
|
750
|
-
expect(result.success).toBe(true);
|
|
751
|
-
const files = result.data as string[];
|
|
752
|
-
expect(files).toHaveLength(1);
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
it("should return empty array for no matches", async () => {
|
|
756
|
-
const result = await executeGlob({ pattern: "*.nonexistent" }, ctx);
|
|
757
|
-
|
|
758
|
-
expect(result.success).toBe(true);
|
|
759
|
-
expect(result.data).toEqual([]);
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
it("should support cwd option", async () => {
|
|
763
|
-
const subdir = path.join(tempDir, "subdir");
|
|
764
|
-
await fs.mkdir(subdir);
|
|
765
|
-
await fs.writeFile(path.join(subdir, "file.ts"), "content");
|
|
766
|
-
|
|
767
|
-
const result = await executeGlob({ pattern: "*.ts", cwd: subdir }, ctx);
|
|
768
|
-
|
|
769
|
-
expect(result.success).toBe(true);
|
|
770
|
-
const files = result.data as string[];
|
|
771
|
-
expect(files).toHaveLength(1);
|
|
772
|
-
});
|
|
773
|
-
|
|
774
|
-
it("should reject cwd prefix-collision paths outside working directory", async () => {
|
|
775
|
-
const siblingDir = `${tempDir}-evil`;
|
|
776
|
-
await fs.mkdir(siblingDir, { recursive: true });
|
|
777
|
-
await fs.writeFile(path.join(siblingDir, "outside.ts"), "content");
|
|
778
|
-
|
|
779
|
-
const result = await executeGlob({ pattern: "*.ts", cwd: siblingDir }, ctx);
|
|
780
|
-
|
|
781
|
-
expect(result.success).toBe(false);
|
|
782
|
-
expect(result.message).toContain("outside working directory");
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
it("should cap glob output to hard limit", async () => {
|
|
786
|
-
const total = FILESYSTEM_OUTPUT_LIMITS.MAX_GLOB_RESULTS + 25;
|
|
787
|
-
const writes = Array.from({ length: total }, (_, i) =>
|
|
788
|
-
fs.writeFile(path.join(tempDir, `cap-${i}.txt`), "x"),
|
|
789
|
-
);
|
|
790
|
-
await Promise.all(writes);
|
|
791
|
-
|
|
792
|
-
const result = await executeGlob({ pattern: "cap-*.txt" }, ctx);
|
|
793
|
-
|
|
794
|
-
expect(result.success).toBe(true);
|
|
795
|
-
const files = result.data as string[];
|
|
796
|
-
expect(files).toHaveLength(FILESYSTEM_OUTPUT_LIMITS.MAX_GLOB_RESULTS);
|
|
797
|
-
expect(result.message).toContain("truncated");
|
|
798
|
-
});
|
|
799
|
-
});
|
|
800
|
-
|
|
801
|
-
describe("executeGrep", () => {
|
|
802
|
-
beforeEach(async () => {
|
|
803
|
-
await fs.writeFile(
|
|
804
|
-
path.join(tempDir, "file1.txt"),
|
|
805
|
-
"Hello World\nThis is a test\nHello again",
|
|
806
|
-
);
|
|
807
|
-
await fs.writeFile(path.join(tempDir, "file2.txt"), "Another file\nNo matches here");
|
|
808
|
-
await fs.writeFile(
|
|
809
|
-
path.join(tempDir, "file3.ts"),
|
|
810
|
-
'const hello = "Hello";\nfunction test() {}',
|
|
811
|
-
);
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
it("should find pattern in single file", async () => {
|
|
815
|
-
const filePath = path.join(tempDir, "file1.txt");
|
|
816
|
-
|
|
817
|
-
const result = await executeGrep({ pattern: "Hello", path: filePath }, ctx);
|
|
818
|
-
|
|
819
|
-
expect(result.success).toBe(true);
|
|
820
|
-
const data = result.data as {
|
|
821
|
-
matches: Array<{ file: string; line: number; content: string }>;
|
|
822
|
-
errors?: string[];
|
|
823
|
-
};
|
|
824
|
-
expect(data.matches.length).toBe(2);
|
|
825
|
-
expect(data.matches[0].content).toContain("Hello");
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
it("should search directory recursively", async () => {
|
|
829
|
-
const result = await executeGrep({ pattern: "Hello", path: tempDir }, ctx);
|
|
830
|
-
|
|
831
|
-
expect(result.success).toBe(true);
|
|
832
|
-
const data = result.data as { matches: Array<{ file: string }>; errors?: string[] };
|
|
833
|
-
expect(data.matches.length).toBeGreaterThanOrEqual(3);
|
|
834
|
-
});
|
|
835
|
-
|
|
836
|
-
it("should support glob patterns", async () => {
|
|
837
|
-
const result = await executeGrep({ pattern: "Hello", path: tempDir, glob: "*.txt" }, ctx);
|
|
838
|
-
|
|
839
|
-
expect(result.success).toBe(true);
|
|
840
|
-
const data = result.data as { matches: Array<{ file: string }>; errors?: string[] };
|
|
841
|
-
expect(data.matches.every((m) => m.file.endsWith(".txt"))).toBe(true);
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
it("should support case-insensitive search", async () => {
|
|
845
|
-
const result = await executeGrep({ pattern: "hello", path: tempDir, ignoreCase: true }, ctx);
|
|
846
|
-
|
|
847
|
-
expect(result.success).toBe(true);
|
|
848
|
-
const data = result.data as { matches: Array<{ content: string }>; errors?: string[] };
|
|
849
|
-
expect(data.matches.length).toBeGreaterThan(0);
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
it("should return empty array for no matches", async () => {
|
|
853
|
-
const result = await executeGrep({ pattern: "nomatchpattern123", path: tempDir }, ctx);
|
|
854
|
-
|
|
855
|
-
expect(result.success).toBe(true);
|
|
856
|
-
const data = result.data as { matches: Array<unknown>; errors?: string[] };
|
|
857
|
-
expect(data.matches).toEqual([]);
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
it("should return error for invalid regex", async () => {
|
|
861
|
-
const result = await executeGrep({ pattern: "[invalid(regex", path: tempDir }, ctx);
|
|
862
|
-
|
|
863
|
-
expect(result.success).toBe(false);
|
|
864
|
-
expect(result.message).toBeDefined();
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
it("should reject potentially catastrophic regex patterns", async () => {
|
|
868
|
-
const result = await executeGrep({ pattern: "(a+)+$", path: tempDir }, ctx);
|
|
869
|
-
|
|
870
|
-
expect(result.success).toBe(false);
|
|
871
|
-
expect((result.message ?? "").toLowerCase()).toContain("unsafe regular expression");
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
it("should reject ambiguous repeated alternation patterns prone to backtracking", async () => {
|
|
875
|
-
const result = await executeGrep({ pattern: "(a|aa)+$", path: tempDir }, ctx);
|
|
876
|
-
|
|
877
|
-
expect(result.success).toBe(false);
|
|
878
|
-
expect((result.message ?? "").toLowerCase()).toContain("unsafe regular expression");
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
it("should reject lookaround assertions for grep regex safety", async () => {
|
|
882
|
-
const result = await executeGrep({ pattern: "(?=a)a+", path: tempDir }, ctx);
|
|
883
|
-
|
|
884
|
-
expect(result.success).toBe(false);
|
|
885
|
-
expect((result.message ?? "").toLowerCase()).toContain("unsafe regular expression");
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
it("should work with relative path", async () => {
|
|
889
|
-
const result = await executeGrep({ pattern: "Hello", path: "." }, ctx);
|
|
890
|
-
|
|
891
|
-
expect(result.success).toBe(true);
|
|
892
|
-
const data = result.data as { matches: Array<{ file: string }>; errors?: string[] };
|
|
893
|
-
expect(data.matches.length).toBeGreaterThan(0);
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
it("should default path to current working directory when omitted", async () => {
|
|
897
|
-
const result = await executeGrep({ pattern: "Hello" }, ctx);
|
|
898
|
-
|
|
899
|
-
expect(result.success).toBe(true);
|
|
900
|
-
const data = result.data as { matches: Array<{ file: string }>; errors?: string[] };
|
|
901
|
-
expect(data.matches.length).toBeGreaterThan(0);
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
it("should cap grep matches to hard limit and mark truncated", async () => {
|
|
905
|
-
const hits = FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_MATCHES + 20;
|
|
906
|
-
await fs.writeFile(path.join(tempDir, "many-hits.txt"), Array(hits).fill("HIT").join("\n"));
|
|
907
|
-
|
|
908
|
-
const result = await executeGrep(
|
|
909
|
-
{ pattern: "HIT", path: path.join(tempDir, "many-hits.txt") },
|
|
910
|
-
ctx,
|
|
911
|
-
);
|
|
912
|
-
|
|
913
|
-
expect(result.success).toBe(true);
|
|
914
|
-
const data = result.data as {
|
|
915
|
-
matches: Array<{ file: string; line: number; content: string }>;
|
|
916
|
-
truncated?: boolean;
|
|
917
|
-
};
|
|
918
|
-
expect(data.matches).toHaveLength(FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_MATCHES);
|
|
919
|
-
expect(data.truncated).toBe(true);
|
|
920
|
-
expect(result.message).toContain("truncated");
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
it("should skip oversized files instead of reading them fully", async () => {
|
|
924
|
-
const oversizedPath = path.join(tempDir, "oversized.txt");
|
|
925
|
-
await fs.writeFile(
|
|
926
|
-
oversizedPath,
|
|
927
|
-
"a".repeat(FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_FILE_BYTES + 1024),
|
|
928
|
-
);
|
|
929
|
-
|
|
930
|
-
const result = await executeGrep({ pattern: "a+", path: oversizedPath }, ctx);
|
|
931
|
-
|
|
932
|
-
expect(result.success).toBe(true);
|
|
933
|
-
const data = result.data as {
|
|
934
|
-
matches: Array<{ file: string; line: number; content: string }>;
|
|
935
|
-
errors?: string[];
|
|
936
|
-
};
|
|
937
|
-
expect(data.matches).toHaveLength(0);
|
|
938
|
-
expect(data.errors?.[0]).toContain("exceeds");
|
|
939
|
-
});
|
|
940
|
-
|
|
941
|
-
it("should skip extremely long lines to cap regex evaluation risk", async () => {
|
|
942
|
-
const longLinePath = path.join(tempDir, "long-line.txt");
|
|
943
|
-
await fs.writeFile(
|
|
944
|
-
longLinePath,
|
|
945
|
-
`${"a".repeat(FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_LINE_BYTES + 1)}\nshort line`,
|
|
946
|
-
);
|
|
947
|
-
|
|
948
|
-
const result = await executeGrep({ pattern: "a+", path: longLinePath }, ctx);
|
|
949
|
-
|
|
950
|
-
expect(result.success).toBe(true);
|
|
951
|
-
const data = result.data as {
|
|
952
|
-
matches: Array<{ file: string; line: number; content: string }>;
|
|
953
|
-
errors?: string[];
|
|
954
|
-
};
|
|
955
|
-
expect(data.matches).toHaveLength(0);
|
|
956
|
-
expect(data.errors?.[0]).toContain("Skipped lines longer than");
|
|
957
|
-
});
|
|
958
|
-
});
|
|
959
|
-
});
|