@sayknow-cli/coding-agent 0.4.7 → 0.5.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/CHANGELOG.md +97 -0
- package/dist/types/capability/index.d.ts +10 -20
- package/dist/types/capability/types.d.ts +3 -0
- package/dist/types/cli/args.d.ts +0 -2
- package/dist/types/cli/read-cli.d.ts +1 -0
- package/dist/types/cli.d.ts +9 -1
- package/dist/types/commands/daemon.d.ts +2 -2
- package/dist/types/commands/deep-interview.d.ts +9 -0
- package/dist/types/commands/harness.d.ts +22 -0
- package/dist/types/commands/read.d.ts +6 -0
- package/dist/types/commands/sdk.d.ts +20 -2
- package/dist/types/config/keybindings.d.ts +34 -4
- package/dist/types/config/model-profile-contract.d.ts +40 -0
- package/dist/types/config/model-profiles.d.ts +2 -3
- package/dist/types/config/model-registry.d.ts +5 -0
- package/dist/types/config/provider-auth-health.d.ts +14 -0
- package/dist/types/config/provider-ranking.d.ts +59 -0
- package/dist/types/config/settings-schema.d.ts +156 -10
- package/dist/types/config/settings.d.ts +3 -0
- package/dist/types/edit/modes/patch.d.ts +13 -0
- package/dist/types/edit/path-mutation-lock.d.ts +15 -0
- package/dist/types/eval/py/executor.d.ts +1 -1
- package/dist/types/eval/py/runner-artifact.d.ts +8 -0
- package/dist/types/eval/py/tool-bridge.d.ts +1 -2
- package/dist/types/extensibility/extensions/types.d.ts +43 -2
- package/dist/types/extensibility/shared-events.d.ts +6 -0
- package/dist/types/internal-urls/local-root-gc.d.ts +2 -0
- package/dist/types/main.d.ts +33 -2
- package/dist/types/memories/index.d.ts +2 -0
- package/dist/types/modes/acp/acp-agent.d.ts +22 -9
- package/dist/types/modes/components/assistant-message.d.ts +3 -1
- package/dist/types/modes/components/btw-panel.d.ts +1 -0
- package/dist/types/modes/components/irc-sidebar.d.ts +41 -0
- package/dist/types/modes/components/queue-pane.d.ts +8 -0
- package/dist/types/modes/components/queued-message-selector.d.ts +6 -0
- package/dist/types/modes/components/read-tool-group.d.ts +4 -4
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +2 -1
- package/dist/types/modes/components/session-observer-overlay.d.ts +4 -0
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/components/tool-execution.d.ts +8 -0
- package/dist/types/modes/components/tool-status-header.d.ts +4 -2
- package/dist/types/modes/components/welcome.d.ts +5 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +5 -0
- package/dist/types/modes/controllers/command-controller.d.ts +2 -0
- package/dist/types/modes/controllers/event-controller.d.ts +3 -0
- package/dist/types/modes/interactive-mode.d.ts +13 -2
- package/dist/types/modes/irc-observation-ledger.d.ts +17 -1
- package/dist/types/modes/prompt-action-autocomplete.d.ts +6 -1
- package/dist/types/modes/prompt-suggestion-controller.d.ts +35 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +2 -2
- package/dist/types/modes/types.d.ts +6 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +2 -1
- package/dist/types/modes/utils/ui-helpers.d.ts +16 -0
- package/dist/types/runtime/memory-domain.d.ts +9 -0
- package/dist/types/runtime/memory-guard-contract.d.ts +71 -0
- package/dist/types/runtime/memory-guard.d.ts +39 -0
- package/dist/types/runtime/memory-limit.d.ts +11 -0
- package/dist/types/runtime-mcp/content-limits.d.ts +7 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +1 -1
- package/dist/types/runtime-mcp/manager.d.ts +9 -1
- package/dist/types/runtime-mcp/oauth-flow.d.ts +0 -5
- package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +14 -0
- package/dist/types/runtime-mcp/redaction.d.ts +2 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +5 -0
- package/dist/types/sdk/acp/final-text.d.ts +19 -0
- package/dist/types/sdk/acp/mcp.d.ts +23 -0
- package/dist/types/sdk/broker/broker.d.ts +2 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +13 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +9 -1
- package/dist/types/sdk/bus/config-commands.d.ts +2 -2
- package/dist/types/sdk/bus/config.d.ts +2 -0
- package/dist/types/sdk/bus/control-drain-lease.d.ts +52 -0
- package/dist/types/sdk/bus/conversation-store.d.ts +1 -0
- package/dist/types/sdk/bus/daemon-paths.d.ts +1 -0
- package/dist/types/sdk/bus/index.d.ts +52 -4
- package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +37 -0
- package/dist/types/sdk/bus/lifecycle-commands.d.ts +5 -4
- package/dist/types/sdk/bus/notification-orchestration.d.ts +1 -0
- package/dist/types/sdk/bus/notification-service.d.ts +34 -0
- package/dist/types/sdk/bus/operator-runtime.d.ts +1 -0
- package/dist/types/sdk/bus/prompt-reconciliation.d.ts +106 -0
- package/dist/types/sdk/bus/rate-limit-pool.d.ts +2 -0
- package/dist/types/sdk/bus/reconciliation-store.d.ts +65 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +33 -9
- package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +286 -12
- package/dist/types/sdk/bus/telegram-reference.d.ts +2 -0
- package/dist/types/sdk/bus/topic-registry.d.ts +88 -2
- package/dist/types/sdk/client/discovery.d.ts +2 -0
- package/dist/types/sdk/client/liveness.d.ts +7 -0
- package/dist/types/sdk/host/control/operations.d.ts +3 -2
- package/dist/types/sdk/host/host.d.ts +3 -1
- package/dist/types/sdk/host/query/handlers.d.ts +14 -0
- package/dist/types/sdk/index.d.ts +2 -0
- package/dist/types/sdk/lifecycle-session.d.ts +10 -1
- package/dist/types/sdk/prompt-status.d.ts +88 -0
- package/dist/types/sdk/session-directory.d.ts +1 -1
- package/dist/types/sdk/session.d.ts +7 -0
- package/dist/types/sdk/startup-capability.d.ts +9 -0
- package/dist/types/sdk/transport/auth-preface.d.ts +9 -0
- package/dist/types/sdk/transport/index.d.ts +12 -0
- package/dist/types/sdk/transport/relay.d.ts +43 -0
- package/dist/types/sdk/transport/serve-cli.d.ts +4 -0
- package/dist/types/sdk/transport/socket.d.ts +7 -0
- package/dist/types/sdk/transport/stdio.d.ts +3 -0
- package/dist/types/session/agent-session.d.ts +83 -24
- package/dist/types/session/btw-contract.d.ts +16 -0
- package/dist/types/session/fallback-chain-controller.d.ts +18 -2
- package/dist/types/session/internal/managed-session-scope.d.ts +70 -10
- package/dist/types/session/internal/managed-session-storage.d.ts +34 -12
- package/dist/types/session/internal/native-publish-outcome.d.ts +48 -0
- package/dist/types/session/memory-guard-checkpoint-participant.d.ts +69 -0
- package/dist/types/session/session-manager.d.ts +89 -18
- package/dist/types/session/session-storage.d.ts +31 -0
- package/dist/types/session/streaming-output.d.ts +60 -5
- package/dist/types/setup/credential-import.d.ts +5 -1
- package/dist/types/setup/provider-onboarding.d.ts +2 -0
- package/dist/types/skc-runtime/deep-interview-runtime.d.ts +1 -1
- package/dist/types/skc-runtime/deep-interview-stage.d.ts +37 -0
- package/dist/types/skc-runtime/gc-runtime.d.ts +1 -1
- package/dist/types/skc-runtime/linux-proc.d.ts +22 -14
- package/dist/types/skc-runtime/memory-guard-owner-claims.d.ts +47 -0
- package/dist/types/skc-runtime/ralplan-runtime.d.ts +112 -1
- package/dist/types/skc-runtime/repository-binding.d.ts +63 -0
- package/dist/types/skc-runtime/state-runtime.d.ts +3 -1
- package/dist/types/skc-runtime/state-writer.d.ts +5 -1
- package/dist/types/skc-runtime/team-launch.d.ts +1 -1
- package/dist/types/skc-runtime/team-runtime.d.ts +9 -2
- package/dist/types/skc-runtime/team-store.d.ts +12 -0
- package/dist/types/skc-runtime/team-worker-memory-guard.d.ts +92 -0
- package/dist/types/skc-runtime/tmux-owner-isolation.d.ts +7 -0
- package/dist/types/skc-runtime/ultragoal-guard.d.ts +6 -5
- package/dist/types/skc-runtime/ultragoal-receipt-freshness.d.ts +28 -0
- package/dist/types/skc-runtime/ultragoal-runtime.d.ts +43 -5
- package/dist/types/skill-state/workflow-hud.d.ts +3 -0
- package/dist/types/ssh/utils.d.ts +1 -0
- package/dist/types/task/discovery.d.ts +3 -1
- package/dist/types/task/executor.d.ts +6 -0
- package/dist/types/task/index.d.ts +3 -1
- package/dist/types/task/provider-retry-status.d.ts +13 -0
- package/dist/types/task/receipt.d.ts +2 -0
- package/dist/types/task/types.d.ts +133 -0
- package/dist/types/task/ultragoal-redteam-activation.d.ts +33 -0
- package/dist/types/tools/browser/launch.d.ts +7 -0
- package/dist/types/tools/fetch.d.ts +22 -9
- package/dist/types/tools/image-gen.d.ts +63 -1
- package/dist/types/tools/index.d.ts +7 -1
- package/dist/types/tools/output-meta.d.ts +21 -1
- package/dist/types/tools/read-internals.d.ts +12 -0
- package/dist/types/tools/read.d.ts +45 -1
- package/dist/types/tools/resource-gc.d.ts +23 -0
- package/dist/types/tools/skill-discovery.d.ts +7 -0
- package/dist/types/tools/sqlite-reader.d.ts +7 -0
- package/dist/types/tools/tool-result.d.ts +7 -1
- package/dist/types/utils/prompt-suggestion.d.ts +33 -0
- package/dist/types/utils/shell-snapshot.d.ts +12 -0
- package/dist/types/web/insane/bridge.d.ts +1 -0
- package/dist/types/web/insane/url-guard.d.ts +17 -0
- package/package.json +8 -12
- package/scripts/benchmark-sticky-viewport-pr1.ts +239 -0
- package/scripts/capture-platform-shortcut-labels-showcase.ts +342 -0
- package/scripts/capture-sticky-viewport-showcase.ts +292 -0
- package/scripts/compile-args.ts +0 -1
- package/scripts/dogfood-repository-binding.ts +209 -0
- package/scripts/generate-docs-index.ts +4 -1
- package/scripts/generate-sdk-operation-inventory.ts +9 -0
- package/scripts/run-test-manifest.ts +6 -4
- package/scripts/verify-skc-sdk-canonicalization.ts +122 -18
- package/scripts/verify-sticky-viewport-showcase.ts +611 -0
- package/src/capability/index.ts +58 -42
- package/src/capability/types.ts +3 -0
- package/src/cli/args.ts +16 -100
- package/src/cli/fast-help.ts +1 -1
- package/src/cli/mcp-cli.ts +4 -21
- package/src/cli/notify-cli.ts +6 -38
- package/src/cli/read-cli.ts +2 -1
- package/src/cli/setup-cli.ts +10 -4
- package/src/cli.ts +133 -11
- package/src/commands/daemon.ts +22 -5
- package/src/commands/deep-interview.ts +26 -1
- package/src/commands/harness.ts +35 -12
- package/src/commands/read.ts +11 -2
- package/src/commands/sdk.ts +134 -17
- package/src/commands/team.ts +1 -1
- package/src/commit/agentic/index.ts +3 -3
- package/src/commit/map-reduce/index.ts +2 -2
- package/src/config/keybindings.ts +158 -25
- package/src/config/model-profile-contract.ts +174 -0
- package/src/config/model-profiles.ts +51 -10
- package/src/config/model-registry.ts +24 -4
- package/src/config/model-resolver.ts +2 -2
- package/src/config/provider-auth-health.ts +42 -0
- package/src/config/provider-ranking.ts +119 -0
- package/src/config/settings-schema.ts +157 -10
- package/src/config/settings.ts +254 -108
- package/src/coordinator-mcp/model-preset.ts +21 -74
- package/src/defaults/skc/skills/deep-interview/SKILL.md +147 -24
- package/src/defaults/skc/skills/ralplan/SKILL.md +91 -34
- package/src/defaults/skc/skills/team/SKILL.md +1 -1
- package/src/defaults/skc/skills/ultragoal/SKILL.md +68 -17
- package/src/discovery/ssh.ts +12 -1
- package/src/edit/index.ts +3 -6
- package/src/edit/modes/patch.ts +38 -1
- package/src/edit/modes/replace.ts +42 -0
- package/src/edit/path-mutation-lock.ts +112 -0
- package/src/eval/js/tool-bridge.ts +1 -1
- package/src/eval/py/executor.ts +37 -13
- package/src/eval/py/kernel.ts +1 -21
- package/src/eval/py/prelude.py +2 -2
- package/src/eval/py/runner-artifact.ts +84 -0
- package/src/eval/py/tool-bridge.ts +34 -18
- package/src/extensibility/extensions/runner.ts +4 -0
- package/src/extensibility/extensions/types.ts +42 -4
- package/src/extensibility/plugins/marketplace/fetcher.ts +191 -7
- package/src/extensibility/shared-events.ts +5 -0
- package/src/extensibility/skc-plugins/runtime-adapters.ts +2 -1
- package/src/hooks/native-skill-hook.ts +17 -4
- package/src/internal-urls/docs-index.generated.ts +17 -16
- package/src/internal-urls/local-protocol.ts +87 -25
- package/src/internal-urls/local-root-gc.ts +127 -0
- package/src/internal-urls/mcp-protocol.ts +73 -11
- package/src/main.ts +120 -42
- package/src/memories/index.ts +10 -0
- package/src/modes/DESIGN.md +52 -0
- package/src/modes/acp/acp-agent.ts +647 -83
- package/src/modes/acp/acp-event-mapper.ts +106 -12
- package/src/modes/acp/acp-mode.ts +39 -3
- package/src/modes/action-registry.ts +1 -1
- package/src/modes/components/assistant-message.ts +123 -22
- package/src/modes/components/btw-panel.ts +82 -16
- package/src/modes/components/irc-sidebar.ts +176 -62
- package/src/modes/components/model-selector.ts +61 -4
- package/src/modes/components/notifications-settings-editor.ts +1 -1
- package/src/modes/components/oauth-selector.ts +42 -12
- package/src/modes/components/plan-preview-overlay.ts +1 -1
- package/src/modes/components/queue-pane.ts +55 -9
- package/src/modes/components/queued-message-selector.ts +53 -10
- package/src/modes/components/read-tool-group.ts +82 -14
- package/src/modes/components/runtime-mcp-add-wizard.ts +5 -0
- package/src/modes/components/sayknow-pet-widget.ts +20 -8
- package/src/modes/components/session-observer-overlay.ts +187 -32
- package/src/modes/components/settings-selector.ts +60 -18
- package/src/modes/components/tool-execution.ts +138 -27
- package/src/modes/components/tool-status-header.ts +26 -8
- package/src/modes/components/welcome.ts +50 -23
- package/src/modes/controllers/btw-controller.ts +119 -36
- package/src/modes/controllers/command-controller.ts +101 -54
- package/src/modes/controllers/event-controller.ts +119 -27
- package/src/modes/controllers/extension-ui-controller.ts +23 -12
- package/src/modes/controllers/input-controller.ts +100 -8
- package/src/modes/controllers/runtime-mcp-command-controller.ts +29 -6
- package/src/modes/controllers/selector-controller.ts +4 -1
- package/src/modes/interactive-mode.ts +201 -60
- package/src/modes/irc-observation-ledger.ts +71 -15
- package/src/modes/prompt-action-autocomplete.ts +32 -13
- package/src/modes/prompt-suggestion-controller.ts +96 -0
- package/src/modes/runtime-init.ts +20 -2
- package/src/modes/shared/agent-wire/command-dispatch.ts +3 -3
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +2 -2
- package/src/modes/types.ts +6 -0
- package/src/modes/utils/hotkeys-markdown.ts +64 -36
- package/src/modes/utils/ui-helpers.ts +99 -4
- package/src/prompts/agent-fragments/restricted-bash.md +1 -1
- package/src/prompts/agents/architect.md +17 -3
- package/src/prompts/agents/critic.md +17 -2
- package/src/prompts/agents/executor.md +1 -1
- package/src/prompts/agents/planner.md +8 -1
- package/src/prompts/system/btw-user.md +3 -8
- package/src/prompts/system/prompt-suggestion-system.md +32 -0
- package/src/prompts/system/system-prompt.md +6 -3
- package/src/prompts/tools/cron.md +3 -1
- package/src/prompts/tools/read.md +4 -2
- package/src/prompts/tools/skill-discovery.md +1 -0
- package/src/runtime/memory-domain.ts +66 -0
- package/src/runtime/memory-guard-contract.ts +73 -0
- package/src/runtime/memory-guard.ts +292 -0
- package/src/runtime/memory-limit.ts +50 -0
- package/src/runtime-mcp/client.ts +41 -55
- package/src/runtime-mcp/content-limits.ts +71 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +1 -1
- package/src/runtime-mcp/json-rpc.ts +28 -11
- package/src/runtime-mcp/manager.ts +77 -59
- package/src/runtime-mcp/oauth-flow.ts +0 -72
- package/src/runtime-mcp/plugin-network-boundary.ts +101 -0
- package/src/runtime-mcp/redaction.ts +30 -0
- package/src/runtime-mcp/smithery-auth.ts +17 -2
- package/src/runtime-mcp/smithery-connect.ts +11 -1
- package/src/runtime-mcp/transports/http.ts +63 -22
- package/src/sdk/acp/adapter.ts +8 -1
- package/src/sdk/acp/final-text.ts +40 -0
- package/src/sdk/acp/mcp.ts +26 -0
- package/src/sdk/broker/broker.ts +34 -20
- package/src/sdk/broker/identity.ts +22 -12
- package/src/sdk/broker/lifecycle.ts +293 -43
- package/src/sdk/broker/session-index.ts +11 -1
- package/src/sdk/bus/chat-daemon-cli.ts +2 -2
- package/src/sdk/bus/chat-daemon-control.ts +22 -5
- package/src/sdk/bus/config-commands.ts +2 -2
- package/src/sdk/bus/config.ts +10 -2
- package/src/sdk/bus/control-drain-lease.ts +104 -0
- package/src/sdk/bus/conversation-store.ts +40 -6
- package/src/sdk/bus/daemon-paths.ts +2 -0
- package/src/sdk/bus/index.ts +793 -121
- package/src/sdk/bus/kind-aware-reconciliation.ts +242 -0
- package/src/sdk/bus/lifecycle-commands.ts +63 -10
- package/src/sdk/bus/lifecycle-control-runtime.ts +11 -2
- package/src/sdk/bus/lifecycle-orchestrator.ts +32 -1
- package/src/sdk/bus/notification-orchestration.ts +12 -0
- package/src/sdk/bus/notification-service.ts +87 -25
- package/src/sdk/bus/operator-runtime.ts +31 -5
- package/src/sdk/bus/prompt-reconciliation.ts +240 -0
- package/src/sdk/bus/rate-limit-pool.ts +8 -0
- package/src/sdk/bus/recent-activity.ts +90 -26
- package/src/sdk/bus/reconciliation-store.ts +224 -0
- package/src/sdk/bus/telegram-cli.ts +6 -13
- package/src/sdk/bus/telegram-daemon-cli.ts +8 -3
- package/src/sdk/bus/telegram-daemon-contract.ts +34 -9
- package/src/sdk/bus/telegram-daemon-control.ts +161 -40
- package/src/sdk/bus/telegram-daemon.ts +3649 -593
- package/src/sdk/bus/telegram-reference.ts +20 -2
- package/src/sdk/bus/topic-registry.ts +451 -12
- package/src/sdk/cli/session-cli.ts +15 -2
- package/src/sdk/client/discovery.ts +19 -3
- package/src/sdk/client/liveness.ts +49 -0
- package/src/sdk/host/control/dispatch.ts +8 -2
- package/src/sdk/host/control/operations.ts +3 -2
- package/src/sdk/host/host.ts +27 -9
- package/src/sdk/host/query/handlers.ts +125 -5
- package/src/sdk/index.ts +12 -0
- package/src/sdk/lifecycle-session.ts +19 -3
- package/src/sdk/mcp/server.ts +46 -18
- package/src/sdk/prompt-status.ts +97 -0
- package/src/sdk/protocol/operation-inventory.generated.json +145 -0
- package/src/sdk/protocol/operation-registry.ts +24 -4
- package/src/sdk/session-directory.ts +5 -1
- package/src/sdk/session.ts +69 -8
- package/src/sdk/startup-capability.ts +15 -1
- package/src/sdk/transport/auth-preface.ts +82 -0
- package/src/sdk/transport/index.ts +18 -0
- package/src/sdk/transport/relay.ts +252 -0
- package/src/sdk/transport/serve-cli.ts +105 -0
- package/src/sdk/transport/socket.ts +197 -0
- package/src/sdk/transport/stdio.ts +17 -0
- package/src/session/agent-session.ts +1112 -314
- package/src/session/blob-store.ts +25 -7
- package/src/session/btw-contract.ts +59 -0
- package/src/session/fallback-chain-controller.ts +47 -8
- package/src/session/internal/managed-session-scope.ts +1426 -259
- package/src/session/internal/managed-session-storage.ts +414 -238
- package/src/session/internal/native-publish-outcome.ts +271 -0
- package/src/session/memory-guard-checkpoint-participant.ts +131 -0
- package/src/session/session-manager.ts +2079 -469
- package/src/session/session-storage.ts +151 -11
- package/src/session/streaming-output.ts +262 -43
- package/src/setup/credential-import.ts +28 -3
- package/src/setup/provider-onboarding.ts +49 -5
- package/src/setup/provider-presets.json +2 -1
- package/src/skc-runtime/deep-interview-runtime.ts +303 -36
- package/src/skc-runtime/deep-interview-stage.ts +1016 -0
- package/src/skc-runtime/deep-interview-state.ts +8 -5
- package/src/skc-runtime/gc-render.ts +1 -0
- package/src/skc-runtime/gc-runtime.ts +11 -1
- package/src/skc-runtime/linux-proc.ts +70 -36
- package/src/skc-runtime/managed-owner-supervisor.ts +83 -4
- package/src/skc-runtime/memory-guard-owner-claims.ts +389 -0
- package/src/skc-runtime/ralplan-runtime.ts +1057 -75
- package/src/skc-runtime/repository-binding.ts +267 -0
- package/src/skc-runtime/session-state-sidecar.ts +25 -9
- package/src/skc-runtime/state-runtime.ts +50 -12
- package/src/skc-runtime/state-writer.ts +68 -56
- package/src/skc-runtime/team-launch.ts +34 -5
- package/src/skc-runtime/team-runtime.ts +41 -1
- package/src/skc-runtime/team-store.ts +32 -0
- package/src/skc-runtime/team-worker-memory-guard.ts +363 -0
- package/src/skc-runtime/team-workers.ts +1 -0
- package/src/skc-runtime/tmux-common.ts +13 -2
- package/src/skc-runtime/tmux-owner-isolation.ts +20 -1
- package/src/skc-runtime/tmux-sessions.ts +45 -6
- package/src/skc-runtime/ultragoal-guard.ts +93 -15
- package/src/skc-runtime/ultragoal-receipt-freshness.ts +123 -0
- package/src/skc-runtime/ultragoal-runtime.ts +469 -38
- package/src/skc-runtime/workflow-manifest.generated.json +195 -5
- package/src/skc-runtime/workflow-manifest.ts +67 -3
- package/src/skill-state/workflow-hud.ts +25 -2
- package/src/skill-state/workflow-mutation-guard.ts +104 -12
- package/src/slash-commands/builtin-registry.ts +1 -1
- package/src/ssh/utils.ts +14 -0
- package/src/task/discovery.ts +8 -2
- package/src/task/executor.ts +165 -47
- package/src/task/index.ts +123 -15
- package/src/task/provider-retry-status.ts +88 -0
- package/src/task/receipt.ts +3 -0
- package/src/task/render.ts +45 -26
- package/src/task/skc-command.ts +2 -2
- package/src/task/types.ts +55 -10
- package/src/task/ultragoal-redteam-activation.ts +75 -0
- package/src/tools/ask.ts +1 -1
- package/src/tools/ast-edit.ts +2 -2
- package/src/tools/bash-allowed-prefixes.ts +45 -1
- package/src/tools/bash-pty-selection.ts +2 -2
- package/src/tools/browser/launch.ts +41 -6
- package/src/tools/browser/screenshot-format.ts +6 -1
- package/src/tools/cron.ts +1 -1
- package/src/tools/fetch.ts +127 -154
- package/src/tools/image-gen.ts +476 -23
- package/src/tools/index.ts +7 -1
- package/src/tools/output-meta.ts +176 -9
- package/src/tools/path-utils.ts +5 -1
- package/src/tools/read-internals.ts +44 -0
- package/src/tools/read.ts +1544 -310
- package/src/tools/resource-gc.ts +665 -125
- package/src/tools/skill-discovery.ts +39 -3
- package/src/tools/sqlite-reader.ts +63 -5
- package/src/tools/subagent-render.ts +74 -16
- package/src/tools/subagent.ts +2 -0
- package/src/tools/tool-result.ts +14 -1
- package/src/utils/edit-mode.ts +2 -2
- package/src/utils/pasted-image-path.ts +15 -6
- package/src/utils/prompt-suggestion.ts +265 -0
- package/src/utils/shell-snapshot.ts +173 -63
- package/src/utils/sixel.ts +3 -3
- package/src/web/insane/bridge.ts +5 -1
- package/src/web/insane/url-guard.ts +140 -27
- package/src/web/scrapers/docs-rs.ts +30 -5
- package/src/web/scrapers/types.ts +19 -49
- package/src/web/scrapers/utils.ts +12 -26
- package/src/web/search/providers/codex.ts +1 -1
- package/src/workflow/workflow-intent-diff.ts +4 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
export type NativePublishMutationState = "not_committed" | "committed" | "unknown";
|
|
2
|
+
export type NativePublishDurabilityState = "not_attempted" | "proven" | "not_provable";
|
|
3
|
+
export type NativePublishReason =
|
|
4
|
+
| "none"
|
|
5
|
+
| "destination_exists"
|
|
6
|
+
| "atomic_unavailable"
|
|
7
|
+
| "cross_device"
|
|
8
|
+
| "permission_denied"
|
|
9
|
+
| "io_failure"
|
|
10
|
+
| "interrupted"
|
|
11
|
+
| "invalid_request"
|
|
12
|
+
| "identity_violation"
|
|
13
|
+
| "durability_not_provable"
|
|
14
|
+
| "unknown";
|
|
15
|
+
export type NativePublishOperation = "direct_rename" | "retained_file" | "retained_tree";
|
|
16
|
+
|
|
17
|
+
export type NativePublishPrimitive =
|
|
18
|
+
| "renameat2_noreplace"
|
|
19
|
+
| "renameatx_np_excl"
|
|
20
|
+
| "windows_rename_noreplace"
|
|
21
|
+
| "unsupported"
|
|
22
|
+
| "unknown";
|
|
23
|
+
export type NativePublishPhase =
|
|
24
|
+
| "preflight"
|
|
25
|
+
| "file_sync"
|
|
26
|
+
| "rename"
|
|
27
|
+
| "source_parent_sync"
|
|
28
|
+
| "destination_parent_sync"
|
|
29
|
+
| "terminal_identity"
|
|
30
|
+
| "complete"
|
|
31
|
+
| "unknown";
|
|
32
|
+
|
|
33
|
+
type SyncFailure = {
|
|
34
|
+
phase: Exclude<NativePublishPhase, "preflight" | "file_sync" | "rename" | "complete" | "unknown">;
|
|
35
|
+
parentRole: "source" | "destination" | "shared" | "staged_file";
|
|
36
|
+
osCode?: number;
|
|
37
|
+
kind: "unsupported" | "io" | "permission" | "other";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type PublishDiagnostic = {
|
|
41
|
+
schemaVersion: 1;
|
|
42
|
+
collectionState: "complete" | "partial" | "unavailable";
|
|
43
|
+
osCode?: number;
|
|
44
|
+
syncFailures?: readonly SyncFailure[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type NativePublishIdentity = {
|
|
48
|
+
readonly dev: string;
|
|
49
|
+
readonly ino: string;
|
|
50
|
+
readonly size: string;
|
|
51
|
+
readonly mtimeNs: string;
|
|
52
|
+
readonly ctimeNs: string;
|
|
53
|
+
readonly sha256?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type NativePublishOutcome = {
|
|
57
|
+
readonly ok: boolean;
|
|
58
|
+
readonly code?: string;
|
|
59
|
+
readonly identity?: NativePublishIdentity;
|
|
60
|
+
readonly mutationState: NativePublishMutationState;
|
|
61
|
+
readonly durabilityState: NativePublishDurabilityState;
|
|
62
|
+
readonly reason: NativePublishReason;
|
|
63
|
+
readonly primitive: NativePublishPrimitive;
|
|
64
|
+
readonly phase: NativePublishPhase;
|
|
65
|
+
readonly diagnostic: PublishDiagnostic;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const mutationStates = new Set<NativePublishMutationState>(["not_committed", "committed", "unknown"]);
|
|
69
|
+
const durabilityStates = new Set<NativePublishDurabilityState>(["not_attempted", "proven", "not_provable"]);
|
|
70
|
+
const reasons = new Set<NativePublishReason>([
|
|
71
|
+
"none",
|
|
72
|
+
"destination_exists",
|
|
73
|
+
"atomic_unavailable",
|
|
74
|
+
"cross_device",
|
|
75
|
+
"permission_denied",
|
|
76
|
+
"io_failure",
|
|
77
|
+
"interrupted",
|
|
78
|
+
"invalid_request",
|
|
79
|
+
"identity_violation",
|
|
80
|
+
"durability_not_provable",
|
|
81
|
+
"unknown",
|
|
82
|
+
]);
|
|
83
|
+
const primitives = new Set<NativePublishPrimitive>([
|
|
84
|
+
"renameat2_noreplace",
|
|
85
|
+
"renameatx_np_excl",
|
|
86
|
+
"windows_rename_noreplace",
|
|
87
|
+
"unsupported",
|
|
88
|
+
"unknown",
|
|
89
|
+
]);
|
|
90
|
+
const phases = new Set<NativePublishPhase>([
|
|
91
|
+
"preflight",
|
|
92
|
+
"file_sync",
|
|
93
|
+
"rename",
|
|
94
|
+
"source_parent_sync",
|
|
95
|
+
"destination_parent_sync",
|
|
96
|
+
"terminal_identity",
|
|
97
|
+
"complete",
|
|
98
|
+
"unknown",
|
|
99
|
+
]);
|
|
100
|
+
const preMutationReasons = new Set<NativePublishReason>([
|
|
101
|
+
"destination_exists",
|
|
102
|
+
"atomic_unavailable",
|
|
103
|
+
"cross_device",
|
|
104
|
+
"permission_denied",
|
|
105
|
+
"io_failure",
|
|
106
|
+
"interrupted",
|
|
107
|
+
"invalid_request",
|
|
108
|
+
"identity_violation",
|
|
109
|
+
]);
|
|
110
|
+
const int32 = (value: unknown): value is number =>
|
|
111
|
+
typeof value === "number" && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;
|
|
112
|
+
const ownPlainRecord = (value: unknown): value is Record<string, unknown> =>
|
|
113
|
+
Boolean(value) && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
114
|
+
const exactKeys = (value: Record<string, unknown>, keys: readonly string[]) =>
|
|
115
|
+
Object.keys(value).every(key => keys.includes(key));
|
|
116
|
+
|
|
117
|
+
const malformed: NativePublishOutcome = Object.freeze({
|
|
118
|
+
ok: false,
|
|
119
|
+
mutationState: "unknown",
|
|
120
|
+
durabilityState: "not_provable",
|
|
121
|
+
reason: "unknown",
|
|
122
|
+
primitive: "unknown",
|
|
123
|
+
phase: "unknown",
|
|
124
|
+
diagnostic: Object.freeze({ schemaVersion: 1, collectionState: "unavailable" }),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
function validIdentity(value: unknown): boolean {
|
|
128
|
+
if (value === undefined) return true;
|
|
129
|
+
if (!ownPlainRecord(value) || !exactKeys(value, ["dev", "ino", "size", "mtimeNs", "ctimeNs", "sha256"]))
|
|
130
|
+
return false;
|
|
131
|
+
const decimal = (field: unknown) => typeof field === "string" && /^-?[0-9]{1,32}$/.test(field);
|
|
132
|
+
return (
|
|
133
|
+
decimal(value.dev) &&
|
|
134
|
+
decimal(value.ino) &&
|
|
135
|
+
decimal(value.size) &&
|
|
136
|
+
decimal(value.mtimeNs) &&
|
|
137
|
+
decimal(value.ctimeNs) &&
|
|
138
|
+
(value.sha256 === undefined || (typeof value.sha256 === "string" && /^[a-f0-9]{64}$/.test(value.sha256)))
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function validDiagnostic(value: unknown): value is PublishDiagnostic {
|
|
143
|
+
if (!ownPlainRecord(value) || !exactKeys(value, ["schemaVersion", "collectionState", "osCode", "syncFailures"]))
|
|
144
|
+
return false;
|
|
145
|
+
if (value.schemaVersion !== 1 || !["complete", "partial", "unavailable"].includes(value.collectionState as string))
|
|
146
|
+
return false;
|
|
147
|
+
if (value.osCode !== undefined && !int32(value.osCode)) return false;
|
|
148
|
+
if (value.syncFailures === undefined) return true;
|
|
149
|
+
if (!Array.isArray(value.syncFailures) || value.syncFailures.length > 4) return false;
|
|
150
|
+
return value.syncFailures.every(failure => {
|
|
151
|
+
if (!ownPlainRecord(failure) || !exactKeys(failure, ["phase", "parentRole", "osCode", "kind"])) return false;
|
|
152
|
+
const phase = failure.phase;
|
|
153
|
+
const role = failure.parentRole;
|
|
154
|
+
const compatibleRole =
|
|
155
|
+
(phase === "source_parent_sync" && ["source", "shared"].includes(role as string)) ||
|
|
156
|
+
(phase === "destination_parent_sync" && role === "destination") ||
|
|
157
|
+
(phase === "terminal_identity" && ["source", "destination", "shared", "staged_file"].includes(role as string));
|
|
158
|
+
return (
|
|
159
|
+
["source_parent_sync", "destination_parent_sync", "terminal_identity"].includes(phase as string) &&
|
|
160
|
+
compatibleRole &&
|
|
161
|
+
(failure.osCode === undefined || int32(failure.osCode)) &&
|
|
162
|
+
["unsupported", "io", "permission", "other"].includes(failure.kind as string)
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function legalOutcome(outcome: NativePublishOutcome): boolean {
|
|
168
|
+
if (outcome.mutationState === "not_committed")
|
|
169
|
+
return (
|
|
170
|
+
!outcome.ok &&
|
|
171
|
+
outcome.durabilityState === "not_attempted" &&
|
|
172
|
+
preMutationReasons.has(outcome.reason) &&
|
|
173
|
+
((outcome.phase === "rename" &&
|
|
174
|
+
[
|
|
175
|
+
"destination_exists",
|
|
176
|
+
"atomic_unavailable",
|
|
177
|
+
"cross_device",
|
|
178
|
+
"permission_denied",
|
|
179
|
+
"io_failure",
|
|
180
|
+
"interrupted",
|
|
181
|
+
].includes(outcome.reason)) ||
|
|
182
|
+
(outcome.phase === "preflight" &&
|
|
183
|
+
!["atomic_unavailable", "cross_device", "interrupted"].includes(outcome.reason)) ||
|
|
184
|
+
(outcome.phase === "file_sync" && outcome.reason === "io_failure"))
|
|
185
|
+
);
|
|
186
|
+
if (outcome.mutationState === "unknown")
|
|
187
|
+
return (
|
|
188
|
+
!outcome.ok &&
|
|
189
|
+
outcome.durabilityState === "not_provable" &&
|
|
190
|
+
outcome.reason === "unknown" &&
|
|
191
|
+
["rename", "terminal_identity"].includes(outcome.phase)
|
|
192
|
+
);
|
|
193
|
+
if (outcome.ok)
|
|
194
|
+
return (
|
|
195
|
+
outcome.reason === "none" &&
|
|
196
|
+
outcome.phase === "complete" &&
|
|
197
|
+
["proven", "not_attempted"].includes(outcome.durabilityState)
|
|
198
|
+
);
|
|
199
|
+
return (
|
|
200
|
+
!outcome.ok &&
|
|
201
|
+
outcome.durabilityState === "not_provable" &&
|
|
202
|
+
((outcome.reason === "durability_not_provable" &&
|
|
203
|
+
["file_sync", "source_parent_sync", "destination_parent_sync"].includes(outcome.phase)) ||
|
|
204
|
+
(outcome.reason === "identity_violation" && outcome.phase === "terminal_identity") ||
|
|
205
|
+
(outcome.reason === "io_failure" && outcome.phase === "terminal_identity"))
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Treat incompatible native results as an unknown mutation; never infer safety from legacy fields.
|
|
211
|
+
* Retained descriptor operations have a stricter contract than direct rename: a reported success
|
|
212
|
+
* includes the terminal identity and all required durability evidence.
|
|
213
|
+
*/
|
|
214
|
+
export function classifyNativePublishOutcome(
|
|
215
|
+
value: unknown,
|
|
216
|
+
operation: NativePublishOperation = "direct_rename",
|
|
217
|
+
): NativePublishOutcome {
|
|
218
|
+
if (
|
|
219
|
+
!ownPlainRecord(value) ||
|
|
220
|
+
!exactKeys(value, [
|
|
221
|
+
"ok",
|
|
222
|
+
"code",
|
|
223
|
+
"identity",
|
|
224
|
+
"mutationState",
|
|
225
|
+
"durabilityState",
|
|
226
|
+
"reason",
|
|
227
|
+
"primitive",
|
|
228
|
+
"phase",
|
|
229
|
+
"diagnostic",
|
|
230
|
+
])
|
|
231
|
+
)
|
|
232
|
+
return malformed;
|
|
233
|
+
if (
|
|
234
|
+
typeof value.ok !== "boolean" ||
|
|
235
|
+
(value.code !== undefined && (typeof value.code !== "string" || !/^[a-z0-9_]{1,64}$/.test(value.code))) ||
|
|
236
|
+
!mutationStates.has(value.mutationState as NativePublishMutationState) ||
|
|
237
|
+
!durabilityStates.has(value.durabilityState as NativePublishDurabilityState) ||
|
|
238
|
+
!reasons.has(value.reason as NativePublishReason) ||
|
|
239
|
+
!primitives.has(value.primitive as NativePublishPrimitive) ||
|
|
240
|
+
!phases.has(value.phase as NativePublishPhase) ||
|
|
241
|
+
!validIdentity(value.identity) ||
|
|
242
|
+
!validDiagnostic(value.diagnostic)
|
|
243
|
+
)
|
|
244
|
+
return malformed;
|
|
245
|
+
const outcome = value as unknown as NativePublishOutcome;
|
|
246
|
+
if (!legalOutcome(outcome)) return malformed;
|
|
247
|
+
if (operation === "direct_rename") return outcome;
|
|
248
|
+
if (
|
|
249
|
+
outcome.primitive !== "renameat2_noreplace" ||
|
|
250
|
+
(outcome.ok && (!outcome.identity || outcome.durabilityState !== "proven" || outcome.phase !== "complete"))
|
|
251
|
+
)
|
|
252
|
+
return malformed;
|
|
253
|
+
return outcome;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Only a fully validated pre-mutation result permits exact cleanup of current staging. */
|
|
257
|
+
export function mayCleanCurrentStaging(outcome: NativePublishOutcome): boolean {
|
|
258
|
+
return outcome.mutationState === "not_committed" && outcome.durabilityState === "not_attempted";
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Stable, bounded text for startup errors. Native paths and messages are intentionally excluded. */
|
|
262
|
+
export function formatNativePublishDiagnostic(outcome: NativePublishOutcome): string {
|
|
263
|
+
const osCode = outcome.diagnostic.osCode === undefined ? "" : ` os=${outcome.diagnostic.osCode}`;
|
|
264
|
+
const failures = outcome.diagnostic.syncFailures
|
|
265
|
+
?.map(
|
|
266
|
+
failure =>
|
|
267
|
+
`${failure.parentRole}:${failure.phase}:${failure.kind}${failure.osCode === undefined ? "" : `:${failure.osCode}`}`,
|
|
268
|
+
)
|
|
269
|
+
.join(",");
|
|
270
|
+
return `${outcome.reason} primitive=${outcome.primitive} phase=${outcome.phase}${osCode}${failures ? ` sync=${failures}` : ""}`;
|
|
271
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { RecoveryFsRoot } from "@sayknow-cli/natives";
|
|
4
|
+
import type {
|
|
5
|
+
RecoveryHydrationContext,
|
|
6
|
+
ResumeSessionIdentity,
|
|
7
|
+
SessionDestinationInput,
|
|
8
|
+
SessionManager,
|
|
9
|
+
SessionManagerCheckpointRevisionStrings,
|
|
10
|
+
StrictSessionOpenFailure,
|
|
11
|
+
} from "./session-manager";
|
|
12
|
+
|
|
13
|
+
export interface MemoryGuardTranscriptDescriptorV1 {
|
|
14
|
+
bytes: string;
|
|
15
|
+
relative_path: string;
|
|
16
|
+
sha256: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface MemoryGuardCheckpointBlobAuthorityV1 {
|
|
20
|
+
kind: "checkpoint_blob_tree_v1";
|
|
21
|
+
manifest_relative_path: string;
|
|
22
|
+
manifest_sha256: string;
|
|
23
|
+
root_relative_path: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface MemoryGuardCheckpointBlobManifestEntryV1 {
|
|
27
|
+
bytes: string;
|
|
28
|
+
relative_path: string;
|
|
29
|
+
sha256: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface MemoryGuardCheckpointBlobManifestV1 {
|
|
33
|
+
entries: MemoryGuardCheckpointBlobManifestEntryV1[];
|
|
34
|
+
schema_version: 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MemoryGuardSessionManagerCheckpointV1 {
|
|
38
|
+
blob_authority: MemoryGuardCheckpointBlobAuthorityV1;
|
|
39
|
+
revisions: SessionManagerCheckpointRevisionStrings;
|
|
40
|
+
schema_version: 1;
|
|
41
|
+
session_id: string;
|
|
42
|
+
session_name: string | null;
|
|
43
|
+
transcript: MemoryGuardTranscriptDescriptorV1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface MemoryGuardParticipantDescriptorV1 {
|
|
47
|
+
ordinal: number;
|
|
48
|
+
checkpoint: MemoryGuardCheckpointBlobAuthorityV1;
|
|
49
|
+
revisions: SessionManagerCheckpointRevisionStrings;
|
|
50
|
+
session_id: string;
|
|
51
|
+
session_name: string | null;
|
|
52
|
+
transcript: MemoryGuardTranscriptDescriptorV1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface MemoryGuardParticipantIngressLease {
|
|
56
|
+
readonly token: symbol;
|
|
57
|
+
release(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface MemoryGuardCreateCheckpointInput {
|
|
61
|
+
ingressLease: MemoryGuardParticipantIngressLease;
|
|
62
|
+
checkpointRoot: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type MemoryGuardRestoreBlockedReason =
|
|
66
|
+
| StrictSessionOpenFailure["reason"]
|
|
67
|
+
| "checkpoint-mismatch"
|
|
68
|
+
| "participant-mismatch"
|
|
69
|
+
| "transcript-mismatch"
|
|
70
|
+
| "blob-manifest-mismatch"
|
|
71
|
+
| "blob-missing"
|
|
72
|
+
| "blob-hash-mismatch"
|
|
73
|
+
| "blob-authority-mismatch"
|
|
74
|
+
| "destination-unavailable";
|
|
75
|
+
|
|
76
|
+
export interface MemoryGuardRestoreInput {
|
|
77
|
+
incidentAuthority: RecoveryFsRoot;
|
|
78
|
+
participant: MemoryGuardParticipantDescriptorV1;
|
|
79
|
+
checkpoint: MemoryGuardSessionManagerCheckpointV1;
|
|
80
|
+
destination: SessionDestinationInput;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type MemoryGuardRestoreResult =
|
|
84
|
+
| {
|
|
85
|
+
kind: "staged";
|
|
86
|
+
manager: SessionManager;
|
|
87
|
+
hydrationContext: RecoveryHydrationContext;
|
|
88
|
+
transcriptIdentity: ResumeSessionIdentity;
|
|
89
|
+
cleanup: () => Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
| { kind: "blocked"; reason: MemoryGuardRestoreBlockedReason };
|
|
92
|
+
|
|
93
|
+
function sortJson(value: unknown): unknown {
|
|
94
|
+
if (Array.isArray(value)) return value.map(sortJson);
|
|
95
|
+
if (value && typeof value === "object") {
|
|
96
|
+
return Object.fromEntries(
|
|
97
|
+
Object.entries(value as Record<string, unknown>)
|
|
98
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
99
|
+
.map(([key, child]) => [key, sortJson(child)]),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function memoryGuardCanonicalJson(value: unknown): string {
|
|
106
|
+
return `${JSON.stringify(sortJson(value))}\n`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function memoryGuardSha256Hex(value: Uint8Array | string): string {
|
|
110
|
+
return crypto.createHash("sha256").update(value).digest("hex");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function isMemoryGuardDecimalString(value: unknown): value is string {
|
|
114
|
+
return typeof value === "string" && /^(?:0|[1-9]\d*)$/.test(value);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function isMemoryGuardSha256Hex(value: unknown): value is string {
|
|
118
|
+
return typeof value === "string" && /^[0-9a-f]{64}$/.test(value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function isMemoryGuardRelativePath(value: unknown): value is string {
|
|
122
|
+
if (typeof value !== "string" || value.length === 0) return false;
|
|
123
|
+
if (path.isAbsolute(value) || value.includes("\\")) return false;
|
|
124
|
+
const parts = value.split("/");
|
|
125
|
+
return parts.every(part => part.length > 0 && part !== "." && part !== "..");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function hasOnlyKeys(value: Record<string, unknown>, allowed: readonly string[]): boolean {
|
|
129
|
+
const keys = Object.keys(value);
|
|
130
|
+
return keys.length === allowed.length && keys.every(key => allowed.includes(key));
|
|
131
|
+
}
|