shennian 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/publish-build-manifest.json +165 -125
- package/dist/src/agents/acp/adapter.js +2 -2
- package/dist/src/agents/acp/capability-cache.js +2 -2
- package/dist/src/agents/acp/catalog.js +2 -2
- package/dist/src/agents/acp/manifests.js +2 -2
- package/dist/src/agents/claude.js +8 -6
- package/dist/src/agents/codex.js +2 -2
- package/dist/src/agents/command-spec.js +4 -4
- package/dist/src/agents/cursor.js +1 -1
- package/dist/src/agents/custom-recovery-conformance.js +2 -2
- package/dist/src/agents/gemini.js +1 -1
- package/dist/src/agents/model-registry/discovery.js +3 -3
- package/dist/src/agents/model-registry/service.js +1 -1
- package/dist/src/agents/model-registry.js +1 -1
- package/dist/src/agents/openclaw.js +2 -2
- package/dist/src/agents/opencode.js +1 -1
- package/dist/src/agents/pi-coding-agent.js +3 -4
- package/dist/src/agents/pi-session-ownership.js +2 -2
- package/dist/src/agents/spawn-errors.js +1 -0
- package/dist/src/agents/windows-agent-paths.js +1 -0
- package/dist/src/commands/agent-readiness.js +2 -2
- package/dist/src/commands/daemon-service-spec.js +1 -1
- package/dist/src/commands/daemon.js +6 -6
- package/dist/src/commands/queue.js +1 -0
- package/dist/src/commands/room.js +3 -3
- package/dist/src/config/index.js +2 -2
- package/dist/src/fs/atomic-rename.js +1 -0
- package/dist/src/index.js +3 -3
- package/dist/src/native-fusion/claude-entry-parser.js +7 -0
- package/dist/src/native-fusion/local-repository.js +2 -2
- package/dist/src/native-fusion/native-source-deletions.js +2 -2
- package/dist/src/native-fusion/parsers.js +1 -3
- package/dist/src/native-fusion/state.js +2 -2
- package/dist/src/personal-sync/epoch.js +2 -2
- package/dist/src/personal-sync/identity.js +2 -2
- package/dist/src/relay/client.js +1 -1
- package/dist/src/room/activation-service.js +6 -6
- package/dist/src/room/attachment-cache.js +2 -2
- package/dist/src/room/host-session-observations.js +2 -2
- package/dist/src/room/managed-context.js +1 -1
- package/dist/src/room/managed-room-ipc.js +2 -2
- package/dist/src/room/mirror-sync-service.js +1 -1
- package/dist/src/room/public-attachment-cache.js +2 -2
- package/dist/src/room/room-error-guidance.js +1 -0
- package/dist/src/room/session-registry.js +2 -2
- package/dist/src/security/managed-agent-policy.js +1 -1
- package/dist/src/security/managed-agent-runtime.js +1 -1
- package/dist/src/session/attachment-transfer-store.js +2 -2
- package/dist/src/session/canonical-store.js +5 -5
- package/dist/src/session/deletion-sync-state.js +2 -2
- package/dist/src/session/handlers/agent-workspace-validation.js +1 -1
- package/dist/src/session/handlers/chat-adapter-config.js +1 -1
- package/dist/src/session/handlers/chat-events.js +2 -2
- package/dist/src/session/handlers/chat-recovery.js +1 -1
- package/dist/src/session/handlers/chat.js +1 -1
- package/dist/src/session/manager.js +1 -1
- package/dist/src/session/native-cleanup-outbox.js +2 -2
- package/dist/src/session/queue-diagnostics.js +1 -0
- package/dist/src/session/queue-dispatch-failure.js +1 -0
- package/dist/src/session/queue-helpers.js +5 -5
- package/dist/src/session/queue-retry.js +1 -1
- package/dist/src/session/queue-storage.js +2 -2
- package/dist/src/session/queue.js +1 -1
- package/dist/src/session/room-reply-notice.js +1 -0
- package/dist/src/session/run-recovery/journal.js +2 -2
- package/dist/src/session/run-stall.js +1 -0
- package/dist/src/session/store.js +2 -2
- package/dist/src/session/tool-detail-store.js +2 -2
- package/node_modules/@shennian/wire/dist/agent-capabilities.js +1 -1
- package/node_modules/@shennian/wire/dist/agent-workspace.js +1 -144
- package/node_modules/@shennian/wire/dist/envelope.js +1 -1
- package/node_modules/@shennian/wire/dist/events.js +1 -1
- package/node_modules/@shennian/wire/dist/external-message-format.js +3 -70
- package/node_modules/@shennian/wire/dist/frames.js +1 -1
- package/node_modules/@shennian/wire/dist/fs.js +2 -7
- package/node_modules/@shennian/wire/dist/index.js +1 -21
- package/node_modules/@shennian/wire/dist/machine.js +1 -1
- package/node_modules/@shennian/wire/dist/message-payload.js +8 -307
- package/node_modules/@shennian/wire/dist/methods.js +1 -3
- package/node_modules/@shennian/wire/dist/native-session.js +1 -1
- package/node_modules/@shennian/wire/dist/project-fs.js +1 -462
- package/node_modules/@shennian/wire/dist/project-path.js +1 -25
- package/node_modules/@shennian/wire/dist/project.js +1 -3
- package/node_modules/@shennian/wire/dist/relay-connectivity.js +1 -29
- package/node_modules/@shennian/wire/dist/room.js +1 -20
- package/node_modules/@shennian/wire/dist/schedule.js +1 -1
- package/node_modules/@shennian/wire/dist/session-sync.js +1 -123
- package/node_modules/@shennian/wire/dist/session.js +1 -60
- package/node_modules/@shennian/wire/dist/tool-detail.js +1 -9
- package/node_modules/@shennian/wire/dist/voice-chief.js +1 -3
- package/package.json +3 -8
- package/dist/bin/shennian.d.ts +0 -2
- package/dist/src/agent-env.d.ts +0 -44
- package/dist/src/agents/acp/adapter.d.ts +0 -82
- package/dist/src/agents/acp/auth-state.d.ts +0 -3
- package/dist/src/agents/acp/auth.d.ts +0 -7
- package/dist/src/agents/acp/capability-cache.d.ts +0 -14
- package/dist/src/agents/acp/catalog.d.ts +0 -11
- package/dist/src/agents/acp/client-services.d.ts +0 -37
- package/dist/src/agents/acp/discovery.d.ts +0 -10
- package/dist/src/agents/acp/events.d.ts +0 -4
- package/dist/src/agents/acp/manifests.d.ts +0 -63
- package/dist/src/agents/acp/metrics.d.ts +0 -24
- package/dist/src/agents/acp/package-commands.d.ts +0 -4
- package/dist/src/agents/acp/process-client.d.ts +0 -41
- package/dist/src/agents/acp/process-tree.d.ts +0 -2
- package/dist/src/agents/acp/types.d.ts +0 -31
- package/dist/src/agents/acp/watcher.d.ts +0 -22
- package/dist/src/agents/adapter.d.ts +0 -180
- package/dist/src/agents/auth-status.d.ts +0 -4
- package/dist/src/agents/claude-managed-permissions.d.ts +0 -33
- package/dist/src/agents/claude.d.ts +0 -69
- package/dist/src/agents/codex-managed-permissions.d.ts +0 -32
- package/dist/src/agents/codex-managed-room-tools.d.ts +0 -41
- package/dist/src/agents/codex-protocol.d.ts +0 -103
- package/dist/src/agents/codex-runtime.d.ts +0 -91
- package/dist/src/agents/codex-utils.d.ts +0 -29
- package/dist/src/agents/codex.d.ts +0 -59
- package/dist/src/agents/command-spec.d.ts +0 -55
- package/dist/src/agents/config-status.d.ts +0 -18
- package/dist/src/agents/cursor-managed-permissions.d.ts +0 -28
- package/dist/src/agents/cursor.d.ts +0 -44
- package/dist/src/agents/custom-managed-runtime.d.ts +0 -37
- package/dist/src/agents/custom-recovery-conformance.d.ts +0 -2
- package/dist/src/agents/custom.d.ts +0 -62
- package/dist/src/agents/detect.d.ts +0 -23
- package/dist/src/agents/event-terminal-gate.d.ts +0 -16
- package/dist/src/agents/external-channel-instructions.d.ts +0 -4
- package/dist/src/agents/gemini.d.ts +0 -32
- package/dist/src/agents/manager.d.ts +0 -57
- package/dist/src/agents/model-registry/cache.d.ts +0 -4
- package/dist/src/agents/model-registry/discovery.d.ts +0 -4
- package/dist/src/agents/model-registry/opencode-api.d.ts +0 -2
- package/dist/src/agents/model-registry/parsers.d.ts +0 -20
- package/dist/src/agents/model-registry/runner.d.ts +0 -6
- package/dist/src/agents/model-registry/service.d.ts +0 -10
- package/dist/src/agents/model-registry/types.d.ts +0 -39
- package/dist/src/agents/model-registry.d.ts +0 -17
- package/dist/src/agents/native-capabilities.d.ts +0 -10
- package/dist/src/agents/openclaw.d.ts +0 -29
- package/dist/src/agents/opencode-managed-permissions.d.ts +0 -25
- package/dist/src/agents/opencode.d.ts +0 -46
- package/dist/src/agents/pi-coding-agent-managed-permissions.d.ts +0 -7
- package/dist/src/agents/pi-coding-agent.d.ts +0 -63
- package/dist/src/agents/pi-managed-extension.d.ts +0 -12
- package/dist/src/agents/pi-managed-model-broker.d.ts +0 -27
- package/dist/src/agents/pi-managed-model-broker.js +0 -1
- package/dist/src/agents/pi-rpc-client.d.ts +0 -31
- package/dist/src/agents/pi-session-ownership.d.ts +0 -2
- package/dist/src/agents/platform-instructions.d.ts +0 -5
- package/dist/src/agents/runtime-compatibility.d.ts +0 -11
- package/dist/src/agents/workbuddy-managed-permissions.d.ts +0 -37
- package/dist/src/agents/workbuddy.d.ts +0 -63
- package/dist/src/commands/agent-readiness.d.ts +0 -17
- package/dist/src/commands/agent.d.ts +0 -2
- package/dist/src/commands/daemon-instance-lock.d.ts +0 -21
- package/dist/src/commands/daemon-process.d.ts +0 -6
- package/dist/src/commands/daemon-service-spec.d.ts +0 -26
- package/dist/src/commands/daemon-start-wait.d.ts +0 -9
- package/dist/src/commands/daemon-state.d.ts +0 -57
- package/dist/src/commands/daemon-windows.d.ts +0 -33
- package/dist/src/commands/daemon.d.ts +0 -67
- package/dist/src/commands/integration.d.ts +0 -3
- package/dist/src/commands/logout.d.ts +0 -3
- package/dist/src/commands/manager.d.ts +0 -2
- package/dist/src/commands/pair-authorization.d.ts +0 -3
- package/dist/src/commands/pair-browser.d.ts +0 -44
- package/dist/src/commands/pair-qr.d.ts +0 -4
- package/dist/src/commands/pair.d.ts +0 -19
- package/dist/src/commands/room.d.ts +0 -16
- package/dist/src/commands/runtime.d.ts +0 -2
- package/dist/src/commands/schedule.d.ts +0 -2
- package/dist/src/commands/tools.d.ts +0 -2
- package/dist/src/commands/upgrade.d.ts +0 -31
- package/dist/src/commands/worker.d.ts +0 -11
- package/dist/src/config/index.d.ts +0 -58
- package/dist/src/daemon-ipc/agent-readiness.d.ts +0 -15
- package/dist/src/daemon-ipc/client.d.ts +0 -8
- package/dist/src/daemon-ipc/control.d.ts +0 -16
- package/dist/src/daemon-ipc/json.d.ts +0 -3
- package/dist/src/daemon-ipc/paths.d.ts +0 -15
- package/dist/src/daemon-ipc/protocol.d.ts +0 -31
- package/dist/src/daemon-ipc/secret.d.ts +0 -3
- package/dist/src/daemon-ipc/server.d.ts +0 -20
- package/dist/src/daemon-log.d.ts +0 -9
- package/dist/src/env-path.d.ts +0 -15
- package/dist/src/fs/boundary.d.ts +0 -23
- package/dist/src/fs/handler.d.ts +0 -26
- package/dist/src/fs/security.d.ts +0 -2
- package/dist/src/fs/text-decoder.d.ts +0 -10
- package/dist/src/index.d.ts +0 -1
- package/dist/src/log-redaction.d.ts +0 -4
- package/dist/src/log-reporter.d.ts +0 -41
- package/dist/src/manager/prompt.d.ts +0 -2
- package/dist/src/manager/registry.d.ts +0 -184
- package/dist/src/manager/retired-external-channel-compat.d.ts +0 -78
- package/dist/src/manager/runtime.d.ts +0 -90
- package/dist/src/manager/worker-ipc.d.ts +0 -28
- package/dist/src/manager/worker-markdown.d.ts +0 -10
- package/dist/src/native-fusion/codex-files.d.ts +0 -10
- package/dist/src/native-fusion/codex-message-parser.d.ts +0 -9
- package/dist/src/native-fusion/codex-parser.d.ts +0 -8
- package/dist/src/native-fusion/codex-user-input.d.ts +0 -11
- package/dist/src/native-fusion/config.d.ts +0 -1
- package/dist/src/native-fusion/file-identity.d.ts +0 -9
- package/dist/src/native-fusion/file-watcher.d.ts +0 -26
- package/dist/src/native-fusion/local-repository.d.ts +0 -90
- package/dist/src/native-fusion/native-source-deletions.d.ts +0 -47
- package/dist/src/native-fusion/opencode-parser.d.ts +0 -29
- package/dist/src/native-fusion/parser-common.d.ts +0 -35
- package/dist/src/native-fusion/parsers.d.ts +0 -13
- package/dist/src/native-fusion/service.d.ts +0 -64
- package/dist/src/native-fusion/session-header.d.ts +0 -13
- package/dist/src/native-fusion/session-native-sources.d.ts +0 -24
- package/dist/src/native-fusion/source-visibility-audit.d.ts +0 -16
- package/dist/src/native-fusion/source-visibility.d.ts +0 -25
- package/dist/src/native-fusion/state.d.ts +0 -4
- package/dist/src/native-fusion/types.d.ts +0 -82
- package/dist/src/personal-sync/epoch.d.ts +0 -17
- package/dist/src/personal-sync/identity.d.ts +0 -1
- package/dist/src/personal-sync/machine-authority.d.ts +0 -12
- package/dist/src/personal-sync/metrics.d.ts +0 -25
- package/dist/src/personal-sync/paths.d.ts +0 -5
- package/dist/src/region.d.ts +0 -15
- package/dist/src/relay/client.d.ts +0 -81
- package/dist/src/room/activation-audit.d.ts +0 -15
- package/dist/src/room/activation-policy.d.ts +0 -8
- package/dist/src/room/activation-service.d.ts +0 -77
- package/dist/src/room/attachment-cache.d.ts +0 -44
- package/dist/src/room/attachment-upload.d.ts +0 -20
- package/dist/src/room/device-authorization-client.d.ts +0 -91
- package/dist/src/room/host-session-observations.d.ts +0 -54
- package/dist/src/room/invite-bootstrap.d.ts +0 -49
- package/dist/src/room/invite-qr.d.ts +0 -6
- package/dist/src/room/live-delivery.d.ts +0 -5
- package/dist/src/room/managed-context.d.ts +0 -49
- package/dist/src/room/managed-prompt-composer.d.ts +0 -47
- package/dist/src/room/managed-room-binding.d.ts +0 -69
- package/dist/src/room/managed-room-ipc.d.ts +0 -65
- package/dist/src/room/mirror-sync-service.d.ts +0 -49
- package/dist/src/room/public-attachment-cache.d.ts +0 -34
- package/dist/src/room/public-room-client.d.ts +0 -37
- package/dist/src/room/registration-authority.d.ts +0 -4
- package/dist/src/room/room-action-client-types.d.ts +0 -137
- package/dist/src/room/room-action-client.d.ts +0 -116
- package/dist/src/room/room-binding-client.d.ts +0 -62
- package/dist/src/room/session-registry.d.ts +0 -158
- package/dist/src/runtime-distribution.d.ts +0 -7
- package/dist/src/schedules/personal-context.d.ts +0 -2
- package/dist/src/schedules/server-client.d.ts +0 -19
- package/dist/src/security/managed-agent-credential-paths.d.ts +0 -6
- package/dist/src/security/managed-agent-executable.d.ts +0 -19
- package/dist/src/security/managed-agent-policy.d.ts +0 -66
- package/dist/src/security/managed-agent-runtime.d.ts +0 -44
- package/dist/src/session/archive-zip.d.ts +0 -10
- package/dist/src/session/attachment-reference.d.ts +0 -2
- package/dist/src/session/attachment-transfer-store.d.ts +0 -45
- package/dist/src/session/canonical-store.d.ts +0 -104
- package/dist/src/session/deletion-sync-state.d.ts +0 -20
- package/dist/src/session/deletion-sync-validation.d.ts +0 -2
- package/dist/src/session/deletion-synchronizer.d.ts +0 -9
- package/dist/src/session/handlers/agent-capabilities.d.ts +0 -3
- package/dist/src/session/handlers/agent-config.d.ts +0 -7
- package/dist/src/session/handlers/agent-control.d.ts +0 -4
- package/dist/src/session/handlers/agent-workspace-validation.d.ts +0 -28
- package/dist/src/session/handlers/agents.d.ts +0 -11
- package/dist/src/session/handlers/chat-adapter-config.d.ts +0 -11
- package/dist/src/session/handlers/chat-context.d.ts +0 -31
- package/dist/src/session/handlers/chat-events.d.ts +0 -5
- package/dist/src/session/handlers/chat-recovery.d.ts +0 -4
- package/dist/src/session/handlers/chat-session-lifecycle.d.ts +0 -9
- package/dist/src/session/handlers/chat.d.ts +0 -6
- package/dist/src/session/handlers/control.d.ts +0 -5
- package/dist/src/session/handlers/fs.d.ts +0 -14
- package/dist/src/session/handlers/message-status.d.ts +0 -3
- package/dist/src/session/handlers/pi-validation-session.d.ts +0 -7
- package/dist/src/session/handlers/pi-validation-session.js +0 -1
- package/dist/src/session/handlers/project-fs.d.ts +0 -11
- package/dist/src/session/handlers/remote-access.d.ts +0 -4
- package/dist/src/session/handlers/room-managed.d.ts +0 -6
- package/dist/src/session/handlers/session-refresh.d.ts +0 -3
- package/dist/src/session/handlers/title.d.ts +0 -3
- package/dist/src/session/handlers/tool-detail.d.ts +0 -3
- package/dist/src/session/handlers/voice-window.d.ts +0 -3
- package/dist/src/session/history-subscriptions.d.ts +0 -29
- package/dist/src/session/index-publisher.d.ts +0 -3
- package/dist/src/session/manager-event-authority.d.ts +0 -3
- package/dist/src/session/manager.d.ts +0 -95
- package/dist/src/session/native-cleanup-outbox.d.ts +0 -64
- package/dist/src/session/native-session-lifecycle.d.ts +0 -56
- package/dist/src/session/project-fs-store.d.ts +0 -43
- package/dist/src/session/projection.d.ts +0 -3
- package/dist/src/session/queue-control.d.ts +0 -27
- package/dist/src/session/queue-helpers.d.ts +0 -20
- package/dist/src/session/queue-message.d.ts +0 -35
- package/dist/src/session/queue-retry.d.ts +0 -11
- package/dist/src/session/queue-storage.d.ts +0 -8
- package/dist/src/session/queue-types.d.ts +0 -31
- package/dist/src/session/queue.d.ts +0 -73
- package/dist/src/session/queued-chat-dispatch.d.ts +0 -12
- package/dist/src/session/run-recovery/barrier.d.ts +0 -12
- package/dist/src/session/run-recovery/coordinator.d.ts +0 -32
- package/dist/src/session/run-recovery/journal.d.ts +0 -30
- package/dist/src/session/run-recovery/schema.d.ts +0 -48
- package/dist/src/session/store.d.ts +0 -128
- package/dist/src/session/tool-detail-store.d.ts +0 -17
- package/dist/src/session/turn-trigger.d.ts +0 -43
- package/dist/src/session/types.d.ts +0 -93
- package/dist/src/tools/markdown-to-pdf.d.ts +0 -42
- package/dist/src/upgrade/channel.d.ts +0 -5
- package/dist/src/upgrade/distribution.d.ts +0 -21
- package/dist/src/upgrade/engine.d.ts +0 -104
- package/dist/src/upgrade/scheduler.d.ts +0 -60
- package/dist/src/upgrade/updater-bootstrap.d.ts +0 -12
- package/dist/src/upgrade/updater-launcher.d.ts +0 -37
- package/dist/src/upgrade/updater-protocol.d.ts +0 -40
- package/dist/src/upgrade/updater-service-entry.d.ts +0 -7
- package/dist/src/upgrade/updater-worker.d.ts +0 -57
- package/dist/src/windows-shell.d.ts +0 -6
- package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts +0 -16
- package/node_modules/@shennian/wire/dist/agent-workspace.d.ts +0 -133
- package/node_modules/@shennian/wire/dist/envelope.d.ts +0 -7
- package/node_modules/@shennian/wire/dist/events.d.ts +0 -125
- package/node_modules/@shennian/wire/dist/external-message-format.d.ts +0 -37
- package/node_modules/@shennian/wire/dist/frames.d.ts +0 -33
- package/node_modules/@shennian/wire/dist/fs.d.ts +0 -107
- package/node_modules/@shennian/wire/dist/index.d.ts +0 -21
- package/node_modules/@shennian/wire/dist/machine.d.ts +0 -160
- package/node_modules/@shennian/wire/dist/message-payload.d.ts +0 -71
- package/node_modules/@shennian/wire/dist/methods.d.ts +0 -5
- package/node_modules/@shennian/wire/dist/native-session.d.ts +0 -20
- package/node_modules/@shennian/wire/dist/project-fs.d.ts +0 -146
- package/node_modules/@shennian/wire/dist/project-path.d.ts +0 -4
- package/node_modules/@shennian/wire/dist/project.d.ts +0 -16
- package/node_modules/@shennian/wire/dist/relay-connectivity.d.ts +0 -30
- package/node_modules/@shennian/wire/dist/room.d.ts +0 -190
- package/node_modules/@shennian/wire/dist/schedule.d.ts +0 -37
- package/node_modules/@shennian/wire/dist/session-sync.d.ts +0 -406
- package/node_modules/@shennian/wire/dist/session.d.ts +0 -465
- package/node_modules/@shennian/wire/dist/tool-detail.d.ts +0 -38
- package/node_modules/@shennian/wire/dist/voice-chief.d.ts +0 -116
|
@@ -1,462 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// @test src/__tests__/project-fs.test.ts
|
|
3
|
-
export const PROJECT_FS_OPAQUE_CAPABILITY = 'project_fs_opaque_v1';
|
|
4
|
-
export const PROJECT_FS_NEGOTIATION_METHOD = 'project.fs.negotiate';
|
|
5
|
-
export const PROJECT_FS_SENSITIVE_AUTHORITY_VERSION = 1;
|
|
6
|
-
export function projectFsNegotiationProofPayload(requestId, challenge) {
|
|
7
|
-
return JSON.stringify([
|
|
8
|
-
PROJECT_FS_NEGOTIATION_METHOD,
|
|
9
|
-
requestId,
|
|
10
|
-
challenge.version,
|
|
11
|
-
challenge.nonce,
|
|
12
|
-
challenge.daemonInstallationId,
|
|
13
|
-
PROJECT_FS_OPAQUE_CAPABILITY,
|
|
14
|
-
]);
|
|
15
|
-
}
|
|
16
|
-
export function parseProjectFsNegotiationChallenge(value) {
|
|
17
|
-
const input = recordWithExactKeys(value, ['version', 'nonce', 'daemonInstallationId']);
|
|
18
|
-
if (!input ||
|
|
19
|
-
input.version !== PROJECT_FS_SENSITIVE_AUTHORITY_VERSION ||
|
|
20
|
-
!isOpaqueToken(input.nonce) ||
|
|
21
|
-
typeof input.daemonInstallationId !== 'string' ||
|
|
22
|
-
input.daemonInstallationId.length < 1 ||
|
|
23
|
-
input.daemonInstallationId.length > 191)
|
|
24
|
-
return null;
|
|
25
|
-
return {
|
|
26
|
-
version: PROJECT_FS_SENSITIVE_AUTHORITY_VERSION,
|
|
27
|
-
nonce: input.nonce,
|
|
28
|
-
daemonInstallationId: input.daemonInstallationId,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export function parseProjectFsNegotiationResponse(value) {
|
|
32
|
-
const input = recordWithExactKeys(value, [
|
|
33
|
-
'version',
|
|
34
|
-
'capability',
|
|
35
|
-
'nonce',
|
|
36
|
-
'daemonInstallationId',
|
|
37
|
-
'proof',
|
|
38
|
-
]);
|
|
39
|
-
if (!input || input.capability !== PROJECT_FS_OPAQUE_CAPABILITY)
|
|
40
|
-
return null;
|
|
41
|
-
if (input.version !== PROJECT_FS_SENSITIVE_AUTHORITY_VERSION ||
|
|
42
|
-
!isOpaqueToken(input.nonce) ||
|
|
43
|
-
typeof input.daemonInstallationId !== 'string' ||
|
|
44
|
-
input.daemonInstallationId.length < 1 ||
|
|
45
|
-
input.daemonInstallationId.length > 191 ||
|
|
46
|
-
!isOpaqueToken(input.proof))
|
|
47
|
-
return null;
|
|
48
|
-
return {
|
|
49
|
-
version: PROJECT_FS_SENSITIVE_AUTHORITY_VERSION,
|
|
50
|
-
capability: PROJECT_FS_OPAQUE_CAPABILITY,
|
|
51
|
-
nonce: input.nonce,
|
|
52
|
-
daemonInstallationId: input.daemonInstallationId,
|
|
53
|
-
proof: input.proof,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export const PROJECT_FS_METHODS = [
|
|
57
|
-
'project.fs.open',
|
|
58
|
-
'project.fs.list',
|
|
59
|
-
'project.fs.read',
|
|
60
|
-
'project.fs.close',
|
|
61
|
-
];
|
|
62
|
-
export const PROJECT_FS_LIMITS = {
|
|
63
|
-
defaultDirectoryPageItems: 50,
|
|
64
|
-
maxDirectoryPageItems: 200,
|
|
65
|
-
maxReadBytes: 256 * 1024,
|
|
66
|
-
maxTokenLength: 512,
|
|
67
|
-
maxProjectRefLength: 1024,
|
|
68
|
-
maxNameLength: 255,
|
|
69
|
-
};
|
|
70
|
-
export const PROJECT_FS_ERROR_CODES = [
|
|
71
|
-
'capability_required',
|
|
72
|
-
'machine_offline',
|
|
73
|
-
'permission_denied',
|
|
74
|
-
'project_not_found',
|
|
75
|
-
'project_scope_changed',
|
|
76
|
-
'handle_invalid',
|
|
77
|
-
'handle_expired',
|
|
78
|
-
'source_changed',
|
|
79
|
-
'sensitive_path_denied',
|
|
80
|
-
'unsupported_entry',
|
|
81
|
-
'read_too_large',
|
|
82
|
-
'rate_limited',
|
|
83
|
-
'io_error',
|
|
84
|
-
];
|
|
85
|
-
export const PROJECT_FS_REQUIRED_ACTIONS = [
|
|
86
|
-
'retry',
|
|
87
|
-
'refresh_project',
|
|
88
|
-
'upgrade_daemon',
|
|
89
|
-
'reauthenticate',
|
|
90
|
-
'none',
|
|
91
|
-
];
|
|
92
|
-
/** Server-only envelope. Clients may send this key, but Server must replace it wholesale. */
|
|
93
|
-
export const PROJECT_FS_AUTHORITY_PARAM = '__projectFsAuthority';
|
|
94
|
-
export function isProjectFsMethod(value) {
|
|
95
|
-
return typeof value === 'string' && PROJECT_FS_METHODS.includes(value);
|
|
96
|
-
}
|
|
97
|
-
const OPAQUE_TOKEN_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
98
|
-
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
99
|
-
function recordWithExactKeys(value, allowedKeys) {
|
|
100
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
101
|
-
return null;
|
|
102
|
-
const record = value;
|
|
103
|
-
for (const key of Object.keys(record)) {
|
|
104
|
-
if (!allowedKeys.includes(key))
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
return record;
|
|
108
|
-
}
|
|
109
|
-
function isSafeIntegerBetween(value, min, max) {
|
|
110
|
-
return Number.isSafeInteger(value) && Number(value) >= min && Number(value) <= max;
|
|
111
|
-
}
|
|
112
|
-
function isOpaqueToken(value) {
|
|
113
|
-
return (typeof value === 'string' &&
|
|
114
|
-
value.length >= 32 &&
|
|
115
|
-
value.length <= PROJECT_FS_LIMITS.maxTokenLength &&
|
|
116
|
-
OPAQUE_TOKEN_PATTERN.test(value));
|
|
117
|
-
}
|
|
118
|
-
function isProjectRef(value) {
|
|
119
|
-
return (typeof value === 'string' &&
|
|
120
|
-
value.length >= 32 &&
|
|
121
|
-
value.length <= PROJECT_FS_LIMITS.maxProjectRefLength &&
|
|
122
|
-
OPAQUE_TOKEN_PATTERN.test(value));
|
|
123
|
-
}
|
|
124
|
-
function isDisplayName(value) {
|
|
125
|
-
return (typeof value === 'string' &&
|
|
126
|
-
value.length > 0 &&
|
|
127
|
-
value.length <= PROJECT_FS_LIMITS.maxNameLength &&
|
|
128
|
-
!/[\u0000-\u001f\u007f\\/]/.test(value) &&
|
|
129
|
-
value !== '.' &&
|
|
130
|
-
value !== '..');
|
|
131
|
-
}
|
|
132
|
-
function optionalLimit(value) {
|
|
133
|
-
return (value === undefined || isSafeIntegerBetween(value, 1, PROJECT_FS_LIMITS.maxDirectoryPageItems));
|
|
134
|
-
}
|
|
135
|
-
function parseEntry(value) {
|
|
136
|
-
const entry = recordWithExactKeys(value, ['handle', 'name', 'kind', 'size', 'modifiedAt']);
|
|
137
|
-
if (!entry || !isOpaqueToken(entry.handle) || !isDisplayName(entry.name))
|
|
138
|
-
return null;
|
|
139
|
-
if (entry.kind !== 'directory' && entry.kind !== 'file')
|
|
140
|
-
return null;
|
|
141
|
-
if (entry.size !== undefined && !isSafeIntegerBetween(entry.size, 0, Number.MAX_SAFE_INTEGER)) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
if (entry.kind === 'directory' && entry.size !== undefined)
|
|
145
|
-
return null;
|
|
146
|
-
if (entry.modifiedAt !== undefined &&
|
|
147
|
-
(!Number.isFinite(entry.modifiedAt) || Number(entry.modifiedAt) < 0)) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
handle: entry.handle,
|
|
152
|
-
name: entry.name,
|
|
153
|
-
kind: entry.kind,
|
|
154
|
-
...(entry.size === undefined ? {} : { size: Number(entry.size) }),
|
|
155
|
-
...(entry.modifiedAt === undefined ? {} : { modifiedAt: Number(entry.modifiedAt) }),
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export function parseProjectFsDirectoryPage(value) {
|
|
159
|
-
const page = recordWithExactKeys(value, ['directoryHandle', 'cursor', 'nextCursor', 'entries']);
|
|
160
|
-
if (!page || !isOpaqueToken(page.directoryHandle))
|
|
161
|
-
return null;
|
|
162
|
-
if (!isSafeIntegerBetween(page.cursor, 0, Number.MAX_SAFE_INTEGER))
|
|
163
|
-
return null;
|
|
164
|
-
if (page.nextCursor !== null &&
|
|
165
|
-
!isSafeIntegerBetween(page.nextCursor, 1, Number.MAX_SAFE_INTEGER))
|
|
166
|
-
return null;
|
|
167
|
-
if (!Array.isArray(page.entries) ||
|
|
168
|
-
page.entries.length > PROJECT_FS_LIMITS.maxDirectoryPageItems) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
const entries = [];
|
|
172
|
-
const handles = new Set();
|
|
173
|
-
for (const rawEntry of page.entries) {
|
|
174
|
-
const entry = parseEntry(rawEntry);
|
|
175
|
-
if (!entry || handles.has(entry.handle))
|
|
176
|
-
return null;
|
|
177
|
-
handles.add(entry.handle);
|
|
178
|
-
entries.push(entry);
|
|
179
|
-
}
|
|
180
|
-
const expectedNextCursor = Number(page.cursor) + entries.length;
|
|
181
|
-
if (page.nextCursor !== null && page.nextCursor !== expectedNextCursor)
|
|
182
|
-
return null;
|
|
183
|
-
if (page.nextCursor === null && entries.length === 0 && Number(page.cursor) !== 0)
|
|
184
|
-
return null;
|
|
185
|
-
return {
|
|
186
|
-
directoryHandle: page.directoryHandle,
|
|
187
|
-
cursor: Number(page.cursor),
|
|
188
|
-
nextCursor: page.nextCursor === null ? null : Number(page.nextCursor),
|
|
189
|
-
entries,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
export function parseProjectFsOpenParams(value) {
|
|
193
|
-
const params = recordWithExactKeys(value, ['projectRef', 'limit']);
|
|
194
|
-
if (!params || !isProjectRef(params.projectRef) || !optionalLimit(params.limit))
|
|
195
|
-
return null;
|
|
196
|
-
return {
|
|
197
|
-
projectRef: params.projectRef,
|
|
198
|
-
...(params.limit === undefined ? {} : { limit: Number(params.limit) }),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
export function parseProjectFsOpenResult(value) {
|
|
202
|
-
const result = recordWithExactKeys(value, ['leaseId', 'root', 'page', 'expiresAt']);
|
|
203
|
-
if (!result ||
|
|
204
|
-
!isOpaqueToken(result.leaseId) ||
|
|
205
|
-
!isSafeIntegerBetween(result.expiresAt, 1, Number.MAX_SAFE_INTEGER)) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
const root = recordWithExactKeys(result.root, ['handle', 'name', 'kind']);
|
|
209
|
-
if (!root ||
|
|
210
|
-
!isOpaqueToken(root.handle) ||
|
|
211
|
-
!isDisplayName(root.name) ||
|
|
212
|
-
root.kind !== 'directory') {
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
const page = parseProjectFsDirectoryPage(result.page);
|
|
216
|
-
if (!page || page.directoryHandle !== root.handle)
|
|
217
|
-
return null;
|
|
218
|
-
return {
|
|
219
|
-
leaseId: result.leaseId,
|
|
220
|
-
root: { handle: root.handle, name: root.name, kind: 'directory' },
|
|
221
|
-
page,
|
|
222
|
-
expiresAt: Number(result.expiresAt),
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
export function parseProjectFsListParams(value) {
|
|
226
|
-
const params = recordWithExactKeys(value, [
|
|
227
|
-
'projectRef',
|
|
228
|
-
'leaseId',
|
|
229
|
-
'directoryHandle',
|
|
230
|
-
'cursor',
|
|
231
|
-
'limit',
|
|
232
|
-
]);
|
|
233
|
-
if (!params ||
|
|
234
|
-
!isProjectRef(params.projectRef) ||
|
|
235
|
-
!isOpaqueToken(params.leaseId) ||
|
|
236
|
-
!isOpaqueToken(params.directoryHandle) ||
|
|
237
|
-
!optionalLimit(params.limit) ||
|
|
238
|
-
(params.cursor !== undefined &&
|
|
239
|
-
!isSafeIntegerBetween(params.cursor, 0, Number.MAX_SAFE_INTEGER))) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
projectRef: params.projectRef,
|
|
244
|
-
leaseId: params.leaseId,
|
|
245
|
-
directoryHandle: params.directoryHandle,
|
|
246
|
-
...(params.cursor === undefined ? {} : { cursor: Number(params.cursor) }),
|
|
247
|
-
...(params.limit === undefined ? {} : { limit: Number(params.limit) }),
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
export function parseProjectFsListResult(value) {
|
|
251
|
-
const result = recordWithExactKeys(value, [
|
|
252
|
-
'leaseId',
|
|
253
|
-
'directoryHandle',
|
|
254
|
-
'cursor',
|
|
255
|
-
'nextCursor',
|
|
256
|
-
'entries',
|
|
257
|
-
'expiresAt',
|
|
258
|
-
]);
|
|
259
|
-
if (!result ||
|
|
260
|
-
!isOpaqueToken(result.leaseId) ||
|
|
261
|
-
!isSafeIntegerBetween(result.expiresAt, 1, Number.MAX_SAFE_INTEGER))
|
|
262
|
-
return null;
|
|
263
|
-
const page = parseProjectFsDirectoryPage({
|
|
264
|
-
directoryHandle: result.directoryHandle,
|
|
265
|
-
cursor: result.cursor,
|
|
266
|
-
nextCursor: result.nextCursor,
|
|
267
|
-
entries: result.entries,
|
|
268
|
-
});
|
|
269
|
-
if (!page)
|
|
270
|
-
return null;
|
|
271
|
-
return { ...page, leaseId: result.leaseId, expiresAt: Number(result.expiresAt) };
|
|
272
|
-
}
|
|
273
|
-
export function parseProjectFsReadParams(value) {
|
|
274
|
-
const params = recordWithExactKeys(value, [
|
|
275
|
-
'projectRef',
|
|
276
|
-
'leaseId',
|
|
277
|
-
'fileHandle',
|
|
278
|
-
'offset',
|
|
279
|
-
'limitBytes',
|
|
280
|
-
'encoding',
|
|
281
|
-
]);
|
|
282
|
-
if (!params ||
|
|
283
|
-
!isProjectRef(params.projectRef) ||
|
|
284
|
-
!isOpaqueToken(params.leaseId) ||
|
|
285
|
-
!isOpaqueToken(params.fileHandle) ||
|
|
286
|
-
!isSafeIntegerBetween(params.offset, 0, Number.MAX_SAFE_INTEGER) ||
|
|
287
|
-
!isSafeIntegerBetween(params.limitBytes, 1, PROJECT_FS_LIMITS.maxReadBytes) ||
|
|
288
|
-
(params.encoding !== undefined && params.encoding !== 'binary' && params.encoding !== 'auto')) {
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
projectRef: params.projectRef,
|
|
293
|
-
leaseId: params.leaseId,
|
|
294
|
-
fileHandle: params.fileHandle,
|
|
295
|
-
offset: Number(params.offset),
|
|
296
|
-
limitBytes: Number(params.limitBytes),
|
|
297
|
-
...(params.encoding === undefined ? {} : { encoding: params.encoding }),
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function isBase64Page(value) {
|
|
301
|
-
return (typeof value === 'string' &&
|
|
302
|
-
value.length <= Math.ceil(PROJECT_FS_LIMITS.maxReadBytes / 3) * 4 &&
|
|
303
|
-
BASE64_PATTERN.test(value));
|
|
304
|
-
}
|
|
305
|
-
function base64ByteLength(value) {
|
|
306
|
-
if (!value)
|
|
307
|
-
return 0;
|
|
308
|
-
const padding = value.endsWith('==') ? 2 : value.endsWith('=') ? 1 : 0;
|
|
309
|
-
return (value.length / 4) * 3 - padding;
|
|
310
|
-
}
|
|
311
|
-
function isOptionalMetadataString(value) {
|
|
312
|
-
return (value === undefined ||
|
|
313
|
-
(typeof value === 'string' &&
|
|
314
|
-
value.length > 0 &&
|
|
315
|
-
value.length <= 255 &&
|
|
316
|
-
!/[\u0000-\u001f\u007f]/.test(value)));
|
|
317
|
-
}
|
|
318
|
-
export function parseProjectFsReadResult(value) {
|
|
319
|
-
const result = recordWithExactKeys(value, [
|
|
320
|
-
'leaseId',
|
|
321
|
-
'fileHandle',
|
|
322
|
-
'offset',
|
|
323
|
-
'bytesRead',
|
|
324
|
-
'nextOffset',
|
|
325
|
-
'totalSize',
|
|
326
|
-
'dataBase64',
|
|
327
|
-
'text',
|
|
328
|
-
'encoding',
|
|
329
|
-
'encodingFallback',
|
|
330
|
-
'mimeType',
|
|
331
|
-
'expiresAt',
|
|
332
|
-
]);
|
|
333
|
-
if (!result ||
|
|
334
|
-
!isOpaqueToken(result.leaseId) ||
|
|
335
|
-
!isOpaqueToken(result.fileHandle) ||
|
|
336
|
-
!isSafeIntegerBetween(result.offset, 0, Number.MAX_SAFE_INTEGER) ||
|
|
337
|
-
!isSafeIntegerBetween(result.bytesRead, 0, PROJECT_FS_LIMITS.maxReadBytes) ||
|
|
338
|
-
!isSafeIntegerBetween(result.totalSize, 0, Number.MAX_SAFE_INTEGER) ||
|
|
339
|
-
!isSafeIntegerBetween(result.expiresAt, 1, Number.MAX_SAFE_INTEGER))
|
|
340
|
-
return null;
|
|
341
|
-
const expectedNextOffset = Number(result.offset) + Number(result.bytesRead);
|
|
342
|
-
if (expectedNextOffset > Number(result.totalSize))
|
|
343
|
-
return null;
|
|
344
|
-
if (result.nextOffset !== null && result.nextOffset !== expectedNextOffset)
|
|
345
|
-
return null;
|
|
346
|
-
if (result.nextOffset === null && expectedNextOffset !== Number(result.totalSize))
|
|
347
|
-
return null;
|
|
348
|
-
const hasBinary = result.dataBase64 !== undefined;
|
|
349
|
-
const hasText = result.text !== undefined;
|
|
350
|
-
if (hasBinary === hasText)
|
|
351
|
-
return null;
|
|
352
|
-
if (hasBinary && !isBase64Page(result.dataBase64))
|
|
353
|
-
return null;
|
|
354
|
-
if (hasBinary && base64ByteLength(result.dataBase64) !== Number(result.bytesRead)) {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
if (hasText &&
|
|
358
|
-
(typeof result.text !== 'string' || result.text.length > PROJECT_FS_LIMITS.maxReadBytes)) {
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
if (!isOptionalMetadataString(result.encoding) || !isOptionalMetadataString(result.mimeType)) {
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
364
|
-
if (result.encodingFallback !== undefined && typeof result.encodingFallback !== 'boolean') {
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
return {
|
|
368
|
-
leaseId: result.leaseId,
|
|
369
|
-
fileHandle: result.fileHandle,
|
|
370
|
-
offset: Number(result.offset),
|
|
371
|
-
bytesRead: Number(result.bytesRead),
|
|
372
|
-
nextOffset: result.nextOffset === null ? null : Number(result.nextOffset),
|
|
373
|
-
totalSize: Number(result.totalSize),
|
|
374
|
-
...(hasBinary ? { dataBase64: result.dataBase64 } : { text: result.text }),
|
|
375
|
-
...(result.encoding === undefined ? {} : { encoding: result.encoding }),
|
|
376
|
-
...(result.encodingFallback === undefined ? {} : { encodingFallback: result.encodingFallback }),
|
|
377
|
-
...(result.mimeType === undefined ? {} : { mimeType: result.mimeType }),
|
|
378
|
-
expiresAt: Number(result.expiresAt),
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
export function parseProjectFsCloseParams(value) {
|
|
382
|
-
const params = recordWithExactKeys(value, ['projectRef', 'leaseId']);
|
|
383
|
-
if (!params || !isProjectRef(params.projectRef) || !isOpaqueToken(params.leaseId))
|
|
384
|
-
return null;
|
|
385
|
-
return { projectRef: params.projectRef, leaseId: params.leaseId };
|
|
386
|
-
}
|
|
387
|
-
export function parseProjectFsCloseResult(value) {
|
|
388
|
-
const result = recordWithExactKeys(value, ['closed']);
|
|
389
|
-
return result?.closed === true ? { closed: true } : null;
|
|
390
|
-
}
|
|
391
|
-
export function parseProjectFsRejection(value) {
|
|
392
|
-
const rejection = recordWithExactKeys(value, ['code', 'message', 'retryable', 'requiredAction']);
|
|
393
|
-
if (!rejection ||
|
|
394
|
-
!PROJECT_FS_ERROR_CODES.includes(rejection.code) ||
|
|
395
|
-
!PROJECT_FS_REQUIRED_ACTIONS.includes(rejection.requiredAction) ||
|
|
396
|
-
typeof rejection.retryable !== 'boolean' ||
|
|
397
|
-
(rejection.message !== undefined &&
|
|
398
|
-
(typeof rejection.message !== 'string' ||
|
|
399
|
-
rejection.message.length > 512 ||
|
|
400
|
-
/[\u0000-\u001f\u007f]/.test(rejection.message) ||
|
|
401
|
-
/(?:^|\s)(?:\/[A-Za-z0-9._-]|[A-Za-z]:[\\/]|\\\\)/.test(rejection.message))))
|
|
402
|
-
return null;
|
|
403
|
-
return {
|
|
404
|
-
code: rejection.code,
|
|
405
|
-
...(rejection.message === undefined ? {} : { message: rejection.message }),
|
|
406
|
-
retryable: rejection.retryable,
|
|
407
|
-
requiredAction: rejection.requiredAction,
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
/** Future clients must require this exact capability and never probe legacy path RPCs. */
|
|
411
|
-
export function hasProjectFsOpaqueCapability(capabilities) {
|
|
412
|
-
return capabilities?.includes(PROJECT_FS_OPAQUE_CAPABILITY) === true;
|
|
413
|
-
}
|
|
414
|
-
export function parseProjectFsTrustedEnvelope(value) {
|
|
415
|
-
const envelope = recordWithExactKeys(value, [
|
|
416
|
-
'version', 'requestId', 'method', 'params', 'authority', 'signature',
|
|
417
|
-
]);
|
|
418
|
-
if (!envelope || envelope.version !== 1 || typeof envelope.requestId !== 'string' ||
|
|
419
|
-
!envelope.requestId || envelope.requestId.length > 191 || !isProjectFsMethod(envelope.method) ||
|
|
420
|
-
typeof envelope.signature !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(envelope.signature))
|
|
421
|
-
return null;
|
|
422
|
-
const params = envelope.method === 'project.fs.open'
|
|
423
|
-
? parseProjectFsOpenParams(envelope.params)
|
|
424
|
-
: envelope.method === 'project.fs.list'
|
|
425
|
-
? parseProjectFsListParams(envelope.params)
|
|
426
|
-
: envelope.method === 'project.fs.read'
|
|
427
|
-
? parseProjectFsReadParams(envelope.params)
|
|
428
|
-
: parseProjectFsCloseParams(envelope.params);
|
|
429
|
-
const authority = recordWithExactKeys(envelope.authority, [
|
|
430
|
-
'projectRef', 'scopeId', 'accountScope', 'machineId', 'projectId', 'rootPath', 'rootDigest',
|
|
431
|
-
'authorizationEpoch', 'daemonInstallationId', 'generation', 'expiresAt',
|
|
432
|
-
]);
|
|
433
|
-
if (!params || !authority || authority.projectRef !== params.projectRef ||
|
|
434
|
-
!isProjectRef(authority.projectRef) || !isOpaqueToken(authority.scopeId) ||
|
|
435
|
-
!isOpaqueToken(authority.accountScope) || typeof authority.machineId !== 'string' ||
|
|
436
|
-
!authority.machineId || authority.machineId.length > 191 || typeof authority.projectId !== 'string' ||
|
|
437
|
-
!authority.projectId || authority.projectId.length > 64 || typeof authority.rootPath !== 'string' ||
|
|
438
|
-
!authority.rootPath || authority.rootPath.length > 4096 || !isOpaqueToken(authority.rootDigest) ||
|
|
439
|
-
!isSafeIntegerBetween(authority.authorizationEpoch, 0, Number.MAX_SAFE_INTEGER) ||
|
|
440
|
-
typeof authority.daemonInstallationId !== 'string' || !authority.daemonInstallationId ||
|
|
441
|
-
authority.daemonInstallationId.length > 191 || typeof authority.generation !== 'string' ||
|
|
442
|
-
!isOpaqueToken(authority.generation) ||
|
|
443
|
-
!isSafeIntegerBetween(authority.expiresAt, 1, Number.MAX_SAFE_INTEGER))
|
|
444
|
-
return null;
|
|
445
|
-
return {
|
|
446
|
-
version: 1,
|
|
447
|
-
requestId: envelope.requestId,
|
|
448
|
-
method: envelope.method,
|
|
449
|
-
params,
|
|
450
|
-
authority: authority,
|
|
451
|
-
signature: envelope.signature,
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
export function projectFsAuthoritySigningPayload(envelope) {
|
|
455
|
-
const authority = envelope.authority;
|
|
456
|
-
return JSON.stringify([
|
|
457
|
-
envelope.version, envelope.requestId, envelope.method, envelope.params,
|
|
458
|
-
authority.projectRef, authority.scopeId, authority.accountScope, authority.machineId,
|
|
459
|
-
authority.projectId, authority.rootPath, authority.rootDigest, authority.authorizationEpoch,
|
|
460
|
-
authority.daemonInstallationId, authority.generation, authority.expiresAt,
|
|
461
|
-
]);
|
|
462
|
-
}
|
|
1
|
+
const c="project_fs_opaque_v1",_="project.fs.negotiate",O=1;function C(t,e){return JSON.stringify([_,t,e.version,e.nonce,e.daemonInstallationId,c])}function H(t){const e=i(t,["version","nonce","daemonInstallationId"]);return!e||e.version!==1||!o(e.nonce)||typeof e.daemonInstallationId!="string"||e.daemonInstallationId.length<1||e.daemonInstallationId.length>191?null:{version:1,nonce:e.nonce,daemonInstallationId:e.daemonInstallationId}}function z(t){const e=i(t,["version","capability","nonce","daemonInstallationId","proof"]);return!e||e.capability!==c||e.version!==1||!o(e.nonce)||typeof e.daemonInstallationId!="string"||e.daemonInstallationId.length<1||e.daemonInstallationId.length>191||!o(e.proof)?null:{version:1,capability:c,nonce:e.nonce,daemonInstallationId:e.daemonInstallationId,proof:e.proof}}const h=["project.fs.open","project.fs.list","project.fs.read","project.fs.close"],a={defaultDirectoryPageItems:50,maxDirectoryPageItems:200,maxReadBytes:256*1024,maxTokenLength:512,maxProjectRefLength:1024,maxNameLength:255},x=["capability_required","machine_offline","permission_denied","project_not_found","project_scope_changed","handle_invalid","handle_expired","source_changed","sensitive_path_denied","unsupported_entry","read_too_large","rate_limited","io_error"],R=["retry","refresh_project","upgrade_daemon","reauthenticate","none"],B="__projectFsAuthority";function E(t){return typeof t=="string"&&h.includes(t)}const f=/^[A-Za-z0-9_-]+$/,A=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function i(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=t;for(const n of Object.keys(r))if(!e.includes(n))return null;return r}function s(t,e,r){return Number.isSafeInteger(t)&&Number(t)>=e&&Number(t)<=r}function o(t){return typeof t=="string"&&t.length>=32&&t.length<=a.maxTokenLength&&f.test(t)}function d(t){return typeof t=="string"&&t.length>=32&&t.length<=a.maxProjectRefLength&&f.test(t)}function p(t){return typeof t=="string"&&t.length>0&&t.length<=a.maxNameLength&&!/[\u0000-\u001f\u007f\\/]/.test(t)&&t!=="."&&t!==".."}function m(t){return t===void 0||s(t,1,a.maxDirectoryPageItems)}function N(t){const e=i(t,["handle","name","kind","size","modifiedAt"]);return!e||!o(e.handle)||!p(e.name)||e.kind!=="directory"&&e.kind!=="file"||e.size!==void 0&&!s(e.size,0,Number.MAX_SAFE_INTEGER)||e.kind==="directory"&&e.size!==void 0||e.modifiedAt!==void 0&&(!Number.isFinite(e.modifiedAt)||Number(e.modifiedAt)<0)?null:{handle:e.handle,name:e.name,kind:e.kind,...e.size===void 0?{}:{size:Number(e.size)},...e.modifiedAt===void 0?{}:{modifiedAt:Number(e.modifiedAt)}}}function I(t){const e=i(t,["directoryHandle","cursor","nextCursor","entries"]);if(!e||!o(e.directoryHandle)||!s(e.cursor,0,Number.MAX_SAFE_INTEGER)||e.nextCursor!==null&&!s(e.nextCursor,1,Number.MAX_SAFE_INTEGER)||!Array.isArray(e.entries)||e.entries.length>a.maxDirectoryPageItems)return null;const r=[],n=new Set;for(const y of e.entries){const l=N(y);if(!l||n.has(l.handle))return null;n.add(l.handle),r.push(l)}const u=Number(e.cursor)+r.length;return e.nextCursor!==null&&e.nextCursor!==u||e.nextCursor===null&&r.length===0&&Number(e.cursor)!==0?null:{directoryHandle:e.directoryHandle,cursor:Number(e.cursor),nextCursor:e.nextCursor===null?null:Number(e.nextCursor),entries:r}}function b(t){const e=i(t,["projectRef","limit"]);return!e||!d(e.projectRef)||!m(e.limit)?null:{projectRef:e.projectRef,...e.limit===void 0?{}:{limit:Number(e.limit)}}}function k(t){const e=i(t,["leaseId","root","page","expiresAt"]);if(!e||!o(e.leaseId)||!s(e.expiresAt,1,Number.MAX_SAFE_INTEGER))return null;const r=i(e.root,["handle","name","kind"]);if(!r||!o(r.handle)||!p(r.name)||r.kind!=="directory")return null;const n=I(e.page);return!n||n.directoryHandle!==r.handle?null:{leaseId:e.leaseId,root:{handle:r.handle,name:r.name,kind:"directory"},page:n,expiresAt:Number(e.expiresAt)}}function j(t){const e=i(t,["projectRef","leaseId","directoryHandle","cursor","limit"]);return!e||!d(e.projectRef)||!o(e.leaseId)||!o(e.directoryHandle)||!m(e.limit)||e.cursor!==void 0&&!s(e.cursor,0,Number.MAX_SAFE_INTEGER)?null:{projectRef:e.projectRef,leaseId:e.leaseId,directoryHandle:e.directoryHandle,...e.cursor===void 0?{}:{cursor:Number(e.cursor)},...e.limit===void 0?{}:{limit:Number(e.limit)}}}function M(t){const e=i(t,["leaseId","directoryHandle","cursor","nextCursor","entries","expiresAt"]);if(!e||!o(e.leaseId)||!s(e.expiresAt,1,Number.MAX_SAFE_INTEGER))return null;const r=I({directoryHandle:e.directoryHandle,cursor:e.cursor,nextCursor:e.nextCursor,entries:e.entries});return r?{...r,leaseId:e.leaseId,expiresAt:Number(e.expiresAt)}:null}function T(t){const e=i(t,["projectRef","leaseId","fileHandle","offset","limitBytes","encoding"]);return!e||!d(e.projectRef)||!o(e.leaseId)||!o(e.fileHandle)||!s(e.offset,0,Number.MAX_SAFE_INTEGER)||!s(e.limitBytes,1,a.maxReadBytes)||e.encoding!==void 0&&e.encoding!=="binary"&&e.encoding!=="auto"?null:{projectRef:e.projectRef,leaseId:e.leaseId,fileHandle:e.fileHandle,offset:Number(e.offset),limitBytes:Number(e.limitBytes),...e.encoding===void 0?{}:{encoding:e.encoding}}}function S(t){return typeof t=="string"&&t.length<=Math.ceil(a.maxReadBytes/3)*4&&A.test(t)}function P(t){if(!t)return 0;const e=t.endsWith("==")?2:t.endsWith("=")?1:0;return t.length/4*3-e}function g(t){return t===void 0||typeof t=="string"&&t.length>0&&t.length<=255&&!/[\u0000-\u001f\u007f]/.test(t)}function q(t){const e=i(t,["leaseId","fileHandle","offset","bytesRead","nextOffset","totalSize","dataBase64","text","encoding","encodingFallback","mimeType","expiresAt"]);if(!e||!o(e.leaseId)||!o(e.fileHandle)||!s(e.offset,0,Number.MAX_SAFE_INTEGER)||!s(e.bytesRead,0,a.maxReadBytes)||!s(e.totalSize,0,Number.MAX_SAFE_INTEGER)||!s(e.expiresAt,1,Number.MAX_SAFE_INTEGER))return null;const r=Number(e.offset)+Number(e.bytesRead);if(r>Number(e.totalSize)||e.nextOffset!==null&&e.nextOffset!==r||e.nextOffset===null&&r!==Number(e.totalSize))return null;const n=e.dataBase64!==void 0,u=e.text!==void 0;return n===u||n&&!S(e.dataBase64)||n&&P(e.dataBase64)!==Number(e.bytesRead)||u&&(typeof e.text!="string"||e.text.length>a.maxReadBytes)||!g(e.encoding)||!g(e.mimeType)||e.encodingFallback!==void 0&&typeof e.encodingFallback!="boolean"?null:{leaseId:e.leaseId,fileHandle:e.fileHandle,offset:Number(e.offset),bytesRead:Number(e.bytesRead),nextOffset:e.nextOffset===null?null:Number(e.nextOffset),totalSize:Number(e.totalSize),...n?{dataBase64:e.dataBase64}:{text:e.text},...e.encoding===void 0?{}:{encoding:e.encoding},...e.encodingFallback===void 0?{}:{encodingFallback:e.encodingFallback},...e.mimeType===void 0?{}:{mimeType:e.mimeType},expiresAt:Number(e.expiresAt)}}function F(t){const e=i(t,["projectRef","leaseId"]);return!e||!d(e.projectRef)||!o(e.leaseId)?null:{projectRef:e.projectRef,leaseId:e.leaseId}}function J(t){return i(t,["closed"])?.closed===!0?{closed:!0}:null}function D(t){const e=i(t,["code","message","retryable","requiredAction"]);return!e||!x.includes(e.code)||!R.includes(e.requiredAction)||typeof e.retryable!="boolean"||e.message!==void 0&&(typeof e.message!="string"||e.message.length>512||/[\u0000-\u001f\u007f]/.test(e.message)||/(?:^|\s)(?:\/[A-Za-z0-9._-]|[A-Za-z]:[\\/]|\\\\)/.test(e.message))?null:{code:e.code,...e.message===void 0?{}:{message:e.message},retryable:e.retryable,requiredAction:e.requiredAction}}function G(t){return t?.includes(c)===!0}function L(t){const e=i(t,["version","requestId","method","params","authority","signature"]);if(!e||e.version!==1||typeof e.requestId!="string"||!e.requestId||e.requestId.length>191||!E(e.method)||typeof e.signature!="string"||!/^[A-Za-z0-9_-]{43}$/.test(e.signature))return null;const r=e.method==="project.fs.open"?b(e.params):e.method==="project.fs.list"?j(e.params):e.method==="project.fs.read"?T(e.params):F(e.params),n=i(e.authority,["projectRef","scopeId","accountScope","machineId","projectId","rootPath","rootDigest","authorizationEpoch","daemonInstallationId","generation","expiresAt"]);return!r||!n||n.projectRef!==r.projectRef||!d(n.projectRef)||!o(n.scopeId)||!o(n.accountScope)||typeof n.machineId!="string"||!n.machineId||n.machineId.length>191||typeof n.projectId!="string"||!n.projectId||n.projectId.length>64||typeof n.rootPath!="string"||!n.rootPath||n.rootPath.length>4096||!o(n.rootDigest)||!s(n.authorizationEpoch,0,Number.MAX_SAFE_INTEGER)||typeof n.daemonInstallationId!="string"||!n.daemonInstallationId||n.daemonInstallationId.length>191||typeof n.generation!="string"||!o(n.generation)||!s(n.expiresAt,1,Number.MAX_SAFE_INTEGER)?null:{version:1,requestId:e.requestId,method:e.method,params:r,authority:n,signature:e.signature}}function X(t){const e=t.authority;return JSON.stringify([t.version,t.requestId,t.method,t.params,e.projectRef,e.scopeId,e.accountScope,e.machineId,e.projectId,e.rootPath,e.rootDigest,e.authorizationEpoch,e.daemonInstallationId,e.generation,e.expiresAt])}export{B as PROJECT_FS_AUTHORITY_PARAM,x as PROJECT_FS_ERROR_CODES,a as PROJECT_FS_LIMITS,h as PROJECT_FS_METHODS,_ as PROJECT_FS_NEGOTIATION_METHOD,c as PROJECT_FS_OPAQUE_CAPABILITY,R as PROJECT_FS_REQUIRED_ACTIONS,O as PROJECT_FS_SENSITIVE_AUTHORITY_VERSION,G as hasProjectFsOpaqueCapability,E as isProjectFsMethod,F as parseProjectFsCloseParams,J as parseProjectFsCloseResult,I as parseProjectFsDirectoryPage,j as parseProjectFsListParams,M as parseProjectFsListResult,H as parseProjectFsNegotiationChallenge,z as parseProjectFsNegotiationResponse,b as parseProjectFsOpenParams,k as parseProjectFsOpenResult,T as parseProjectFsReadParams,q as parseProjectFsReadResult,D as parseProjectFsRejection,L as parseProjectFsTrustedEnvelope,X as projectFsAuthoritySigningPayload,C as projectFsNegotiationProofPayload};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// @test src/__tests__/project-path.test.ts
|
|
3
|
-
/** Matching only: never changes persisted project IDs or directory spelling. */
|
|
4
|
-
export function normalizeProjectMatchPath(workDir) {
|
|
5
|
-
const trimmed = workDir.trim();
|
|
6
|
-
const windows = /^[a-z]:[\\/]/i.test(trimmed) || /^\\\\/.test(trimmed) || /^\/\//.test(trimmed);
|
|
7
|
-
const path = windows ? trimmed.replace(/\\/g, '/') : trimmed;
|
|
8
|
-
return path === '/' || path === '~' ? path : path.replace(/[\\/]+$/, '');
|
|
9
|
-
}
|
|
10
|
-
/** Include both existing Windows spellings in one paginated database query. */
|
|
11
|
-
export function projectSessionPathCandidates(workDir) {
|
|
12
|
-
const path = normalizeProjectMatchPath(workDir);
|
|
13
|
-
if (path === '/' || path === '~')
|
|
14
|
-
return [path];
|
|
15
|
-
const paths = /^[a-z]:(?:\/|$)/i.test(path) || path.startsWith('//')
|
|
16
|
-
? [path, path.replace(/\//g, '\\')]
|
|
17
|
-
: [path];
|
|
18
|
-
const candidates = new Set();
|
|
19
|
-
for (const value of paths) {
|
|
20
|
-
candidates.add(value);
|
|
21
|
-
candidates.add(`${value}/`);
|
|
22
|
-
candidates.add(`${value}\\`);
|
|
23
|
-
}
|
|
24
|
-
return [...candidates];
|
|
25
|
-
}
|
|
1
|
+
function o(a){const t=a.trim(),e=/^[a-z]:[\\/]/i.test(t)||/^\\\\/.test(t)||/^\/\//.test(t)?t.replace(/\\/g,"/"):t;return e==="/"||e==="~"?e:e.replace(/[\\/]+$/,"")}function r(a){const t=o(a);if(t==="/"||t==="~")return[t];const s=/^[a-z]:(?:\/|$)/i.test(t)||t.startsWith("//")?[t,t.replace(/\//g,"\\")]:[t],e=new Set;for(const n of s)e.add(n),e.add(`${n}/`),e.add(`${n}\\`);return[...e]}export{o as normalizeProjectMatchPath,r as projectSessionPathCandidates};
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// @test packages/shared/src/__tests__/relay.test.ts
|
|
3
|
-
/**
|
|
4
|
-
* The server owns close-code meaning. Keeping this map in Wire prevents App,
|
|
5
|
-
* Shared and Server from drifting into different user-facing explanations.
|
|
6
|
-
*/
|
|
7
|
-
export function classifyRelayClose(code, closeReason = '') {
|
|
8
|
-
if (code === 4001 || code === 4009)
|
|
9
|
-
return { reason: 'auth_required', retryable: false };
|
|
10
|
-
if (code === 4003 || code === 4403 || code === 4411) {
|
|
11
|
-
return { reason: 'permission_revoked', retryable: false };
|
|
12
|
-
}
|
|
13
|
-
if (code === 4402)
|
|
14
|
-
return { reason: 'plan_required', retryable: false };
|
|
15
|
-
if (code === 4406)
|
|
16
|
-
return { reason: 'version_unsupported', retryable: false };
|
|
17
|
-
if (code === 4004)
|
|
18
|
-
return { reason: 'machine_unavailable', retryable: true };
|
|
19
|
-
if (code === 4008 || code === 1012 || code === 1013) {
|
|
20
|
-
return { reason: 'server_unavailable', retryable: true };
|
|
21
|
-
}
|
|
22
|
-
if (code === 0 || code === 1006 || code === 1011) {
|
|
23
|
-
return { reason: 'transient_transport', retryable: true };
|
|
24
|
-
}
|
|
25
|
-
if (/upgrade|required|protocol|epoch|capabilit/i.test(closeReason)) {
|
|
26
|
-
return { reason: 'version_unsupported', retryable: false };
|
|
27
|
-
}
|
|
28
|
-
return { reason: 'unknown', retryable: true };
|
|
29
|
-
}
|
|
1
|
+
function a(r,e=""){return r===4001||r===4009?{reason:"auth_required",retryable:!1}:r===4003||r===4403||r===4411?{reason:"permission_revoked",retryable:!1}:r===4402?{reason:"plan_required",retryable:!1}:r===4406?{reason:"version_unsupported",retryable:!1}:r===4004?{reason:"machine_unavailable",retryable:!0}:r===4008||r===1012||r===1013?{reason:"server_unavailable",retryable:!0}:r===0||r===1006||r===1011?{reason:"transient_transport",retryable:!0}:/upgrade|required|protocol|epoch|capabilit/i.test(e)?{reason:"version_unsupported",retryable:!1}:{reason:"unknown",retryable:!0}}export{a as classifyRelayClose};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// @test src/__tests__/room.test.ts
|
|
3
|
-
import { isAvailableAgentType } from "./session.js";
|
|
4
|
-
export function roomRuntimeAgentType(value) {
|
|
5
|
-
if (value === 'claude_code')
|
|
6
|
-
return 'claude';
|
|
7
|
-
if (!isAvailableAgentType(value) ||
|
|
8
|
-
value === 'manager' ||
|
|
9
|
-
value === 'pi' ||
|
|
10
|
-
value === 'openclaw') {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
export function isRoomRuntimeAdapter(value) {
|
|
16
|
-
return roomRuntimeAgentType(value) !== null;
|
|
17
|
-
}
|
|
18
|
-
export function roomRuntimeAdapterForAgent(agentType) {
|
|
19
|
-
return roomRuntimeAgentType(agentType) ? agentType : null;
|
|
20
|
-
}
|
|
1
|
+
import{isAvailableAgentType as t}from"./session.js";function r(n){return n==="claude_code"?"claude":!t(n)||n==="manager"||n==="pi"||n==="openclaw"?null:n}function o(n){return r(n)!==null}function i(n){return r(n)?n:null}export{o as isRoomRuntimeAdapter,i as roomRuntimeAdapterForAgent,r as roomRuntimeAgentType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|