@poe-platform/safe-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -0
- package/dist/agent-defs/agents/claude-code.d.ts +2 -0
- package/dist/agent-defs/agents/claude-desktop.d.ts +2 -0
- package/dist/agent-defs/agents/codex.d.ts +2 -0
- package/dist/agent-defs/agents/cursor.d.ts +2 -0
- package/dist/agent-defs/agents/gemini-cli.d.ts +2 -0
- package/dist/agent-defs/agents/goose.d.ts +2 -0
- package/dist/agent-defs/agents/index.d.ts +10 -0
- package/dist/agent-defs/agents/kimi.d.ts +2 -0
- package/dist/agent-defs/agents/opencode.d.ts +2 -0
- package/dist/agent-defs/agents/pi.d.ts +2 -0
- package/dist/agent-defs/agents/poe-agent.d.ts +2 -0
- package/dist/agent-defs/capabilities.d.ts +14 -0
- package/dist/agent-defs/index.d.ts +6 -0
- package/dist/agent-defs/registry.d.ts +3 -0
- package/dist/agent-defs/specifier.d.ts +7 -0
- package/dist/agent-defs/types.d.ts +35 -0
- package/dist/agent-harness-tools/binary-exists.d.ts +10 -0
- package/dist/agent-harness-tools/execution-env.d.ts +108 -0
- package/dist/agent-harness-tools/hooks.d.ts +30 -0
- package/dist/agent-harness-tools/index.d.ts +18 -0
- package/dist/agent-harness-tools/log-stream.d.ts +28 -0
- package/dist/agent-harness-tools/participant.d.ts +10 -0
- package/dist/agent-harness-tools/paths.d.ts +14 -0
- package/dist/agent-harness-tools/plan-readiness.d.ts +7 -0
- package/dist/agent-harness-tools/plans.d.ts +35 -0
- package/dist/agent-harness-tools/poe-command-execution.d.ts +37 -0
- package/dist/agent-harness-tools/run-logs.d.ts +17 -0
- package/dist/agent-harness-tools/run-poe-command.d.ts +33 -0
- package/dist/agent-harness-tools/runner.d.ts +33 -0
- package/dist/agent-harness-tools/select-agent.d.ts +18 -0
- package/dist/agent-harness-tools/sequence.d.ts +7 -0
- package/dist/agent-harness-tools/skill-config.d.ts +1 -0
- package/dist/agent-harness-tools/stage.d.ts +22 -0
- package/dist/agent-harness-tools/workspace-transfer.d.ts +3 -0
- package/dist/agent-spawn/acp/middleware.d.ts +38 -0
- package/dist/agent-spawn/acp/types.d.ts +180 -0
- package/dist/agent-spawn/adapters/claude.d.ts +3 -0
- package/dist/agent-spawn/adapters/codex.d.ts +2 -0
- package/dist/agent-spawn/adapters/cursor.d.ts +2 -0
- package/dist/agent-spawn/adapters/index.d.ts +12 -0
- package/dist/agent-spawn/adapters/kimi.d.ts +2 -0
- package/dist/agent-spawn/adapters/native.d.ts +5 -0
- package/dist/agent-spawn/adapters/opencode.d.ts +2 -0
- package/dist/agent-spawn/adapters/pi.d.ts +2 -0
- package/dist/agent-spawn/environment.d.ts +2 -0
- package/dist/agent-spawn/parallel.d.ts +30 -0
- package/dist/agent-spawn/retry.d.ts +26 -0
- package/dist/agent-spawn/types.d.ts +272 -0
- package/dist/auth-store/create-secret-store.d.ts +2 -0
- package/dist/auth-store/encrypted-file-store.d.ts +47 -0
- package/dist/auth-store/index.d.ts +7 -0
- package/dist/auth-store/keychain-store.d.ts +25 -0
- package/dist/auth-store/provider-store.d.ts +14 -0
- package/dist/auth-store/types.d.ts +22 -0
- package/dist/config-mutations/execution/run-mutations.d.ts +7 -0
- package/dist/config-mutations/fs-utils.d.ts +18 -0
- package/dist/config-mutations/index.d.ts +8 -0
- package/dist/config-mutations/mutations/config-mutation.d.ts +47 -0
- package/dist/config-mutations/mutations/file-mutation.d.ts +62 -0
- package/dist/config-mutations/mutations/template-mutation.d.ts +40 -0
- package/dist/config-mutations/template/render.d.ts +6 -0
- package/dist/config-mutations/types.d.ts +168 -0
- package/dist/poe-code-config/compile/schema-compiler.d.ts +11 -0
- package/dist/poe-code-config/config.d.ts +2 -0
- package/dist/poe-code-config/configured-services.d.ts +29 -0
- package/dist/poe-code-config/index.d.ts +16 -0
- package/dist/poe-code-config/inspect.d.ts +13 -0
- package/dist/poe-code-config/memory.d.ts +14 -0
- package/dist/poe-code-config/merge-callbacks.d.ts +38 -0
- package/dist/poe-code-config/merge.d.ts +2 -0
- package/dist/poe-code-config/plan-scope.d.ts +8 -0
- package/dist/poe-code-config/provider-config.d.ts +16 -0
- package/dist/poe-code-config/resolve.d.ts +2 -0
- package/dist/poe-code-config/runtime.d.ts +114 -0
- package/dist/poe-code-config/schema.d.ts +14 -0
- package/dist/poe-code-config/state/fs.d.ts +24 -0
- package/dist/poe-code-config/state/index.d.ts +12 -0
- package/dist/poe-code-config/state/jobs.d.ts +34 -0
- package/dist/poe-code-config/state/templates.d.ts +18 -0
- package/dist/poe-code-config/store.d.ts +12 -0
- package/dist/poe-code-config/types.d.ts +88 -0
- package/dist/process-runner/docker/build-context.d.ts +5 -0
- package/dist/process-runner/docker/context.d.ts +3 -0
- package/dist/process-runner/docker/docker-execution-env.d.ts +28 -0
- package/dist/process-runner/docker/docker-runner.d.ts +2 -0
- package/dist/process-runner/docker/engine.d.ts +3 -0
- package/dist/process-runner/host/host-execution-env.d.ts +2 -0
- package/dist/process-runner/host/host-runner.d.ts +3 -0
- package/dist/process-runner/index.d.ts +10 -0
- package/dist/process-runner/testing/index.d.ts +2 -0
- package/dist/process-runner/testing/mock-runner.d.ts +3 -0
- package/dist/process-runner/types.d.ts +191 -0
- package/dist/process-runner/workspace-transfer.d.ts +61 -0
- package/dist/providers/auth/api-key.d.ts +5 -0
- package/dist/providers/auth/types.d.ts +14 -0
- package/dist/providers/compatibility.d.ts +4 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/providers/anthropic.d.ts +1 -0
- package/dist/providers/providers/cloudflare.d.ts +1 -0
- package/dist/providers/providers/generated.d.ts +5 -0
- package/dist/providers/providers/openai.d.ts +1 -0
- package/dist/providers/providers/poe.d.ts +2 -0
- package/dist/providers/registry.d.ts +44 -0
- package/dist/providers/types.d.ts +54 -0
- package/dist/safe-fs/bridge/filesystem.d.ts +88 -0
- package/dist/safe-fs/bridge/index.d.ts +6 -0
- package/dist/safe-fs/bridge/types.d.ts +75 -0
- package/dist/safe-fs/config.d.ts +15 -0
- package/dist/safe-fs/config.node.d.ts +2 -0
- package/dist/safe-fs/contracts/errors.d.ts +50 -0
- package/dist/safe-fs/contracts/filesystem.d.ts +96 -0
- package/dist/safe-fs/contracts/index.d.ts +4 -0
- package/dist/safe-fs/contracts/io.d.ts +8 -0
- package/dist/safe-fs/contracts/path.d.ts +8 -0
- package/dist/safe-fs/contracts/portable-path.d.ts +13 -0
- package/dist/safe-fs/contracts/virtual-path.d.ts +7 -0
- package/dist/safe-fs/core.d.ts +12 -0
- package/dist/safe-fs/fs/memory/index.d.ts +58 -0
- package/dist/safe-fs/fs/mount/comparison.d.ts +19 -0
- package/dist/safe-fs/fs/mount/index.d.ts +44 -0
- package/dist/safe-fs/fs/overlay/index.d.ts +73 -0
- package/dist/safe-fs/fs/readonly/index.d.ts +31 -0
- package/dist/safe-fs/fs/real/index.d.ts +76 -0
- package/dist/safe-fs/fs/s3/filesystem.d.ts +93 -0
- package/dist/safe-fs/fs/s3/http/index.d.ts +2 -0
- package/dist/safe-fs/fs/s3/http/transport.d.ts +3 -0
- package/dist/safe-fs/fs/s3/http/types.d.ts +30 -0
- package/dist/safe-fs/fs/s3/index.d.ts +6 -0
- package/dist/safe-fs/fs/s3/mock.d.ts +48 -0
- package/dist/safe-fs/fs/s3/transport.d.ts +103 -0
- package/dist/safe-fs/fs/webdav/index.d.ts +2 -0
- package/dist/safe-fs/fs/webdav/webdav.d.ts +101 -0
- package/dist/safe-fs/index.d.ts +14 -0
- package/dist/safe-fs/node/filesystem.d.ts +11 -0
- package/dist/safe-fs/node/index.d.ts +2 -0
- package/dist/safe-fs/node-host.d.ts +1 -0
- package/dist/safe-fs/node-unavailable.d.ts +1 -0
- package/dist/safe-fs/platform/browser.d.ts +12 -0
- package/dist/safe-fs/platform/node.d.ts +13 -0
- package/dist/safe-js/browser/chunks/chunk-QGN6DKT5.js +4335 -0
- package/dist/safe-js/browser/chunks/chunk-QGN6DKT5.js.map +7 -0
- package/dist/safe-js/browser/safe-fs-core.js +67 -0
- package/dist/safe-js/browser/safe-fs-core.js.map +7 -0
- package/dist/safe-js/browser/safe-fs.js +67 -0
- package/dist/safe-js/browser/safe-fs.js.map +7 -0
- package/dist/safe-js/chunks/chunk-2QRYPKQQ.js +4315 -0
- package/dist/safe-js/chunks/chunk-2QRYPKQQ.js.map +7 -0
- package/dist/safe-js/chunks/chunk-4YIDX44G.js +40 -0
- package/dist/safe-js/chunks/chunk-4YIDX44G.js.map +7 -0
- package/dist/safe-js/chunks/chunk-7M2SJPSZ.js +2613 -0
- package/dist/safe-js/chunks/chunk-7M2SJPSZ.js.map +7 -0
- package/dist/safe-js/chunks/chunk-DC5B3GYM.js +8248 -0
- package/dist/safe-js/chunks/chunk-DC5B3GYM.js.map +7 -0
- package/dist/safe-js/chunks/chunk-Z3D76J4U.js +30732 -0
- package/dist/safe-js/chunks/chunk-Z3D76J4U.js.map +7 -0
- package/dist/safe-js/cli.d.ts +36 -0
- package/dist/safe-js/cli.js +724 -0
- package/dist/safe-js/cli.js.map +7 -0
- package/dist/safe-js/core.d.ts +6 -0
- package/dist/safe-js/core.js +14 -0
- package/dist/safe-js/core.js.map +7 -0
- package/dist/safe-js/dump.d.ts +2 -0
- package/dist/safe-js/error/format.d.ts +15 -0
- package/dist/safe-js/error/shape.d.ts +28 -0
- package/dist/safe-js/index.d.ts +56 -0
- package/dist/safe-js/index.js +454 -0
- package/dist/safe-js/index.js.map +7 -0
- package/dist/safe-js/interp/arguments.d.ts +10 -0
- package/dist/safe-js/interp/async.d.ts +56 -0
- package/dist/safe-js/interp/budget.d.ts +95 -0
- package/dist/safe-js/interp/exceptions.d.ts +45 -0
- package/dist/safe-js/interp/generator.d.ts +16 -0
- package/dist/safe-js/interp/globals/console-json.d.ts +14 -0
- package/dist/safe-js/interp/host-bridge.d.ts +29 -0
- package/dist/safe-js/interp/host-call.d.ts +130 -0
- package/dist/safe-js/interp/interpreter.d.ts +63 -0
- package/dist/safe-js/interp/promise-replay.d.ts +70 -0
- package/dist/safe-js/interp/regex/compile-guard.d.ts +33 -0
- package/dist/safe-js/interp/regex/parse.d.ts +62 -0
- package/dist/safe-js/interp/scope.d.ts +43 -0
- package/dist/safe-js/interp/values.d.ts +136 -0
- package/dist/safe-js/lint/index.d.ts +38 -0
- package/dist/safe-js/lint/rules/AS-export-import-meta.d.ts +21 -0
- package/dist/safe-js/lint/rules/module-registry.d.ts +33 -0
- package/dist/safe-js/lint.d.ts +1 -0
- package/dist/safe-js/loader/extract-block.d.ts +10 -0
- package/dist/safe-js/loader/find-exported.d.ts +2 -0
- package/dist/safe-js/loader/frontmatter.d.ts +5 -0
- package/dist/safe-js/migrate.d.ts +33 -0
- package/dist/safe-js/migration-file.d.ts +55 -0
- package/dist/safe-js/modules/agent.d.ts +132 -0
- package/dist/safe-js/modules/env.d.ts +14 -0
- package/dist/safe-js/modules/fail.d.ts +6 -0
- package/dist/safe-js/modules/fs-config.d.ts +12 -0
- package/dist/safe-js/modules/fs.d.ts +82 -0
- package/dist/safe-js/modules/harness.d.ts +19 -0
- package/dist/safe-js/modules/log.d.ts +16 -0
- package/dist/safe-js/modules/mcp-transport.d.ts +26 -0
- package/dist/safe-js/modules/mcp.d.ts +63 -0
- package/dist/safe-js/modules/metric.d.ts +4 -0
- package/dist/safe-js/modules/registry.d.ts +16 -0
- package/dist/safe-js/modules/time.d.ts +12 -0
- package/dist/safe-js/observability/otel.d.ts +21 -0
- package/dist/safe-js/output-stream.d.ts +12 -0
- package/dist/safe-js/parse/parse-export.d.ts +36 -0
- package/dist/safe-js/parse/parser.d.ts +356 -0
- package/dist/safe-js/parse/tokenizer.d.ts +26 -0
- package/dist/safe-js/parse.d.ts +4 -0
- package/dist/safe-js/random.d.ts +9 -0
- package/dist/safe-js/restore.d.ts +26 -0
- package/dist/safe-js/run.d.ts +74 -0
- package/dist/safe-js/runner/run-harness.d.ts +32 -0
- package/dist/safe-js/safe-fs-core.js +130 -0
- package/dist/safe-js/safe-fs-core.js.map +7 -0
- package/dist/safe-js/safe-fs-node.js +94 -0
- package/dist/safe-js/safe-fs-node.js.map +7 -0
- package/dist/safe-js/safe-fs.js +94 -0
- package/dist/safe-js/safe-fs.js.map +7 -0
- package/dist/safe-js/snapshot/arguments.d.ts +17 -0
- package/dist/safe-js/snapshot/backend.d.ts +19 -0
- package/dist/safe-js/snapshot/dump-format.d.ts +7 -0
- package/dist/safe-js/snapshot/dump.d.ts +23 -0
- package/dist/safe-js/snapshot/float32array.d.ts +12 -0
- package/dist/safe-js/snapshot/migration.d.ts +35 -0
- package/dist/safe-js/snapshot/policy.d.ts +49 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +71 -0
- package/dist/safe-js/snapshot/validation.d.ts +15 -0
- package/dist/task-list/backends/gh-issues-client.d.ts +19 -0
- package/dist/task-list/backends/gh-issues-sync.d.ts +46 -0
- package/dist/task-list/backends/gh-issues.d.ts +21 -0
- package/dist/task-list/index.d.ts +9 -0
- package/dist/task-list/move.d.ts +2 -0
- package/dist/task-list/open.d.ts +5 -0
- package/dist/task-list/state-machine.d.ts +16 -0
- package/dist/task-list/state.d.ts +29 -0
- package/dist/task-list/types.d.ts +206 -0
- package/dist/tiny-mcp-client/index.d.ts +662 -0
- package/dist/tiny-stdio-mcp-server/content/audio.d.ts +15 -0
- package/dist/tiny-stdio-mcp-server/content/convert.d.ts +16 -0
- package/dist/tiny-stdio-mcp-server/content/file-type.d.ts +11 -0
- package/dist/tiny-stdio-mcp-server/content/file.d.ts +28 -0
- package/dist/tiny-stdio-mcp-server/content/image.d.ts +15 -0
- package/dist/tiny-stdio-mcp-server/content/index.d.ts +7 -0
- package/dist/tiny-stdio-mcp-server/content/mime.d.ts +7 -0
- package/dist/tiny-stdio-mcp-server/content/remote.d.ts +5 -0
- package/dist/tiny-stdio-mcp-server/index.d.ts +9 -0
- package/dist/tiny-stdio-mcp-server/schema.d.ts +20 -0
- package/dist/tiny-stdio-mcp-server/server.d.ts +35 -0
- package/dist/tiny-stdio-mcp-server/types.d.ts +247 -0
- package/dist/toolcraft-design/acp/components.d.ts +19 -0
- package/dist/toolcraft-design/acp/index.d.ts +4 -0
- package/dist/toolcraft-design/acp/writer.d.ts +13 -0
- package/dist/toolcraft-design/components/browser.d.ts +15 -0
- package/dist/toolcraft-design/components/catalog.d.ts +26 -0
- package/dist/toolcraft-design/components/color.d.ts +31 -0
- package/dist/toolcraft-design/components/command-errors.d.ts +18 -0
- package/dist/toolcraft-design/components/detail-card.d.ts +22 -0
- package/dist/toolcraft-design/components/file-changes.d.ts +16 -0
- package/dist/toolcraft-design/components/help-formatter-plain.d.ts +5 -0
- package/dist/toolcraft-design/components/help-formatter.d.ts +50 -0
- package/dist/toolcraft-design/components/inspector-card.d.ts +21 -0
- package/dist/toolcraft-design/components/logger.d.ts +11 -0
- package/dist/toolcraft-design/components/resource-browser.d.ts +21 -0
- package/dist/toolcraft-design/components/symbols.d.ts +12 -0
- package/dist/toolcraft-design/components/table.d.ts +16 -0
- package/dist/toolcraft-design/components/template.d.ts +19 -0
- package/dist/toolcraft-design/components/text.d.ts +16 -0
- package/dist/toolcraft-design/dashboard/buffer.d.ts +25 -0
- package/dist/toolcraft-design/dashboard/components/footer.d.ts +8 -0
- package/dist/toolcraft-design/dashboard/dashboard.d.ts +20 -0
- package/dist/toolcraft-design/dashboard/index.d.ts +8 -0
- package/dist/toolcraft-design/dashboard/should-use-dashboard.d.ts +10 -0
- package/dist/toolcraft-design/dashboard/snapshot.d.ts +10 -0
- package/dist/toolcraft-design/dashboard/terminal.d.ts +37 -0
- package/dist/toolcraft-design/dashboard/types.d.ts +38 -0
- package/dist/toolcraft-design/explorer/events.d.ts +77 -0
- package/dist/toolcraft-design/explorer/index.d.ts +8 -0
- package/dist/toolcraft-design/explorer/keymap.d.ts +31 -0
- package/dist/toolcraft-design/explorer/runtime.d.ts +2 -0
- package/dist/toolcraft-design/explorer/state.d.ts +224 -0
- package/dist/toolcraft-design/index.d.ts +62 -0
- package/dist/toolcraft-design/internal/output-format.d.ts +6 -0
- package/dist/toolcraft-design/internal/strip-ansi.d.ts +1 -0
- package/dist/toolcraft-design/internal/theme-detect.d.ts +12 -0
- package/dist/toolcraft-design/internal/theme-state.d.ts +12 -0
- package/dist/toolcraft-design/prompts/index.d.ts +91 -0
- package/dist/toolcraft-design/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/dist/toolcraft-design/prompts/interactive/select.d.ts +18 -0
- package/dist/toolcraft-design/prompts/primitives/cancel.d.ts +2 -0
- package/dist/toolcraft-design/prompts/primitives/intro.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/log.d.ts +18 -0
- package/dist/toolcraft-design/prompts/primitives/note.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/outro.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/spinner.d.ts +6 -0
- package/dist/toolcraft-design/prompts/theme.d.ts +11 -0
- package/dist/toolcraft-design/screen/screen.d.ts +40 -0
- package/dist/toolcraft-design/screen/style.d.ts +16 -0
- package/dist/toolcraft-design/static/index.d.ts +4 -0
- package/dist/toolcraft-design/static/menu.d.ts +11 -0
- package/dist/toolcraft-design/static/spinner.d.ts +14 -0
- package/dist/toolcraft-design/terminal/driver.d.ts +34 -0
- package/dist/toolcraft-design/terminal/input.d.ts +25 -0
- package/dist/toolcraft-design/terminal-markdown/ast.d.ts +98 -0
- package/dist/toolcraft-design/terminal-markdown/html-renderer.d.ts +7 -0
- package/dist/toolcraft-design/terminal-markdown/index.d.ts +12 -0
- package/dist/toolcraft-design/terminal-markdown/parser.d.ts +5 -0
- package/dist/toolcraft-design/terminal-markdown/plaintext-renderer.d.ts +11 -0
- package/dist/toolcraft-design/terminal-markdown/renderer.d.ts +7 -0
- package/dist/toolcraft-design/tokens/brand.d.ts +5 -0
- package/dist/toolcraft-design/tokens/colors.d.ts +37 -0
- package/dist/toolcraft-design/tokens/index.d.ts +6 -0
- package/dist/toolcraft-design/tokens/spacing.d.ts +6 -0
- package/dist/toolcraft-design/tokens/typography.d.ts +7 -0
- package/dist/toolcraft-design/tokens/widths.d.ts +5 -0
- package/dist/toolcraft-schema/index.d.ts +184 -0
- package/dist/toolcraft-schema/json-schema/index.d.ts +5 -0
- package/dist/toolcraft-schema/json-schema/types.d.ts +33 -0
- package/dist/toolcraft-schema/json-schema-document.d.ts +14 -0
- package/dist/toolcraft-schema/json.d.ts +10 -0
- package/dist/toolcraft-schema/oneof.d.ts +15 -0
- package/dist/toolcraft-schema/record.d.ts +5 -0
- package/dist/toolcraft-schema/union.d.ts +8 -0
- package/dist/toolcraft-schema/validate.d.ts +17 -0
- package/package.json +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Poe Platform
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# SafeJS
|
|
2
|
+
|
|
3
|
+
Run a JavaScript subset with explicit host capabilities, execution budgets, and resumable checkpoints.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
Install the public package (Node.js 18.18+ and ESM):
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @poe-platform/safe-js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Save this as `example.mjs`, then run `node example.mjs`:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { Budget, run } from "@poe-platform/safe-js";
|
|
17
|
+
|
|
18
|
+
const result = await run("return prices.map(price => price * 2);", {
|
|
19
|
+
bindings: { prices: [3, 5, 8] },
|
|
20
|
+
budget: new Budget({ maxSteps: 10_000, maxCallDepth: 100 })
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!result.ok) throw result.error;
|
|
24
|
+
console.log(result.returnValue);
|
|
25
|
+
// [6, 10, 16]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`run()` takes source text, not a file path. Success returns `ok`, `returnValue`, `snapshot`, and `stats`. Handle both an `ok: false` result and a rejected promise: parsing, budget exhaustion, cancellation, and some execution failures can reject. Top-level `await` in this example lets rejections reach Node.
|
|
29
|
+
|
|
30
|
+
`@poe-platform/safe-js/core` exposes `run`, `lint`, `Budget`, and replayable-random helpers. The shared filesystem is available from `@poe-platform/safe-js/fs`, with a browser-safe `fs/core` entry. Existing `poe-code/safe-js` imports remain available through the CLI package.
|
|
31
|
+
|
|
32
|
+
## Supported features
|
|
33
|
+
|
|
34
|
+
- **JavaScript control flow:** functions and closures, async/await, loops, destructuring, spread, templates, exceptions, and synchronous generators.
|
|
35
|
+
- **Data processing:** arrays, objects, strings, numbers, JSON, Math, Map, Set, Float32Array, promises, and a bounded regular-expression subset. These are selected APIs, not complete ECMAScript implementations.
|
|
36
|
+
- **Explicit capabilities:** named, default, and namespace imports resolve against host-supplied modules. Optional helpers cover agents, MCP tools, files, environment reads, time, logging, and metrics.
|
|
37
|
+
- **Execution controls:** step, call-depth, string, array, and retained-data budgets; an absolute deadline; host cancellation; console and telemetry sinks.
|
|
38
|
+
- **Checkpoints:** capture execution state, restore compatible source, and reconcile pending host operations. Changed programs can use explicit continuation migration.
|
|
39
|
+
- **Authoring tools:** lint diagnostics and fixes, source-positioned errors, Markdown harnesses, and paired Markdown/script files. `run()` does not lint automatically; harness runners do.
|
|
40
|
+
|
|
41
|
+
Scripts have no ambient `process`, `require`, `fetch`, or filesystem access. Host functions still execute with the host's privileges. Register only the capabilities the script needs; this is not OS or process isolation.
|
|
42
|
+
|
|
43
|
+
## Add a host capability
|
|
44
|
+
|
|
45
|
+
Expose a small module rather than an entire application client:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { Budget, lint, run } from "@poe-platform/safe-js";
|
|
49
|
+
|
|
50
|
+
const source = `
|
|
51
|
+
import { lookup } from "catalog";
|
|
52
|
+
const item = await lookup("pencil");
|
|
53
|
+
return item.price;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const diagnostics = lint(source, { modules: { catalog: ["lookup"] } });
|
|
57
|
+
if (diagnostics.some(diagnostic => diagnostic.severity === "error")) {
|
|
58
|
+
throw new Error(JSON.stringify(diagnostics));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = await run(source, {
|
|
62
|
+
modules: {
|
|
63
|
+
catalog: {
|
|
64
|
+
lookup: async name => {
|
|
65
|
+
if (name !== "pencil") throw new Error("Unknown item");
|
|
66
|
+
return { price: 2 };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
budget: new Budget({ maxSteps: 10_000, maxCallDepth: 100 })
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (!result.ok) throw result.error;
|
|
74
|
+
console.log(result.returnValue);
|
|
75
|
+
// 2
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The lint registry describes exports; the runtime registry supplies their values. Both accept records or Maps. Module names are host-defined identifiers, not file paths or npm packages. Validate arguments and enforce permissions inside each host operation. Adding a function does not make its effects safe to replay.
|
|
79
|
+
|
|
80
|
+
## Options
|
|
81
|
+
|
|
82
|
+
### Execution
|
|
83
|
+
|
|
84
|
+
`run(source, options?)` accepts:
|
|
85
|
+
|
|
86
|
+
| Option | Purpose / default |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `bindings` | Global input values and host functions; none by default. |
|
|
89
|
+
| `modules` | Module names mapped to export records or Maps; none by default. |
|
|
90
|
+
| `budget` | A `Budget` instance. Without one, only the default call-depth limit of 1,000 is configured. |
|
|
91
|
+
| `signal` | Host `AbortSignal` for cancellation. |
|
|
92
|
+
| `filename` | Diagnostic filename; defaults to `<input>`. |
|
|
93
|
+
| `entryPointArgs` | Arguments for invoking the default-exported function. Omit for top-level execution only. |
|
|
94
|
+
| `importMeta` | Host-supplied fields exposed through `import.meta`. |
|
|
95
|
+
| `sink` | Console destination with `log(...args)` and `error(...args)`; defaults to the host console. |
|
|
96
|
+
| `otelSink` | Telemetry with `startSpan` and `recordException`; spans implement `setAttribute`, `addEvent`, and `end`. Optional; `noopOtelSink` is available. |
|
|
97
|
+
| `randomSeed`, `random` | Seed for built-in `Math.random`, or a custom `{ next, seed, snapshot }` generator. `random` takes precedence. |
|
|
98
|
+
| `clock` | Clock-state provider with `snapshot()` returning `{ next }` or `undefined`; not a replacement for host time. |
|
|
99
|
+
| `snapshot` | Previously captured state to resume. |
|
|
100
|
+
| `snapshotPath`, `snapshotBackend` | Checkpoint output file or custom backend (`read`, `write`, `remove`); backend takes precedence. Neither automatically loads state into `snapshot`. |
|
|
101
|
+
| `snapshotIntervalMs` | Periodic checkpoint interval when persistence is configured: 30,000 ms; `0` disables periodic writes. Capture happens at interpreter yield points. |
|
|
102
|
+
| `hostCallResumeProvider` | Reconciles pending external operations on restore; returns a matching `HostCallResumeProof`. |
|
|
103
|
+
|
|
104
|
+
`new Budget(options?)` accepts optional limits. A custom budget replaces the default, so include `maxCallDepth` if you want that guard.
|
|
105
|
+
|
|
106
|
+
| Option | Limit |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `maxSteps` | Interpreter work counter. |
|
|
109
|
+
| `deadline` | Absolute epoch milliseconds or a `Date`, not a duration. |
|
|
110
|
+
| `maxCallDepth` | Nested interpreter calls. |
|
|
111
|
+
| `stringLength`, `arrayLength` | Individual string and array lengths. |
|
|
112
|
+
| `dataSize` | Retained sandbox data units, not bytes of process memory. |
|
|
113
|
+
|
|
114
|
+
There are no runtime environment variables to set. `makeEnvModule({ allow, values? })` grants reads of names in `allow`; `values` supplies an explicit string map instead of reading the host's `process.env`. Disallowed reads throw `EnvAccessError`; allowed but unset names return `undefined`. Agent and MCP integrations may require their own credentials.
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary>Linting, parsing, and value conversion</summary>
|
|
118
|
+
|
|
119
|
+
`lint(source, options?)` returns diagnostics with severity, code, message, filename, line, column, span, and optional fix/hint. With `fix: true`, it returns `{ diagnostics, fixed, fixes }` instead.
|
|
120
|
+
|
|
121
|
+
| Option | Purpose |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `filename`, `allowedGlobals` | Diagnostic filename and additional permitted global names. |
|
|
124
|
+
| `modules` | Export-name lists, or `{ exports, filename?, source? }` descriptions. Typed `exports` map names to type strings or `{ type?, async? }`; source descriptions enable import-cycle checks. |
|
|
125
|
+
| `allowedExportNames` | Permitted named exports. |
|
|
126
|
+
| `defaultExport` | Expected entry point: `{ parameters?: string[], required?: boolean }`. |
|
|
127
|
+
| `frontmatterFields` | Fields to check for unused harness configuration. |
|
|
128
|
+
| `largeLiteralThreshold` | Threshold for large-literal diagnostics. |
|
|
129
|
+
| `fix`, `fixRanges` | Apply available fixes, optionally restricted to source ranges. |
|
|
130
|
+
|
|
131
|
+
`parse(source, filename?)` parses a single statement/expression; `parseModule(source, filename?)` parses a module. `formatInterpreterError(error, { source?, filename?, hostCallName?, maxMessageLength? })` formats an error; `(source, diagnostic)` is also supported.
|
|
132
|
+
|
|
133
|
+
`deepCopyToSandbox(value)` and `deepCopyFromSandbox(value, { wrapClosure? })` convert supported values. `wrapClosure` lets the host choose how to represent an exported sandbox function. Not every native JavaScript object is convertible.
|
|
134
|
+
|
|
135
|
+
</details>
|
|
136
|
+
|
|
137
|
+
<details>
|
|
138
|
+
<summary>Optional host modules</summary>
|
|
139
|
+
|
|
140
|
+
Factories return exports to register in `modules`; calling a factory alone does not grant access.
|
|
141
|
+
|
|
142
|
+
| Factory | Configuration and capabilities |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `makeAgentModule(spawnAgent, options?)` | Inject the agent runner. Options: `defaultRetry`, `onEvent`, `otelSink`. Exposes `spawn`, `spawn.retry`, and `spawn.parallel`; call options follow this table. |
|
|
145
|
+
| `makeMcpModule(options)` | Required `servers` map: stdio `{ command, args?, cwd?, env? }` or HTTP `{ url, headers? }`. Options: `requestTimeoutMs` (30,000), `closeTimeoutMs` (1,000), `maxToolPages` (100), `signal`, and injected `fetch`/`spawn`. Named clients expose `tools`, `tool`, `toolBatch`, and `close`; close managed clients when finished. A custom connector function is also accepted. |
|
|
146
|
+
| `makeFsModule(options?)` | Node-backed `{ root?, fs? }`, or shared-filesystem `{ adapter, root?, cwd?, signal? }`; do not combine `fs` and `adapter`. Node access without `root` is unconfined. With an adapter, `root` confines access and `cwd` selects the virtual relative-path base; without `root`, explicit `cwd` also confines access. Omitting both uses virtual `/`. Read text with `readFile(path, "utf8")`; see the [module methods](src/modules/fs.ts) and [filesystem package](../safe-fs/README.md). |
|
|
147
|
+
| `makeEnvModule(namesOrOptions)` | Allowed-name array or `{ allow, values? }`; exposes `get(name)`. `parseEnvConfig(json)` accepts the object form. |
|
|
148
|
+
| `makeTimeModule(options?)` | `now`, `random`, `seed`, `signal`; exposes `now`, `random`, `sleep`, `uuid`. Defaults to host time/randomness; `seed` makes the random generator deterministic, and explicit `random` takes precedence. |
|
|
149
|
+
| `makeLogModule(sink)` | Sends timestamped `info`, `error`, and `event` entries to your callback. |
|
|
150
|
+
| `makeMetricModule(npmRunner)` | Runs `metric:<name>` through your callback; reads the final nonempty stdout line as a finite numeric score. |
|
|
151
|
+
| `makeHarnessModule(frontmatter, meta)` | `meta` is `{ kind, version, filepath }`. Exposes `tasks`, `agents`, `meta`, and `applyConstraints`; prompt constraints come from frontmatter `principles` and `constraints`. |
|
|
152
|
+
| `makeFailModule()` | Exposes a default function that throws a harness failure. No options. |
|
|
153
|
+
|
|
154
|
+
**Agent calls.** A definition is a name or `{ agent, prompt?, model?, mode?, cwd?, mcp? }`. `spawn(definition, options)` requires `prompt` and accepts `check` (default `false`), `label`, `model`, `mode`, `cwd`, `mcp`, `otelSink`, `timeoutMs`, and `signal`. Modes are `read`, `edit`, `auto`, and `yolo`, subject to provider support. `mcp` maps server names to `{ command, args?, env?, timeout? }`.
|
|
155
|
+
|
|
156
|
+
`spawn.retry(definition, options, retryOptions)` and `defaultRetry` use `{ maxAttempts, backoffMs, isErrorRetryable?, isRetryable? }`. `spawn.parallel(calls, options?)` accepts definition/options tuples or spawn-handle factories; options are `check`, `maxConcurrent`, `failFast`, and `signal`. Usage helpers are `createSpawnUsageAccumulator()` and `runWithSpawnUsageAccumulator(accumulator, operation)`.
|
|
157
|
+
|
|
158
|
+
**Config files.** `parseMcpConfig(json, directory)` accepts `servers` and the three numeric MCP limits, resolving stdio paths against `directory`. `parseFsConfig(json)` accepts `{ adapter: { type, options }, root?, cwd? }`; `resolveFsConfig(config, { registry? })` constructs the adapter for `makeFsModule`. Built-in types are `memory` and `real`; `real` requires an absolute host `options.root`. Outer `root`/`cwd` are absolute virtual paths. Custom registry descriptors supply `validateOptions` and `create`. Signals and injected functions are SDK options, not JSON fields.
|
|
159
|
+
|
|
160
|
+
</details>
|
|
161
|
+
|
|
162
|
+
<details>
|
|
163
|
+
<summary>Checkpoints and recovery</summary>
|
|
164
|
+
|
|
165
|
+
- `dump(resultOrRunningPromise, { mode?, onFailure? })` returns checkpoint JSON. `mode` is `capture` or `replay`; `onFailure` is `throw` or `checkpoint`.
|
|
166
|
+
- `restore(snapshot, { source })` validates state for compatible source; pass it as `run`'s `snapshot` option. It does not run the program.
|
|
167
|
+
- `new FileSnapshotBackend(path, { writeMaxAttempts?, writeRetryDelayMs? })` defaults to 3 write attempts and a 100 ms retry delay.
|
|
168
|
+
- `createReplayableRandom({ seed?, snapshot? })` supplies `next`, `seed`, `snapshot`, and `restore` for reproducible random sequences.
|
|
169
|
+
- `declareHostOperation(fn, policy, { onReplay? })` declares `re-issue` or `read-side-effect` recovery policy. `registerPendingHostCallPolicy({ moduleId, operation, policy })` registers it by name. Only mark operations re-issuable when repeating them is acceptable; a declaration does not implement deduplication or external recovery.
|
|
170
|
+
- `inspectSnapshotMigration(snapshot, { source })` inspects outstanding work. `migrateSnapshot(snapshot, { source, targetSource, state, reconciliation })` creates a continuation checkpoint. Reconciliation supplies `checkpointDigest`, `quiescent`, and `calls`; each call has `callId` and disposition `not-performed`, `fulfilled` with `value`, or `rejected` with `reason`.
|
|
171
|
+
- `migrateSnapshotFile(options)` accepts `snapshotPath`, `sourcePath`, `targetSourcePath`, `planPath`, `outputPath`, `inspect`, `dryRun`, and `cwd`. Inspect mode needs the checkpoint and original source; migration also needs the target, plan, and new output path. See [continuation migration](MIGRATION.md) before changing a checkpointed program.
|
|
172
|
+
|
|
173
|
+
</details>
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary>Harness files and command line</summary>
|
|
177
|
+
|
|
178
|
+
`runHarness(filepath, options)` reads `.safejs`, `.ajs`, or Markdown executable blocks. Required `modulesFor(frontmatter, { filepath, kind, version })` supplies capabilities. Optional fields: `budget`, `otelSink`, `signal`, `snapshotBackend`, `snapshotIntervalMs`, `snapshotPath`.
|
|
179
|
+
|
|
180
|
+
`runHarnessPair(filepath, options)` uses the same options for a Markdown/`.ajs` pair. The script exports a default arrow function accepting `frontmatter`; Markdown body and metadata are available through `import.meta`. Loader helpers are `splitFrontmatter(markdown)`, `extractBlock(markdown, startLine?)`, and `findExportedConstInitializer(module, name)`.
|
|
181
|
+
|
|
182
|
+
The bundled runner is `npx poe-safe-js <script.md|script.safejs|script.ajs>` (`poe-safejs` is an alias). It lints before execution and uses **stub agents and metrics**, not real agent runs. Try the [pipeline](examples/pipeline.md), [superintendent](examples/superintendent.md), or [experiment](examples/experiment.md) shapes; use your own host modules or `poe-code harness run` for real integrations.
|
|
183
|
+
|
|
184
|
+
| Flag | Purpose |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| `--fix` | Write available lint fixes before running. |
|
|
187
|
+
| `--fs`, `--fs-root <path>` | Enable real filesystem access, rooted at the script directory by default. `--fs-root` requires `--fs`. |
|
|
188
|
+
| `--fs-config <path>` | Filesystem JSON config; cannot be repeated or combined with `--fs`/`--fs-root`. |
|
|
189
|
+
| `--env-config <path>`, `--mcp-config <path>` | Explicit environment/MCP JSON grants. These integrations are real, not stubs. |
|
|
190
|
+
| `--snapshot <path>`, `--restore <path>` | Save state or load a checkpoint; interrupt capture is best-effort. |
|
|
191
|
+
| `--max-steps <n>`, `--data-size <n>` | Interpreter budget limits. |
|
|
192
|
+
| `-h`, `--help` | Usage and exit codes. |
|
|
193
|
+
|
|
194
|
+
`migrate` takes a checkpoint path plus `--from`, and either `--inspect` or `--to`, `--plan`, `--output`, with optional `--dry-run`.
|
|
195
|
+
|
|
196
|
+
For embedding, `runCli(argv, options?)` comes from `@poe-platform/safe-js/cli`. Options: `cwd`, `env`, `mcp`, `modulesFor`, `process`, `readFile`, `stat`, `stdout`, `stderr`, `writeFile`. Its `modulesFor` callback also receives `{ stdout, stderr }`. Do not combine SDK `env`/`mcp` options with their config-file flags.
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
## Meaningful limitations
|
|
201
|
+
|
|
202
|
+
- **Not a full JavaScript engine.** No user-defined classes/prototype chains, async generators, dynamic imports, or automatic multi-file/npm resolution. No browser build, DOM, general Node API, `eval`, or `Function` constructor. Built-in coverage is selective; lint success is not a runtime compatibility guarantee.
|
|
203
|
+
- **Some familiar syntax differs.** Binary `in` is unsupported; use `Object.hasOwn(object, key)` for own-property checks. Regex supports `g`, `i`, `m`, and `s`, but not lookaround, backreferences, named groups, Unicode property escapes, or other flags. Compilation and matching have fixed limits in addition to configured budgets.
|
|
204
|
+
- **Budgets are not hard resource isolation.** Limits govern interpreter work, not arbitrary host functions or total process memory. Deadlines are checked cooperatively; cancellation cannot forcibly stop a blocking host call or undo its effects. Add host-operation timeouts and external isolation where required.
|
|
205
|
+
- **Recovery is not exactly-once delivery.** Replay can repeat work and consumes budget again. Pending side effects need external reconciliation; opaque host handles and native iterator frames are not portable checkpoint state. Keep compatible source for ordinary restore or explicitly migrate. Checkpoints can contain input data and host results: store them as sensitive data.
|
|
206
|
+
- **Filesystem access is a grant, not an OS sandbox.** The helper is a subset of `node:fs/promises`, with text-oriented results and no file handles, streams, or Buffer API. Root checks do not isolate the process from concurrent filesystem changes. Prefer narrow host operations when a script only needs a few files.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { claudeCodeAgent } from "./claude-code.js";
|
|
2
|
+
export { claudeDesktopAgent } from "./claude-desktop.js";
|
|
3
|
+
export { codexAgent } from "./codex.js";
|
|
4
|
+
export { cursorAgent } from "./cursor.js";
|
|
5
|
+
export { geminiCliAgent } from "./gemini-cli.js";
|
|
6
|
+
export { openCodeAgent } from "./opencode.js";
|
|
7
|
+
export { kimiAgent } from "./kimi.js";
|
|
8
|
+
export { gooseAgent } from "./goose.js";
|
|
9
|
+
export { piAgent } from "./pi.js";
|
|
10
|
+
export { poeAgentAgent } from "./poe-agent.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AgentCapability } from "./types.js";
|
|
2
|
+
export declare function listAgentsWithCapability(capability: AgentCapability, options?: {
|
|
3
|
+
includeAliases?: boolean;
|
|
4
|
+
}): readonly string[];
|
|
5
|
+
export declare function agentSupportsCapability(input: string, capability: AgentCapability): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The single message for every agent argument that misses. It distinguishes a
|
|
8
|
+
* typo (unknown id, plus a did-you-mean) from a real capability gap ("pi
|
|
9
|
+
* supports: spawn"), and always names the agents the command does accept.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatAgentCapabilityError(input: {
|
|
12
|
+
agent: string;
|
|
13
|
+
capability: AgentCapability;
|
|
14
|
+
}): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { AgentCapability, AgentDefinition, ApiShapeId, OtelCaptureDefinition } from "./types.js";
|
|
2
|
+
export type { AgentSpecifier } from "./specifier.js";
|
|
3
|
+
export { claudeCodeAgent, claudeDesktopAgent, codexAgent, cursorAgent, geminiCliAgent, openCodeAgent, kimiAgent, gooseAgent, piAgent, poeAgentAgent } from "./agents/index.js";
|
|
4
|
+
export { allAgents, resolveAgentId } from "./registry.js";
|
|
5
|
+
export { agentSupportsCapability, formatAgentCapabilityError, listAgentsWithCapability } from "./capabilities.js";
|
|
6
|
+
export { parseAgentSpecifier, formatAgentSpecifier, normalizeAgentId } from "./specifier.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface AgentSpecifier {
|
|
2
|
+
agent: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function parseAgentSpecifier(input: string): AgentSpecifier;
|
|
6
|
+
export declare function formatAgentSpecifier(specifier: AgentSpecifier): string;
|
|
7
|
+
export declare function normalizeAgentId(input: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ApiShapeId = "openai-chat-completions" | "openai-responses" | "anthropic-messages" | "google-generations";
|
|
2
|
+
/**
|
|
3
|
+
* The poe-code surfaces an agent can be used with. This is the single
|
|
4
|
+
* published source for each command's allow-list; `agent-capability-matrix.test.ts`
|
|
5
|
+
* pins every value to the registry that implements it, so the sets cannot drift.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentCapability = "spawn" | "configure" | "install" | "test" | "skill" | "mcp";
|
|
8
|
+
export interface OtelCaptureDefinition {
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
args?: (endpoint: string, content: boolean) => string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AgentDefinition {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
label: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
aliases?: string[];
|
|
18
|
+
/** Binary name for CLI agents. Optional for GUI-only apps like Claude Desktop. */
|
|
19
|
+
binaryName?: string;
|
|
20
|
+
readonly capabilities?: readonly AgentCapability[];
|
|
21
|
+
readonly apiShapes?: readonly ApiShapeId[];
|
|
22
|
+
readonly otelCapture?: OtelCaptureDefinition;
|
|
23
|
+
configPath?: string;
|
|
24
|
+
readonly configPaths?: {
|
|
25
|
+
readonly darwin: string;
|
|
26
|
+
readonly linux: string;
|
|
27
|
+
readonly win32: string;
|
|
28
|
+
};
|
|
29
|
+
branding: {
|
|
30
|
+
colors: {
|
|
31
|
+
dark: string;
|
|
32
|
+
light: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface BinaryExistsDetectorResult {
|
|
2
|
+
exitCode: number;
|
|
3
|
+
stdout: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BinaryExistsDetector {
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
validate(result: BinaryExistsDetectorResult): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createBinaryExistsDetectors(binaryName: string): BinaryExistsDetector[];
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { RunnerScope, RuntimeConfig } from "../poe-code-config/index.js";
|
|
2
|
+
import type { RunHandle, Runner, RunSpec } from "../process-runner/index.js";
|
|
3
|
+
import type { StateManager } from "../poe-code-config/index.js";
|
|
4
|
+
export type { RuntimeConfig } from "../poe-code-config/index.js";
|
|
5
|
+
export type { RunHandle, RunSpec } from "../process-runner/index.js";
|
|
6
|
+
export type ExecutionEnvType = "host" | "docker";
|
|
7
|
+
export type JobStatus = "running" | "exited" | "killed" | "lost";
|
|
8
|
+
export interface ExecutionEnvFactory {
|
|
9
|
+
readonly type: ExecutionEnvType;
|
|
10
|
+
readonly supportsDetach?: boolean;
|
|
11
|
+
/** Whether uploadWorkspace/downloadWorkspace move real files, i.e. whether runner.sync means anything. */
|
|
12
|
+
readonly supportsWorkspaceTransfer?: boolean;
|
|
13
|
+
open(spec: OpenSpec): Promise<OpenedEnv>;
|
|
14
|
+
attach(envId: string, context?: AttachedJobContext): Promise<OpenedEnv>;
|
|
15
|
+
}
|
|
16
|
+
export interface OpenSpec {
|
|
17
|
+
cwd: string;
|
|
18
|
+
runtimeCwd?: string;
|
|
19
|
+
runtime: RuntimeConfig;
|
|
20
|
+
runner?: RunnerScope;
|
|
21
|
+
state?: StateManager;
|
|
22
|
+
hostRunner?: Runner;
|
|
23
|
+
env: Record<string, string>;
|
|
24
|
+
uploadIgnoreFiles: string[];
|
|
25
|
+
jobLabel: {
|
|
26
|
+
tool: string;
|
|
27
|
+
argv: string[];
|
|
28
|
+
displayArgv?: string[];
|
|
29
|
+
};
|
|
30
|
+
execution?: {
|
|
31
|
+
wrapForLogTee?: boolean;
|
|
32
|
+
stdin?: RunSpec["stdin"];
|
|
33
|
+
stdout?: RunSpec["stdout"];
|
|
34
|
+
stderr?: RunSpec["stderr"];
|
|
35
|
+
env?: RunSpec["env"];
|
|
36
|
+
tty?: boolean;
|
|
37
|
+
input?: string | Buffer;
|
|
38
|
+
captureOutput?: boolean;
|
|
39
|
+
activityTimeoutMs?: number;
|
|
40
|
+
activityTimeoutSource?: "all" | "stdout";
|
|
41
|
+
onStdout?(chunk: string): void;
|
|
42
|
+
onStderr?(chunk: string): void;
|
|
43
|
+
};
|
|
44
|
+
shellSpec?: RunSpec;
|
|
45
|
+
}
|
|
46
|
+
export interface UploadResult {
|
|
47
|
+
files: number;
|
|
48
|
+
bytes: number;
|
|
49
|
+
skipped: {
|
|
50
|
+
path: string;
|
|
51
|
+
bytes: number;
|
|
52
|
+
reason: "max_size";
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
export interface DownloadResult {
|
|
56
|
+
files: number;
|
|
57
|
+
bytes: number;
|
|
58
|
+
conflicts: {
|
|
59
|
+
path: string;
|
|
60
|
+
reason: "local_modified";
|
|
61
|
+
}[];
|
|
62
|
+
}
|
|
63
|
+
export interface LogChunk {
|
|
64
|
+
byteOffset: number;
|
|
65
|
+
data: string;
|
|
66
|
+
}
|
|
67
|
+
export interface AttachedJobContext {
|
|
68
|
+
jobId: string;
|
|
69
|
+
tool: string;
|
|
70
|
+
argv: string[];
|
|
71
|
+
cwd: string;
|
|
72
|
+
reattachContext?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
export interface OpenedEnv {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly job: JobHandle | null;
|
|
77
|
+
readonly reattachContext?: Record<string, unknown>;
|
|
78
|
+
uploadWorkspace(): Promise<UploadResult>;
|
|
79
|
+
downloadWorkspace(opts: {
|
|
80
|
+
conflictPolicy: "refuse" | "overwrite";
|
|
81
|
+
}): Promise<DownloadResult>;
|
|
82
|
+
exec(spec: RunSpec): RunHandle;
|
|
83
|
+
detach(): Promise<JobHandle>;
|
|
84
|
+
shell(): RunHandle;
|
|
85
|
+
close(): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
export interface JobHandle {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly envId: string;
|
|
90
|
+
readonly tool: string;
|
|
91
|
+
readonly argv: string[];
|
|
92
|
+
status(opts?: {
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
}): Promise<JobStatus>;
|
|
95
|
+
stream(opts?: {
|
|
96
|
+
sinceByte?: number;
|
|
97
|
+
since?: Date;
|
|
98
|
+
follow?: boolean;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
}): AsyncIterable<LogChunk>;
|
|
101
|
+
wait(): Promise<{
|
|
102
|
+
exitCode: number;
|
|
103
|
+
}>;
|
|
104
|
+
kill(signal?: NodeJS.Signals): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
export declare function registerExecutionEnvFactory(factory: ExecutionEnvFactory): void;
|
|
107
|
+
export declare function selectExecutionEnv(runtime: RuntimeConfig): ExecutionEnvFactory;
|
|
108
|
+
export declare function selectExecutionEnvFactory(type: ExecutionEnvType): ExecutionEnvFactory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type WorkflowParticipant } from "./participant.js";
|
|
2
|
+
export type WorkflowMode = "read" | "edit" | "auto" | "yolo";
|
|
3
|
+
export interface RunAgentHooks {
|
|
4
|
+
from: string;
|
|
5
|
+
strategy?: "auto" | "symlink" | "transform";
|
|
6
|
+
scope?: "project" | "user" | "merged";
|
|
7
|
+
}
|
|
8
|
+
export interface WorkflowHook {
|
|
9
|
+
participant?: string;
|
|
10
|
+
mode?: WorkflowMode;
|
|
11
|
+
prompt: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RunAgentInput {
|
|
14
|
+
agent: string;
|
|
15
|
+
prompt: string;
|
|
16
|
+
mode?: WorkflowMode;
|
|
17
|
+
cwd: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
skills?: string[];
|
|
20
|
+
hooks?: RunAgentHooks;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}
|
|
23
|
+
export type RunAgentFn = (input: RunAgentInput) => Promise<unknown>;
|
|
24
|
+
export interface HookContext {
|
|
25
|
+
cwd: string;
|
|
26
|
+
participants: Record<string, WorkflowParticipant>;
|
|
27
|
+
runAgent: RunAgentFn;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
export declare function runWorkflowHook(hook: WorkflowHook, context: HookContext): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { discoverWorkflowDocs, resolveWorkflowPath, type DiscoverDocsOptions } from "./paths.js";
|
|
2
|
+
export { archivePlan, discoverPlans, openPlanList, parsePlanReadiness } from "./plans.js";
|
|
3
|
+
export { comparePlanReadiness, formatPlanReadinessLabel } from "./plan-readiness.js";
|
|
4
|
+
export type { ArchivePlanOptions, DiscoverPlansOptions, OpenPlanListOptions, PlanReadiness, PlanRef } from "./plans.js";
|
|
5
|
+
export { normalizeParticipantConfig, selectParticipantAgent, type WorkflowParticipant } from "./participant.js";
|
|
6
|
+
export { resolveLoopAgent, type ResolveLoopAgentInput } from "./select-agent.js";
|
|
7
|
+
export { runWorkflowHook, type HookContext, type RunAgentFn, type RunAgentHooks, type RunAgentInput, type WorkflowHook, type WorkflowMode } from "./hooks.js";
|
|
8
|
+
export { runWorkflowStage, type StageContext, type WorkflowStage } from "./stage.js";
|
|
9
|
+
export { runDocumentWorkflow, type DocumentWorkflowOptions, type IterationResult, type WorkflowFileStat, type WorkflowFileSystem } from "./runner.js";
|
|
10
|
+
export { runDocumentWorkflowSequence, type DocumentWorkflowSequenceOptions } from "./sequence.js";
|
|
11
|
+
export { ensureSafeRunLogDir, makeRunLogFileName, resolveRunLogDir, slugifyPlanPath, type RunLogFileSystem, type ResolveRunLogDirOptions } from "./run-logs.js";
|
|
12
|
+
export { streamLogFile, waitForExit, wrapForLogTee, type LogStreamEnv, type LogStreamFs } from "./log-stream.js";
|
|
13
|
+
export { createPoeCommandSession, runPoeCommand, type PoeCommandSession } from "./run-poe-command.js";
|
|
14
|
+
export { createBinaryExistsDetectors, type BinaryExistsDetector, type BinaryExistsDetectorResult } from "./binary-exists.js";
|
|
15
|
+
export { applyRuntimeOverrides, resolvePoeCommandExecution, UnsupportedRuntimeCapabilityError, type RuntimeOverrideOptions } from "./poe-command-execution.js";
|
|
16
|
+
export { skillPlanConfigSection } from "./skill-config.js";
|
|
17
|
+
export * from "./execution-env.js";
|
|
18
|
+
export * from "./workspace-transfer.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FSWatcher } from "node:fs";
|
|
2
|
+
import type { LogChunk } from "./execution-env.js";
|
|
3
|
+
export interface LogStreamEnv {
|
|
4
|
+
fs?: LogStreamFs;
|
|
5
|
+
}
|
|
6
|
+
export interface LogStreamFs {
|
|
7
|
+
promises: {
|
|
8
|
+
readFile(path: string): Promise<Buffer | string>;
|
|
9
|
+
stat?(path: string): Promise<{
|
|
10
|
+
mtimeMs: number;
|
|
11
|
+
}>;
|
|
12
|
+
lstat?(path: string): Promise<{
|
|
13
|
+
isSymbolicLink(): boolean;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
watch?: (path: string, listener: () => void) => FSWatcher;
|
|
17
|
+
}
|
|
18
|
+
export declare function wrapForLogTee(argv: string[], jobId: string): string[];
|
|
19
|
+
export declare function streamLogFile(env: LogStreamEnv, jobId: string, opts: {
|
|
20
|
+
sinceByte?: number;
|
|
21
|
+
since?: Date;
|
|
22
|
+
follow?: boolean;
|
|
23
|
+
}): AsyncIterable<LogChunk>;
|
|
24
|
+
export declare function waitForExit(env: LogStreamEnv, jobId: string, opts?: {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
exitCode: number;
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WorkflowMode } from "./hooks.js";
|
|
2
|
+
export interface WorkflowParticipant {
|
|
3
|
+
id: string;
|
|
4
|
+
agent: string | string[];
|
|
5
|
+
mode?: WorkflowMode;
|
|
6
|
+
model?: string;
|
|
7
|
+
prompt?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function normalizeParticipantConfig(id: string, value: unknown): WorkflowParticipant;
|
|
10
|
+
export declare function selectParticipantAgent(participant: WorkflowParticipant, iteration: number): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function resolveWorkflowPath(inputPath: string, cwd: string, homeDir: string): string;
|
|
2
|
+
export interface DiscoverDocsOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
homeDir: string;
|
|
5
|
+
subDirectory: string;
|
|
6
|
+
glob?: string;
|
|
7
|
+
fs: {
|
|
8
|
+
lstat: (path: string) => Promise<{
|
|
9
|
+
isSymbolicLink(): boolean;
|
|
10
|
+
}>;
|
|
11
|
+
readdir: (path: string) => Promise<string[]>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function discoverWorkflowDocs(options: DiscoverDocsOptions): Promise<string[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PlanReadiness } from "./plans.js";
|
|
2
|
+
export declare function formatPlanReadinessLabel(label: string, readiness: PlanReadiness): string;
|
|
3
|
+
export declare function comparePlanReadiness(left: {
|
|
4
|
+
readiness: PlanReadiness;
|
|
5
|
+
}, right: {
|
|
6
|
+
readiness: PlanReadiness;
|
|
7
|
+
}): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type TaskList, type TaskListFs } from "../task-list/index.js";
|
|
2
|
+
export interface PlanRef {
|
|
3
|
+
id: string;
|
|
4
|
+
absolutePath: string;
|
|
5
|
+
displayPath: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
name: string;
|
|
8
|
+
readiness: PlanReadiness;
|
|
9
|
+
}
|
|
10
|
+
export type PlanReadiness = "draft" | "ready";
|
|
11
|
+
export interface DiscoverPlansOptions {
|
|
12
|
+
cwd: string;
|
|
13
|
+
homeDir: string;
|
|
14
|
+
planDirectory: string;
|
|
15
|
+
kinds?: readonly string[];
|
|
16
|
+
fs?: TaskListFs;
|
|
17
|
+
}
|
|
18
|
+
export interface ArchivePlanOptions {
|
|
19
|
+
cwd: string;
|
|
20
|
+
homeDir: string;
|
|
21
|
+
planDirectory: string;
|
|
22
|
+
id: string;
|
|
23
|
+
fs?: TaskListFs;
|
|
24
|
+
metadataPatch?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenPlanListOptions {
|
|
27
|
+
cwd: string;
|
|
28
|
+
homeDir: string;
|
|
29
|
+
planDirectory: string;
|
|
30
|
+
fs?: TaskListFs;
|
|
31
|
+
}
|
|
32
|
+
export declare function parsePlanReadiness(value: unknown): PlanReadiness;
|
|
33
|
+
export declare function discoverPlans(options: DiscoverPlansOptions): Promise<PlanRef[]>;
|
|
34
|
+
export declare const archivePlan: (options: ArchivePlanOptions) => Promise<void>;
|
|
35
|
+
export declare function openPlanList(options: OpenPlanListOptions): Promise<TaskList>;
|