@orion-agents/orion-code 0.3.66 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +78 -361
- package/README.zh-CN.md +71 -262
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +34 -0
- package/dist/acp/session-updates.js +162 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +315 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +5 -1
- package/dist/commands/diagnostic-command-handlers.js +20 -6
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +0 -18
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/framework/loop-budget-contract.d.ts +7 -2
- package/dist/framework/loop-budget-contract.js +4 -1
- package/dist/framework/loop-progress.d.ts +22 -0
- package/dist/framework/loop-progress.js +79 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +27 -20
- package/dist/framework/query.js +453 -153
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +31 -12
- package/dist/harness/context-harness.js +491 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +6 -11
- package/dist/harness/ledger.js +39 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +66 -21
- package/dist/harness/state.js +9 -1
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +95 -0
- package/dist/harness/types.d.ts +73 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +38 -0
- package/dist/print-ui/event-stream.js +187 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +11 -2
- package/dist/runtime/agent-loop.js +165 -25
- package/dist/runtime/agent-runtime-controller.d.ts +13 -3
- package/dist/runtime/agent-runtime-controller.js +347 -183
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +11 -1
- package/dist/runtime/goal-lifecycle-v2.js +85 -15
- package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
- package/dist/runtime/goal-runtime-coordinator.js +81 -24
- package/dist/runtime/loop-budget.js +7 -5
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +135 -39
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +128 -52
- package/dist/runtime/release-receipts.d.ts +24 -133
- package/dist/runtime/release-receipts.js +129 -693
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +351 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +1 -0
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -1
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +342 -0
- package/dist/runtime/task-context-service.d.ts +16 -10
- package/dist/runtime/task-context-service.js +35 -4
- package/dist/runtime/thread-admission.d.ts +1 -1
- package/dist/runtime/thread-admission.js +12 -6
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +7 -0
- package/dist/runtime/thread-runtime.js +43 -0
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +88 -11
- package/dist/runtime/tool-gateway.d.ts +7 -0
- package/dist/runtime/tool-gateway.js +20 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +12 -0
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +33 -19
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +30 -45
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -56
- package/dist/services/global-config.js +213 -183
- package/dist/services/llm.d.ts +40 -4
- package/dist/services/llm.js +164 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +7 -0
- package/dist/services/provider-diagnostics.js +9 -10
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +2 -0
- package/dist/tools/core/write-file.js +5 -0
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +76 -31
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +22 -27
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +562 -0
- package/docs/orion.example.yaml +42 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
- package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
- package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-CABdwh4l.css +0 -1
- package/dist/web-client/assets/index-KvshfEbl.js +0 -20
- package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export type GitVersionLabelV1 = 'base' | 'ours' | 'theirs' | 'worktree' | 'revision';
|
|
2
|
-
export interface GitFileVersionV1 {
|
|
3
|
-
readonly label: GitVersionLabelV1;
|
|
4
|
-
/** The blob OID, or null when this version does not exist for this conflict shape. */
|
|
5
|
-
readonly oid: string | null;
|
|
6
|
-
readonly exists: boolean;
|
|
7
|
-
readonly binary: boolean;
|
|
8
|
-
readonly byteSize: number;
|
|
9
|
-
readonly truncated: boolean;
|
|
10
|
-
/** Text content, or null when absent, binary or over the limit. */
|
|
11
|
-
readonly content: string | null;
|
|
12
|
-
/**
|
|
13
|
-
* Set when the content is an LFS pointer: the pointer is shown as state, and the object is
|
|
14
|
-
* never fetched.
|
|
15
|
-
*/
|
|
16
|
-
readonly lfs: {
|
|
17
|
-
readonly oid: string;
|
|
18
|
-
readonly size: number | null;
|
|
19
|
-
} | null;
|
|
20
|
-
/**
|
|
21
|
-
* v0.3.17 S6 — a renderable data URL when this version is a bounded, known image.
|
|
22
|
-
* Built from bytes already read locally; the plan forbids fetching anything.
|
|
23
|
-
*/
|
|
24
|
-
readonly dataUrl?: string | null;
|
|
25
|
-
}
|
|
26
|
-
export type GitConflictShapeV1 = 'both-modified' | 'both-added' | 'added-by-us' | 'added-by-them' | 'deleted-by-us' | 'deleted-by-them' | 'both-deleted' | 'other';
|
|
27
|
-
export interface GitConflictVersionsV1 {
|
|
28
|
-
readonly path: string;
|
|
29
|
-
readonly shape: GitConflictShapeV1;
|
|
30
|
-
readonly base: GitFileVersionV1;
|
|
31
|
-
readonly ours: GitFileVersionV1;
|
|
32
|
-
readonly theirs: GitFileVersionV1;
|
|
33
|
-
readonly worktree: GitFileVersionV1;
|
|
34
|
-
}
|
|
35
|
-
export interface GitBlobResultV1 {
|
|
36
|
-
readonly path: string;
|
|
37
|
-
readonly rev: string;
|
|
38
|
-
readonly oid: string;
|
|
39
|
-
readonly binary: boolean;
|
|
40
|
-
readonly byteSize: number;
|
|
41
|
-
readonly truncated: boolean;
|
|
42
|
-
readonly content: readonly string[];
|
|
43
|
-
readonly lfs: {
|
|
44
|
-
readonly oid: string;
|
|
45
|
-
readonly size: number | null;
|
|
46
|
-
} | null;
|
|
47
|
-
/** Present only when the blob is a bounded, known image. */
|
|
48
|
-
readonly dataUrl: string | null;
|
|
49
|
-
}
|
|
50
|
-
export interface GitSubmoduleEntryV1 {
|
|
51
|
-
readonly path: string;
|
|
52
|
-
readonly gitlinkOid: string;
|
|
53
|
-
/** Never inspected: plan G6 forbids traversing submodules to compute this. */
|
|
54
|
-
readonly dirtySummary: null;
|
|
55
|
-
readonly dirtyNote: string;
|
|
56
|
-
}
|
|
57
|
-
export interface GitVersionReader {
|
|
58
|
-
conflict(path: string): Promise<GitConflictVersionsV1>;
|
|
59
|
-
blob(input: {
|
|
60
|
-
readonly path: string;
|
|
61
|
-
readonly rev: string;
|
|
62
|
-
}): Promise<GitBlobResultV1>;
|
|
63
|
-
submodules(): Promise<readonly GitSubmoduleEntryV1[]>;
|
|
64
|
-
}
|
|
65
|
-
export interface GitVersionReaderOptions {
|
|
66
|
-
readonly runGit: (args: readonly string[]) => Promise<string>;
|
|
67
|
-
/** Runs git and returns raw bytes, for content that may not be valid UTF-8. */
|
|
68
|
-
readonly runGitBytes: (args: readonly string[]) => Promise<Buffer>;
|
|
69
|
-
/**
|
|
70
|
-
* v0.3.25 #269 — reads one working-tree file relative to the repository root,
|
|
71
|
-
* returning null when it does not exist or cannot be read safely. The
|
|
72
|
-
* `worktree` conflict version must come from the filesystem: `hash-object`
|
|
73
|
-
* without `-w` computes an OID that is not in the object database, so any
|
|
74
|
-
* edited working file made `cat-file` fail the whole conflict response.
|
|
75
|
-
*/
|
|
76
|
-
readonly readWorktreeFile?: (relativePath: string) => Promise<Buffer | null>;
|
|
77
|
-
}
|
|
78
|
-
export declare function createGitVersionReader(options: GitVersionReaderOptions): GitVersionReader;
|
|
79
|
-
//# sourceMappingURL=git-version-service.d.ts.map
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGitVersionReader = createGitVersionReader;
|
|
4
|
-
/**
|
|
5
|
-
* v0.3.17 S5 — historical file versions: conflict stages, arbitrary-revision blobs, LFS
|
|
6
|
-
* pointer state and gitlink (submodule) entries.
|
|
7
|
-
*
|
|
8
|
-
* Plan G5/G6 constraints this module is responsible for:
|
|
9
|
-
* - a conflicted file must NOT be rendered as an ordinary staged diff: base / ours / theirs
|
|
10
|
-
* come from index stages 1/2/3, and a version that legitimately does not exist (add/add,
|
|
11
|
-
* modify/delete) is reported as absent rather than silently omitted;
|
|
12
|
-
* - a file that no longer exists in the working tree can still be read at a revision
|
|
13
|
-
* ("view that version");
|
|
14
|
-
* - LFS only reads local objects or reports pointer state — nothing is fetched;
|
|
15
|
-
* - submodules are never traversed or switched: only the recorded gitlink SHAs are read, and
|
|
16
|
-
* the dirty summary is explicitly reported as not inspected.
|
|
17
|
-
*/
|
|
18
|
-
const redaction_1 = require("../services/redaction");
|
|
19
|
-
const errors_1 = require("./errors");
|
|
20
|
-
/** Upper bound on the bytes returned for one file version. */
|
|
21
|
-
const MAX_VERSION_BYTES = 256 * 1024;
|
|
22
|
-
/** Bytes inspected when deciding whether a file is an LFS pointer. */
|
|
23
|
-
const LFS_PROBE_BYTES = 512;
|
|
24
|
-
function assertRelativePath(value, name = 'path') {
|
|
25
|
-
if (typeof value !== 'string' || !value || value.length > 1024) {
|
|
26
|
-
throw new errors_1.WebWorkbenchError(400, `A ${name} is required.`, 'git_path_invalid');
|
|
27
|
-
}
|
|
28
|
-
if (value.startsWith('/') || value.startsWith(':') || value.includes('\0')) {
|
|
29
|
-
throw new errors_1.WebWorkbenchError(400, 'Unsafe Git path.', 'git_path_unsafe');
|
|
30
|
-
}
|
|
31
|
-
if (value.split('/').some(segment => segment === '..' || segment === '.' || segment === '')) {
|
|
32
|
-
throw new errors_1.WebWorkbenchError(400, 'Unsafe Git path.', 'git_path_unsafe');
|
|
33
|
-
}
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
function assertRev(value) {
|
|
37
|
-
// A revision expression here would be an injection surface; a plain ref or hash is enough.
|
|
38
|
-
if (typeof value !== 'string' || !/^[0-9A-Za-z][0-9A-Za-z._/-]{0,250}$/u.test(value)) {
|
|
39
|
-
throw new errors_1.WebWorkbenchError(400, 'rev must be a ref name or commit hash.', 'git_ref_invalid');
|
|
40
|
-
}
|
|
41
|
-
if (value.includes('..')) {
|
|
42
|
-
throw new errors_1.WebWorkbenchError(400, 'rev must be a ref name or commit hash.', 'git_ref_invalid');
|
|
43
|
-
}
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Recognises the image formats the browser can render from a data URL, by magic bytes —
|
|
48
|
-
* never by extension, which is user-controlled and proves nothing.
|
|
49
|
-
*/
|
|
50
|
-
const IMAGE_SIGNATURES = Object.freeze([
|
|
51
|
-
{ offset: 0, bytes: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], mime: 'image/png' },
|
|
52
|
-
{ offset: 0, bytes: [0xff, 0xd8, 0xff], mime: 'image/jpeg' },
|
|
53
|
-
{ offset: 0, bytes: [0x47, 0x49, 0x46, 0x38], mime: 'image/gif' },
|
|
54
|
-
{ offset: 0, bytes: [0x52, 0x49, 0x46, 0x46], mime: 'image/webp' },
|
|
55
|
-
]);
|
|
56
|
-
/** Largest image that may be inlined as a data URL (bounded, and nothing is fetched). */
|
|
57
|
-
const MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
58
|
-
/**
|
|
59
|
-
* Returns a renderable data URL when the bytes are a known image, so the UI can show the
|
|
60
|
-
* two versions of a picture side by side. The bytes were already read locally — the plan
|
|
61
|
-
* forbids fetching anything.
|
|
62
|
-
*/
|
|
63
|
-
function imageDataUrl(bytes) {
|
|
64
|
-
for (const signature of IMAGE_SIGNATURES) {
|
|
65
|
-
if (bytes.length < signature.offset + signature.bytes.length)
|
|
66
|
-
continue;
|
|
67
|
-
const matches = signature.bytes.every((byte, index) => bytes[signature.offset + index] === byte);
|
|
68
|
-
if (matches) {
|
|
69
|
-
return `data:${signature.mime};base64,${bytes.toString('base64')}`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
/** Detects an LFS pointer and extracts its state. Never fetches anything. */
|
|
75
|
-
function parseLfsPointer(head) {
|
|
76
|
-
if (!head.startsWith('version https://git-lfs.github.com/spec/'))
|
|
77
|
-
return null;
|
|
78
|
-
const oidMatch = /^oid sha256:([0-9a-f]{64})$/mu.exec(head);
|
|
79
|
-
if (!oidMatch)
|
|
80
|
-
return null;
|
|
81
|
-
const sizeMatch = /^size (\d+)$/mu.exec(head);
|
|
82
|
-
return Object.freeze({
|
|
83
|
-
oid: oidMatch[1],
|
|
84
|
-
size: sizeMatch ? Number(sizeMatch[1]) : null,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function createGitVersionReader(options) {
|
|
88
|
-
const { runGit, runGitBytes, readWorktreeFile } = options;
|
|
89
|
-
/** Absent version — the label legitimately has no content for this shape. */
|
|
90
|
-
const absentVersion = (label) => Object.freeze({
|
|
91
|
-
label,
|
|
92
|
-
oid: null,
|
|
93
|
-
exists: false,
|
|
94
|
-
binary: false,
|
|
95
|
-
byteSize: 0,
|
|
96
|
-
truncated: false,
|
|
97
|
-
content: null,
|
|
98
|
-
lfs: null,
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* v0.3.25 #269 — decodes already-fetched bytes into a version, shared by the
|
|
102
|
-
* object-database reader and the working-tree reader so both apply the same
|
|
103
|
-
* size bound, binary probe and LFS-pointer detection.
|
|
104
|
-
*/
|
|
105
|
-
const versionFromBytes = (label, oid, bytes) => {
|
|
106
|
-
const byteSize = bytes.length;
|
|
107
|
-
if (byteSize > MAX_VERSION_BYTES) {
|
|
108
|
-
return Object.freeze({
|
|
109
|
-
label,
|
|
110
|
-
oid,
|
|
111
|
-
exists: true,
|
|
112
|
-
binary: false,
|
|
113
|
-
byteSize,
|
|
114
|
-
truncated: true,
|
|
115
|
-
content: null,
|
|
116
|
-
lfs: null,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
const probe = bytes.subarray(0, LFS_PROBE_BYTES).toString('utf8');
|
|
120
|
-
const lfs = parseLfsPointer(probe);
|
|
121
|
-
if (lfs) {
|
|
122
|
-
return Object.freeze({
|
|
123
|
-
label,
|
|
124
|
-
oid,
|
|
125
|
-
exists: true,
|
|
126
|
-
binary: false,
|
|
127
|
-
byteSize,
|
|
128
|
-
truncated: false,
|
|
129
|
-
content: probe.trimEnd(),
|
|
130
|
-
lfs,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
const binary = bytes.includes(0);
|
|
134
|
-
// Only a bounded known image becomes a data URL; anything else stays an opaque count.
|
|
135
|
-
const dataUrl = binary && byteSize <= MAX_IMAGE_BYTES ? imageDataUrl(bytes) : null;
|
|
136
|
-
return Object.freeze({
|
|
137
|
-
label,
|
|
138
|
-
oid,
|
|
139
|
-
exists: true,
|
|
140
|
-
binary,
|
|
141
|
-
byteSize,
|
|
142
|
-
truncated: false,
|
|
143
|
-
content: binary ? null : bytes.toString('utf8'),
|
|
144
|
-
lfs: null,
|
|
145
|
-
dataUrl,
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Reads one blob by OID, bounded, with binary and LFS detection.
|
|
150
|
-
*
|
|
151
|
-
* The size is read first so an enormous historical file is reported by its size instead of
|
|
152
|
-
* being pulled into memory just to be truncated.
|
|
153
|
-
*/
|
|
154
|
-
const readVersion = async (label, oid) => {
|
|
155
|
-
if (oid === null)
|
|
156
|
-
return absentVersion(label);
|
|
157
|
-
const sizeRaw = (await runGit(['cat-file', '-s', oid])).trim();
|
|
158
|
-
const byteSize = Number(sizeRaw) || 0;
|
|
159
|
-
if (byteSize > MAX_VERSION_BYTES) {
|
|
160
|
-
return Object.freeze({
|
|
161
|
-
label,
|
|
162
|
-
oid,
|
|
163
|
-
exists: true,
|
|
164
|
-
binary: false,
|
|
165
|
-
byteSize,
|
|
166
|
-
truncated: true,
|
|
167
|
-
content: null,
|
|
168
|
-
lfs: null,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return versionFromBytes(label, oid, await runGitBytes(['cat-file', 'blob', oid]));
|
|
172
|
-
};
|
|
173
|
-
return {
|
|
174
|
-
async conflict(pathInput) {
|
|
175
|
-
const path = assertRelativePath(pathInput);
|
|
176
|
-
if ((0, redaction_1.isSensitiveFilePath)(path)) {
|
|
177
|
-
throw new errors_1.WebWorkbenchError(403, 'Sensitive file content is not available in the Web Workbench.', 'sensitive_file_blocked');
|
|
178
|
-
}
|
|
179
|
-
// `ls-files -u` lists one entry per unmerged stage, which is the authoritative record
|
|
180
|
-
// of what the conflict actually contains. Stages absent here do not exist.
|
|
181
|
-
const raw = await runGit(['ls-files', '-u', '-z', '--', path]);
|
|
182
|
-
const stageOids = new Map();
|
|
183
|
-
for (const record of raw.split('\0')) {
|
|
184
|
-
if (!record)
|
|
185
|
-
continue;
|
|
186
|
-
const [meta] = record.split('\t');
|
|
187
|
-
const [mode, oid, stage] = meta.split(' ');
|
|
188
|
-
if (!mode || !oid || !stage)
|
|
189
|
-
continue;
|
|
190
|
-
stageOids.set(Number(stage), oid);
|
|
191
|
-
}
|
|
192
|
-
// v0.3.25 #269 — the working file is read from the filesystem. The previous
|
|
193
|
-
// `hash-object` (without -w) → `cat-file` chain only worked while the edited
|
|
194
|
-
// content happened to match an object git already stored; any real edit made
|
|
195
|
-
// `cat-file` fail the entire conflict response.
|
|
196
|
-
const worktreeBytes = await readWorktreeFile?.(path);
|
|
197
|
-
const [base, ours, theirs, worktree] = await Promise.all([
|
|
198
|
-
readVersion('base', stageOids.get(1) ?? null),
|
|
199
|
-
readVersion('ours', stageOids.get(2) ?? null),
|
|
200
|
-
readVersion('theirs', stageOids.get(3) ?? null),
|
|
201
|
-
worktreeBytes
|
|
202
|
-
? Promise.resolve(versionFromBytes('worktree', null, worktreeBytes))
|
|
203
|
-
: Promise.resolve(absentVersion('worktree')),
|
|
204
|
-
]);
|
|
205
|
-
const hasBase = stageOids.has(1);
|
|
206
|
-
const hasOurs = stageOids.has(2);
|
|
207
|
-
const hasTheirs = stageOids.has(3);
|
|
208
|
-
let shape = 'other';
|
|
209
|
-
if (hasBase && hasOurs && hasTheirs)
|
|
210
|
-
shape = 'both-modified';
|
|
211
|
-
else if (!hasBase && hasOurs && hasTheirs)
|
|
212
|
-
shape = 'both-added';
|
|
213
|
-
// The delete shapes must be tested BEFORE the add shapes: a modify/delete conflict also
|
|
214
|
-
// has exactly one side present, so a loose `hasOurs && !hasTheirs` would swallow it and
|
|
215
|
-
// mislabel a deletion as an addition. A missing side only means 'added' when there is no
|
|
216
|
-
// base to delete from.
|
|
217
|
-
else if (hasBase && !hasOurs && hasTheirs)
|
|
218
|
-
shape = 'deleted-by-us';
|
|
219
|
-
else if (hasBase && hasOurs && !hasTheirs)
|
|
220
|
-
shape = 'deleted-by-them';
|
|
221
|
-
else if (hasOurs && !hasTheirs)
|
|
222
|
-
shape = 'added-by-us';
|
|
223
|
-
else if (!hasOurs && hasTheirs)
|
|
224
|
-
shape = 'added-by-them';
|
|
225
|
-
else if (hasBase && !hasOurs && !hasTheirs)
|
|
226
|
-
shape = 'both-deleted';
|
|
227
|
-
return Object.freeze({ path, shape, base, ours, theirs, worktree });
|
|
228
|
-
},
|
|
229
|
-
async blob(input) {
|
|
230
|
-
const path = assertRelativePath(input.path);
|
|
231
|
-
const rev = assertRev(input.rev);
|
|
232
|
-
if ((0, redaction_1.isSensitiveFilePath)(path)) {
|
|
233
|
-
throw new errors_1.WebWorkbenchError(403, 'Sensitive file content is not available in the Web Workbench.', 'sensitive_file_blocked');
|
|
234
|
-
}
|
|
235
|
-
// `rev:path` is a tree lookup, not a working-tree read: a file deleted since that
|
|
236
|
-
// revision is still readable, which is the whole point of "view that version".
|
|
237
|
-
const oid = (await runGit(['rev-parse', '--verify', '--quiet', `${rev}:${path}`]).catch(() => ''))
|
|
238
|
-
.toString()
|
|
239
|
-
.trim();
|
|
240
|
-
if (!/^[0-9a-f]{7,64}$/iu.test(oid)) {
|
|
241
|
-
throw new errors_1.WebWorkbenchError(404, 'That file does not exist at the requested revision.', 'git_blob_not_found');
|
|
242
|
-
}
|
|
243
|
-
const version = await readVersion('revision', oid);
|
|
244
|
-
return Object.freeze({
|
|
245
|
-
path,
|
|
246
|
-
rev,
|
|
247
|
-
oid,
|
|
248
|
-
binary: version.binary,
|
|
249
|
-
byteSize: version.byteSize,
|
|
250
|
-
truncated: version.truncated,
|
|
251
|
-
content: Object.freeze((version.content ?? '').split('\n')),
|
|
252
|
-
lfs: version.lfs,
|
|
253
|
-
dataUrl: version.dataUrl ?? null,
|
|
254
|
-
});
|
|
255
|
-
},
|
|
256
|
-
async submodules() {
|
|
257
|
-
// Only the recorded gitlink SHAs. `git submodule status` is deliberately NOT run: it
|
|
258
|
-
// traverses every submodule, which plan G6 forbids.
|
|
259
|
-
const raw = await runGit(['ls-files', '--stage', '-z']);
|
|
260
|
-
const entries = [];
|
|
261
|
-
for (const record of raw.split('\0')) {
|
|
262
|
-
if (!record)
|
|
263
|
-
continue;
|
|
264
|
-
const [meta, filePath] = record.split('\t');
|
|
265
|
-
const [mode, oid] = (meta ?? '').split(' ');
|
|
266
|
-
if (mode !== '160000' || !oid || !filePath)
|
|
267
|
-
continue;
|
|
268
|
-
entries.push(Object.freeze({
|
|
269
|
-
path: filePath,
|
|
270
|
-
gitlinkOid: oid,
|
|
271
|
-
dirtySummary: null,
|
|
272
|
-
dirtyNote: '未检测:不遍历子模块(计划 G6)。',
|
|
273
|
-
}));
|
|
274
|
-
}
|
|
275
|
-
return Object.freeze(entries);
|
|
276
|
-
},
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
//# sourceMappingURL=git-version-service.js.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native background/daemon lifecycle for `orion web` (issue #247, S1+S2).
|
|
3
|
-
*
|
|
4
|
-
* A foreground `orion web --background` parent spawns the real host detached,
|
|
5
|
-
* waits for it to publish a pidfile under the config home, then returns. The
|
|
6
|
-
* detached child redirects its stdio to per-host log files and keeps the
|
|
7
|
-
* fail-closed approval / context / sandbox semantics untouched — this is a
|
|
8
|
-
* process-lifecycle concern only, still bound to 127.0.0.1.
|
|
9
|
-
*
|
|
10
|
-
* The pidfile shape is intentionally tiny and human-readable:
|
|
11
|
-
*
|
|
12
|
-
* { "pid": 12345, "port": 4242, "url": "http://127.0.0.1:4242",
|
|
13
|
-
* "startedAt": 1725000000000, "workspace": "/abs/path" }
|
|
14
|
-
*/
|
|
15
|
-
import { type ChildProcess } from 'child_process';
|
|
16
|
-
export declare const HOST_PIDFILE_BASE = "web-host";
|
|
17
|
-
export declare const HOST_DAEMON_CHILD_ENV = "ORION_WEB_DAEMON_CHILD";
|
|
18
|
-
export declare const DAEMON_READY_TIMEOUT_MS = 8000;
|
|
19
|
-
export declare const DAEMON_POLL_MS = 120;
|
|
20
|
-
export interface HostPidfile {
|
|
21
|
-
readonly pid: number;
|
|
22
|
-
readonly port: number;
|
|
23
|
-
readonly url: string;
|
|
24
|
-
readonly workspace: string;
|
|
25
|
-
readonly startedAt: number;
|
|
26
|
-
}
|
|
27
|
-
export type HostDaemonStatus = {
|
|
28
|
-
readonly state: 'running';
|
|
29
|
-
readonly pidfile: HostPidfile;
|
|
30
|
-
} | {
|
|
31
|
-
readonly state: 'stopped';
|
|
32
|
-
} | {
|
|
33
|
-
readonly state: 'stale';
|
|
34
|
-
readonly pid: number;
|
|
35
|
-
readonly port: number;
|
|
36
|
-
};
|
|
37
|
-
export declare function hostLogsDirectory(): string;
|
|
38
|
-
export declare function hostPidfilePath(port: number): string;
|
|
39
|
-
export declare function parseHostPidfile(raw: string): HostPidfile | null;
|
|
40
|
-
export declare function readHostPidfile(port: number): HostPidfile | null;
|
|
41
|
-
export declare function writeHostPidfile(pidfile: HostPidfile): void;
|
|
42
|
-
export declare function clearHostPidfile(port: number): void;
|
|
43
|
-
/** Cross-platform process-liveness probe used by `status`. */
|
|
44
|
-
export declare function isProcessAlive(pid: number): boolean;
|
|
45
|
-
export declare function hostDaemonStatus(port: number): HostDaemonStatus;
|
|
46
|
-
/**
|
|
47
|
-
* Parent-side entry for `--background`: spawn the host detached, redirect its
|
|
48
|
-
* stdio to `~/.orion-code/logs/web-<port>.log`, and wait for the pidfile so the
|
|
49
|
-
* foreground command can print the URL and exit cleanly.
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* True when something already listens on 127.0.0.1:port — typically another
|
|
53
|
-
* Orion host process (e.g. one managed by launchd, which does not write a
|
|
54
|
-
* pidfile). Detecting this up front turns a raw EADDRINUSE crash into a
|
|
55
|
-
* friendly message.
|
|
56
|
-
*/
|
|
57
|
-
export declare function isHostPortTaken(port: number): Promise<boolean>;
|
|
58
|
-
/** Best-effort tail of the host log used when a background child exits early. */
|
|
59
|
-
export declare function readHostLogTail(port: number, lines?: number): string;
|
|
60
|
-
export declare function spawnBackgroundHost(options: {
|
|
61
|
-
readonly cwd: string;
|
|
62
|
-
readonly port: number;
|
|
63
|
-
readonly webArgs: readonly string[];
|
|
64
|
-
}): Promise<{
|
|
65
|
-
readonly child: ChildProcess;
|
|
66
|
-
readonly pidfile: HostPidfile;
|
|
67
|
-
}>;
|
|
68
|
-
/** Terminate a background host by pidfile (SIGTERM, then escalate to SIGKILL). */
|
|
69
|
-
export declare function stopBackgroundHost(port: number): Promise<'stopped' | 'not_running'>;
|
|
70
|
-
//# sourceMappingURL=host-daemon.d.ts.map
|
package/dist/web/host-daemon.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DAEMON_POLL_MS = exports.DAEMON_READY_TIMEOUT_MS = exports.HOST_DAEMON_CHILD_ENV = exports.HOST_PIDFILE_BASE = void 0;
|
|
4
|
-
exports.hostLogsDirectory = hostLogsDirectory;
|
|
5
|
-
exports.hostPidfilePath = hostPidfilePath;
|
|
6
|
-
exports.parseHostPidfile = parseHostPidfile;
|
|
7
|
-
exports.readHostPidfile = readHostPidfile;
|
|
8
|
-
exports.writeHostPidfile = writeHostPidfile;
|
|
9
|
-
exports.clearHostPidfile = clearHostPidfile;
|
|
10
|
-
exports.isProcessAlive = isProcessAlive;
|
|
11
|
-
exports.hostDaemonStatus = hostDaemonStatus;
|
|
12
|
-
exports.isHostPortTaken = isHostPortTaken;
|
|
13
|
-
exports.readHostLogTail = readHostLogTail;
|
|
14
|
-
exports.spawnBackgroundHost = spawnBackgroundHost;
|
|
15
|
-
exports.stopBackgroundHost = stopBackgroundHost;
|
|
16
|
-
/**
|
|
17
|
-
* Native background/daemon lifecycle for `orion web` (issue #247, S1+S2).
|
|
18
|
-
*
|
|
19
|
-
* A foreground `orion web --background` parent spawns the real host detached,
|
|
20
|
-
* waits for it to publish a pidfile under the config home, then returns. The
|
|
21
|
-
* detached child redirects its stdio to per-host log files and keeps the
|
|
22
|
-
* fail-closed approval / context / sandbox semantics untouched — this is a
|
|
23
|
-
* process-lifecycle concern only, still bound to 127.0.0.1.
|
|
24
|
-
*
|
|
25
|
-
* The pidfile shape is intentionally tiny and human-readable:
|
|
26
|
-
*
|
|
27
|
-
* { "pid": 12345, "port": 4242, "url": "http://127.0.0.1:4242",
|
|
28
|
-
* "startedAt": 1725000000000, "workspace": "/abs/path" }
|
|
29
|
-
*/
|
|
30
|
-
const child_process_1 = require("child_process");
|
|
31
|
-
const net_1 = require("net");
|
|
32
|
-
const fs_1 = require("fs");
|
|
33
|
-
const path_1 = require("path");
|
|
34
|
-
const paths_1 = require("../product/paths");
|
|
35
|
-
exports.HOST_PIDFILE_BASE = 'web-host';
|
|
36
|
-
exports.HOST_DAEMON_CHILD_ENV = 'ORION_WEB_DAEMON_CHILD';
|
|
37
|
-
exports.DAEMON_READY_TIMEOUT_MS = 8000;
|
|
38
|
-
exports.DAEMON_POLL_MS = 120;
|
|
39
|
-
function hostLogsDirectory() {
|
|
40
|
-
return (0, path_1.join)((0, paths_1.getConfigHome)(), 'logs');
|
|
41
|
-
}
|
|
42
|
-
function hostPidfilePath(port) {
|
|
43
|
-
return (0, path_1.join)((0, paths_1.getConfigHome)(), `${exports.HOST_PIDFILE_BASE}.${port}.pid`);
|
|
44
|
-
}
|
|
45
|
-
function parseHostPidfile(raw) {
|
|
46
|
-
try {
|
|
47
|
-
const value = JSON.parse(raw);
|
|
48
|
-
if (!value || typeof value !== 'object')
|
|
49
|
-
return null;
|
|
50
|
-
const record = value;
|
|
51
|
-
if (typeof record.pid !== 'number' ||
|
|
52
|
-
typeof record.port !== 'number' ||
|
|
53
|
-
typeof record.url !== 'string' ||
|
|
54
|
-
typeof record.workspace !== 'string' ||
|
|
55
|
-
typeof record.startedAt !== 'number') {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return Object.freeze({
|
|
59
|
-
pid: record.pid,
|
|
60
|
-
port: record.port,
|
|
61
|
-
url: record.url,
|
|
62
|
-
workspace: record.workspace,
|
|
63
|
-
startedAt: record.startedAt,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function readHostPidfile(port) {
|
|
71
|
-
const path = hostPidfilePath(port);
|
|
72
|
-
if (!(0, fs_1.existsSync)(path))
|
|
73
|
-
return null;
|
|
74
|
-
try {
|
|
75
|
-
return parseHostPidfile((0, fs_1.readFileSync)(path, 'utf8'));
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function writeHostPidfile(pidfile) {
|
|
82
|
-
(0, fs_1.mkdirSync)((0, paths_1.getConfigHome)(), { recursive: true });
|
|
83
|
-
(0, fs_1.writeFileSync)(hostPidfilePath(pidfile.port), JSON.stringify(pidfile, null, 2), 'utf8');
|
|
84
|
-
}
|
|
85
|
-
function clearHostPidfile(port) {
|
|
86
|
-
try {
|
|
87
|
-
(0, fs_1.rmSync)(hostPidfilePath(port), { force: true });
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// Pidfile removal is best-effort: a locked/restricted filesystem must not
|
|
91
|
-
// turn `orion web stop` into a failure after the process is already gone.
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/** Cross-platform process-liveness probe used by `status`. */
|
|
95
|
-
function isProcessAlive(pid) {
|
|
96
|
-
try {
|
|
97
|
-
process.kill(pid, 0);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
return error.code === 'EPERM';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function hostDaemonStatus(port) {
|
|
105
|
-
const pidfile = readHostPidfile(port);
|
|
106
|
-
if (!pidfile)
|
|
107
|
-
return { state: 'stopped' };
|
|
108
|
-
if (isProcessAlive(pidfile.pid)) {
|
|
109
|
-
return { state: 'running', pidfile };
|
|
110
|
-
}
|
|
111
|
-
return { state: 'stale', pid: pidfile.pid, port };
|
|
112
|
-
}
|
|
113
|
-
/** Build the argument vector used to re-launch the current CLI detached. */
|
|
114
|
-
function childArgs(webArgs) {
|
|
115
|
-
const entry = process.argv[1];
|
|
116
|
-
if (!entry)
|
|
117
|
-
throw new Error('Unable to determine the CLI entry to relaunch.');
|
|
118
|
-
return [entry, 'web', ...webArgs];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Parent-side entry for `--background`: spawn the host detached, redirect its
|
|
122
|
-
* stdio to `~/.orion-code/logs/web-<port>.log`, and wait for the pidfile so the
|
|
123
|
-
* foreground command can print the URL and exit cleanly.
|
|
124
|
-
*/
|
|
125
|
-
/**
|
|
126
|
-
* True when something already listens on 127.0.0.1:port — typically another
|
|
127
|
-
* Orion host process (e.g. one managed by launchd, which does not write a
|
|
128
|
-
* pidfile). Detecting this up front turns a raw EADDRINUSE crash into a
|
|
129
|
-
* friendly message.
|
|
130
|
-
*/
|
|
131
|
-
function isHostPortTaken(port) {
|
|
132
|
-
return new Promise(resolve => {
|
|
133
|
-
const socket = (0, net_1.connect)({ host: '127.0.0.1', port });
|
|
134
|
-
let settled = false;
|
|
135
|
-
const done = (taken) => {
|
|
136
|
-
if (settled)
|
|
137
|
-
return;
|
|
138
|
-
settled = true;
|
|
139
|
-
socket.destroy();
|
|
140
|
-
resolve(taken);
|
|
141
|
-
};
|
|
142
|
-
socket.once('connect', () => done(true));
|
|
143
|
-
socket.once('error', () => done(false));
|
|
144
|
-
socket.setTimeout(800, () => done(false));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/** Best-effort tail of the host log used when a background child exits early. */
|
|
148
|
-
function readHostLogTail(port, lines = 6) {
|
|
149
|
-
try {
|
|
150
|
-
const raw = (0, fs_1.readFileSync)((0, path_1.join)(hostLogsDirectory(), `web-${port}.log`), 'utf8');
|
|
151
|
-
return raw.split('\n').filter(Boolean).slice(-lines).join('\n');
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
return '';
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async function assertHostPortAvailable(port) {
|
|
158
|
-
if (await isHostPortTaken(port)) {
|
|
159
|
-
throw new Error(`Port ${port} is already served by another Orion host process. This is ` +
|
|
160
|
-
`often a launchd LaunchAgent (ai.orion-code.web). Check with ` +
|
|
161
|
-
'`launchctl list | grep orion`; if the running host belongs to this ' +
|
|
162
|
-
`CLI, use \`orion web status --port ${port}\` to confirm before stopping it.`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function spawnBackgroundHost(options) {
|
|
166
|
-
await assertHostPortAvailable(options.port);
|
|
167
|
-
const logsDirectory = hostLogsDirectory();
|
|
168
|
-
(0, fs_1.mkdirSync)(logsDirectory, { recursive: true });
|
|
169
|
-
const logPath = (0, path_1.join)(logsDirectory, `web-${options.port}.log`);
|
|
170
|
-
const output = (0, fs_1.openSync)(logPath, 'a');
|
|
171
|
-
const child = (0, child_process_1.spawn)(process.execPath, childArgs(options.webArgs), {
|
|
172
|
-
cwd: options.cwd,
|
|
173
|
-
detached: true,
|
|
174
|
-
stdio: ['ignore', output, output],
|
|
175
|
-
env: { ...process.env, [exports.HOST_DAEMON_CHILD_ENV]: '1' },
|
|
176
|
-
});
|
|
177
|
-
child.unref();
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
const deadline = Date.now() + exports.DAEMON_READY_TIMEOUT_MS;
|
|
180
|
-
const poll = () => {
|
|
181
|
-
const pidfile = readHostPidfile(options.port);
|
|
182
|
-
if (pidfile && pidfile.pid === child.pid) {
|
|
183
|
-
resolve({ child, pidfile });
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (child.exitCode !== null || child.signalCode !== null) {
|
|
187
|
-
reject(new Error(`Background host exited before readiness (code ${child.exitCode ?? 'signal'}); see ${logPath}`));
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (Date.now() > deadline) {
|
|
191
|
-
reject(new Error(`Background host did not become ready within ${exports.DAEMON_READY_TIMEOUT_MS}ms; see ${logPath}`));
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
setTimeout(poll, exports.DAEMON_POLL_MS);
|
|
195
|
-
};
|
|
196
|
-
poll();
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
/** Terminate a background host by pidfile (SIGTERM, then escalate to SIGKILL). */
|
|
200
|
-
function stopBackgroundHost(port) {
|
|
201
|
-
const status = hostDaemonStatus(port);
|
|
202
|
-
if (status.state !== 'running')
|
|
203
|
-
return Promise.resolve('not_running');
|
|
204
|
-
const { pidfile } = status;
|
|
205
|
-
return new Promise(resolve => {
|
|
206
|
-
try {
|
|
207
|
-
process.kill(pidfile.pid, 'SIGTERM');
|
|
208
|
-
}
|
|
209
|
-
catch {
|
|
210
|
-
clearHostPidfile(port);
|
|
211
|
-
resolve('stopped');
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const deadline = Date.now() + 4000;
|
|
215
|
-
const poll = () => {
|
|
216
|
-
if (!isProcessAlive(pidfile.pid)) {
|
|
217
|
-
clearHostPidfile(port);
|
|
218
|
-
resolve('stopped');
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (Date.now() > deadline) {
|
|
222
|
-
try {
|
|
223
|
-
process.kill(pidfile.pid, 'SIGKILL');
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
// Already gone.
|
|
227
|
-
}
|
|
228
|
-
clearHostPidfile(port);
|
|
229
|
-
resolve('stopped');
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
setTimeout(poll, 100);
|
|
233
|
-
};
|
|
234
|
-
poll();
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=host-daemon.js.map
|
package/dist/web/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { runOrionWeb, type RunOrionWebOptions } from './launch';
|
|
2
|
-
export { startOrionWebServer, type OrionWebServerHandle, type OrionWebServerOptions, } from './server';
|
|
3
|
-
export { WebWorkbenchController, WebWorkbenchError } from './workbench-controller';
|
|
4
|
-
export { WebEventHub, type WebEventHubOptions } from './event-hub';
|
|
5
|
-
export * from './protocol';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|