@amoree-code/ocean 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +284 -2
- package/dist/application/auth/auth-orchestrator.js +77 -0
- package/dist/application/clients/clients.js +646 -0
- package/dist/application/clients/editors.js +398 -0
- package/dist/application/clients/hooks.js +335 -0
- package/dist/application/clients/native.js +410 -0
- package/dist/application/clients/opencode-plugin.js +158 -0
- package/dist/application/clients/registry.js +188 -0
- package/dist/application/gateway/webhook-gateway.js +137 -0
- package/dist/application/install/provider-installer.js +184 -0
- package/dist/application/integrations/charter-copies.js +76 -0
- package/dist/application/integrations/claude-vscode.js +106 -0
- package/dist/application/integrations/engine-entry-repair.js +105 -0
- package/dist/application/integrations/skill-filter.js +254 -0
- package/dist/application/layout/layout-apply.js +443 -0
- package/dist/application/layout/layout-plan.js +236 -0
- package/dist/application/layout/workspace-template.js +34 -0
- package/dist/application/onboarding/state.js +23 -0
- package/dist/application/onboarding/steps.js +249 -0
- package/dist/application/profiles/profile-distribution.js +53 -0
- package/dist/application/profiles/profile-suggestion.js +39 -0
- package/dist/application/profiles/profile-upgrade-service.js +208 -0
- package/dist/application/pull/history-index.js +476 -0
- package/dist/application/pull/project-match.js +132 -0
- package/dist/application/pull/pull.js +202 -0
- package/dist/application/pull/server-capture.js +307 -0
- package/dist/application/scheduler/local-scheduler.js +210 -0
- package/dist/composition/runtime.js +64 -0
- package/dist/engine-root.js +9 -0
- package/dist/infrastructure/filesystem/profile-loader.js +46 -0
- package/dist/infrastructure/filesystem/runtime-config-loader.js +29 -0
- package/dist/infrastructure/filesystem/skill-loader.js +84 -0
- package/dist/infrastructure/filesystem/workspace-capability.js +37 -0
- package/dist/infrastructure/observability/runtime-logger.js +16 -0
- package/dist/infrastructure/process/agent-tool-executor.js +99 -0
- package/dist/infrastructure/process/cli-process.js +49 -0
- package/dist/infrastructure/process/interactive-process.js +145 -0
- package/dist/infrastructure/process/process-supervisor.js +194 -0
- package/dist/infrastructure/process/service.js +252 -0
- package/dist/infrastructure/providers/browser-provider.js +2 -0
- package/dist/infrastructure/providers/claude-sdk.js +137 -0
- package/dist/infrastructure/providers/client-home.js +14 -0
- package/dist/infrastructure/providers/fake-browser-provider.js +146 -0
- package/dist/infrastructure/providers/ollama-embedder.js +74 -0
- package/dist/infrastructure/providers/openai-compatible.js +268 -0
- package/dist/infrastructure/providers/playwright-browser-provider.js +380 -0
- package/dist/infrastructure/providers/provider-capabilities.js +50 -0
- package/dist/infrastructure/providers/provider-invocation.js +184 -0
- package/dist/infrastructure/providers/provider-registry.js +77 -0
- package/dist/infrastructure/providers/providers.js +134 -0
- package/dist/infrastructure/wrappers/wrapper-manager.js +374 -0
- package/dist/interfaces/cli/auth-command.js +54 -0
- package/dist/interfaces/cli/browser-bridge-command.js +93 -0
- package/dist/interfaces/cli/browser-command.js +119 -0
- package/dist/interfaces/cli/capture-command.js +125 -0
- package/dist/interfaces/cli/client-test-command.js +133 -0
- package/dist/interfaces/cli/clients-command.js +129 -0
- package/dist/interfaces/cli/command-registry.js +1211 -0
- package/dist/interfaces/cli/context-command.js +172 -0
- package/dist/interfaces/cli/daily-command.js +131 -0
- package/dist/interfaces/cli/governance-command.js +55 -0
- package/dist/interfaces/cli/handoff-command.js +35 -0
- package/dist/interfaces/cli/help-command.js +207 -0
- package/dist/interfaces/cli/idea-command.js +47 -0
- package/dist/interfaces/cli/intercept-command.js +317 -0
- package/dist/interfaces/cli/layout-command.js +27 -0
- package/dist/interfaces/cli/market-command.js +52 -0
- package/dist/interfaces/cli/mcp-gateway-command.js +30 -0
- package/dist/interfaces/cli/memory-command.js +317 -0
- package/dist/interfaces/cli/migrate-command.js +26 -0
- package/dist/interfaces/cli/observe-command.js +78 -0
- package/dist/interfaces/cli/onboard-command.js +123 -0
- package/dist/interfaces/cli/operate-command.js +59 -0
- package/dist/interfaces/cli/profiles-command.js +70 -0
- package/dist/interfaces/cli/pull-command.js +54 -0
- package/dist/interfaces/cli/setup-command.js +143 -0
- package/dist/interfaces/cli/tasks-command.js +249 -0
- package/dist/main.js +49 -0
- package/dist/node-warnings.js +17 -0
- package/dist/version.js +8 -0
- package/market/mcp/chrome-devtools/ocean.capability.json +28 -0
- package/market/mcp/gateway/ocean.capability.json +21 -0
- package/market/mcp/obsidian/ocean.capability.json +21 -0
- package/market/mcp/ocean/ocean.capability.json +21 -0
- package/market/mcp/playwright/ocean.capability.json +23 -0
- package/node_modules/@ocean/brain/dist/brain/brain-eval.js +29 -0
- package/node_modules/@ocean/brain/dist/brain/brain-markdown.js +226 -0
- package/node_modules/@ocean/brain/dist/brain/brain-reindex.js +247 -0
- package/node_modules/@ocean/brain/dist/brain/brain-service.js +320 -0
- package/node_modules/@ocean/brain/dist/capture/inbox-sync.js +22 -0
- package/node_modules/@ocean/brain/dist/evidence/verification-report.js +13 -0
- package/node_modules/@ocean/brain/dist/infrastructure/brain/brain-index.js +285 -0
- package/node_modules/@ocean/brain/dist/memory/brain-dump.js +145 -0
- package/node_modules/@ocean/brain/dist/memory/daily-narrative.js +142 -0
- package/node_modules/@ocean/brain/dist/memory/index-sync.js +124 -0
- package/node_modules/@ocean/brain/dist/memory/lesson-activation.js +93 -0
- package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +188 -0
- package/node_modules/@ocean/brain/dist/memory/lessons.js +321 -0
- package/node_modules/@ocean/brain/dist/memory/memory-audit.js +100 -0
- package/node_modules/@ocean/brain/dist/memory/memory-digest.js +49 -0
- package/node_modules/@ocean/brain/dist/memory/memory-harvest.js +345 -0
- package/node_modules/@ocean/brain/dist/memory/memory-paths.js +174 -0
- package/node_modules/@ocean/brain/dist/memory/memory-review.js +278 -0
- package/node_modules/@ocean/brain/dist/memory/memory-trash.js +152 -0
- package/node_modules/@ocean/brain/dist/memory/memory-write.js +216 -0
- package/node_modules/@ocean/brain/dist/memory/model-narrative.js +129 -0
- package/node_modules/@ocean/brain/dist/memory/profile-facts.js +103 -0
- package/node_modules/@ocean/brain/dist/memory/session-promotion.js +61 -0
- package/node_modules/@ocean/brain/dist/memory/session-summary.js +113 -0
- package/node_modules/@ocean/brain/dist/memory/signal-detection.js +66 -0
- package/node_modules/@ocean/brain/package.json +11 -0
- package/node_modules/@ocean/context/dist/context/context-compression.js +66 -0
- package/node_modules/@ocean/context/dist/context/context-cost.js +587 -0
- package/node_modules/@ocean/context/dist/context/context-ladder.js +363 -0
- package/node_modules/@ocean/context/dist/context/context-packet.js +213 -0
- package/node_modules/@ocean/context/dist/context/context-references.js +255 -0
- package/node_modules/@ocean/context/dist/context/intent-router.js +259 -0
- package/node_modules/@ocean/context/dist/context/resource-injection.js +36 -0
- package/node_modules/@ocean/context/package.json +11 -0
- package/node_modules/@ocean/core/dist/domain/brain/brain-record.js +22 -0
- package/node_modules/@ocean/core/dist/domain/brain/record-scope.js +22 -0
- package/node_modules/@ocean/core/dist/domain/capabilities/browser-contract.js +64 -0
- package/node_modules/@ocean/core/dist/domain/capabilities/capability-contract.js +16 -0
- package/node_modules/@ocean/core/dist/domain/capabilities/capability-manifest.js +72 -0
- package/node_modules/@ocean/core/dist/domain/context/context-validator.js +5 -0
- package/node_modules/@ocean/core/dist/domain/context/context.js +34 -0
- package/node_modules/@ocean/core/dist/domain/context/project-id.js +30 -0
- package/node_modules/@ocean/core/dist/domain/evidence/evidence.js +16 -0
- package/node_modules/@ocean/core/dist/domain/mcp/mcp-contract.js +36 -0
- package/node_modules/@ocean/core/dist/domain/mcp/memory-contract.js +41 -0
- package/node_modules/@ocean/core/dist/domain/ports/brain-index-port.js +7 -0
- package/node_modules/@ocean/core/dist/domain/ports/browser-port.js +8 -0
- package/node_modules/@ocean/core/dist/domain/ports/embedder-port.js +2 -0
- package/node_modules/@ocean/core/dist/domain/ports/platform-ports.js +2 -0
- package/node_modules/@ocean/core/dist/domain/ports/runtime-ports.js +2 -0
- package/node_modules/@ocean/core/dist/domain/ports/session-store-port.js +2 -0
- package/node_modules/@ocean/core/dist/domain/process/process-events.js +5 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-distribution.js +19 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-policy.js +34 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-selection.js +73 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-upgrade.js +123 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile-validator.js +5 -0
- package/node_modules/@ocean/core/dist/domain/profiles/profile.js +218 -0
- package/node_modules/@ocean/core/dist/domain/profiles/runtime-config.js +30 -0
- package/node_modules/@ocean/core/dist/domain/providers/provider-capability.js +28 -0
- package/node_modules/@ocean/core/dist/domain/providers/provider.js +2 -0
- package/node_modules/@ocean/core/dist/domain/redaction/redaction.js +86 -0
- package/node_modules/@ocean/core/dist/domain/runs/agent-tools.js +92 -0
- package/node_modules/@ocean/core/dist/domain/runs/execution-plan.js +71 -0
- package/node_modules/@ocean/core/dist/domain/runs/run-contract.js +38 -0
- package/node_modules/@ocean/core/dist/domain/sessions/entry-contract.js +31 -0
- package/node_modules/@ocean/core/dist/domain/sessions/handoff.js +78 -0
- package/node_modules/@ocean/core/dist/domain/sessions/session.js +58 -0
- package/node_modules/@ocean/core/dist/domain/skills/default-skills.js +29 -0
- package/node_modules/@ocean/core/dist/domain/skills/skill-validator.js +5 -0
- package/node_modules/@ocean/core/dist/domain/skills/skill.js +11 -0
- package/node_modules/@ocean/core/dist/domain/tasks/task-id.js +85 -0
- package/node_modules/@ocean/core/dist/shared/fs-utils.js +212 -0
- package/node_modules/@ocean/core/dist/shared/local-date.js +16 -0
- package/node_modules/@ocean/core/dist/shared/paths.js +324 -0
- package/node_modules/@ocean/core/dist/shared/project-resolution.js +1065 -0
- package/node_modules/@ocean/core/dist/shared/task-reference.js +133 -0
- package/node_modules/@ocean/core/package.json +14 -0
- package/node_modules/@ocean/loop/dist/handoff/handoff-service.js +133 -0
- package/node_modules/@ocean/loop/dist/hooks/lifecycle-hooks.js +15 -0
- package/node_modules/@ocean/loop/dist/hooks/session-end-hook.js +183 -0
- package/node_modules/@ocean/loop/dist/hooks/session-start-hook.js +237 -0
- package/node_modules/@ocean/loop/dist/infrastructure/persistence/session-store.js +690 -0
- package/node_modules/@ocean/loop/dist/infrastructure/persistence/session-validator.js +5 -0
- package/node_modules/@ocean/loop/dist/loops/iteration-graph.js +147 -0
- package/node_modules/@ocean/loop/dist/loops/task-loop-record.js +2 -0
- package/node_modules/@ocean/loop/dist/loops/task-loop.js +281 -0
- package/node_modules/@ocean/loop/dist/operations/memory-knowledge-operations.js +263 -0
- package/node_modules/@ocean/loop/dist/operations/operation-contract.js +227 -0
- package/node_modules/@ocean/loop/dist/operations/operation-scope.js +28 -0
- package/node_modules/@ocean/loop/dist/operations/project-operations.js +93 -0
- package/node_modules/@ocean/loop/dist/operations/record-io.js +65 -0
- package/node_modules/@ocean/loop/dist/operations/record-operations.js +45 -0
- package/node_modules/@ocean/loop/dist/operations/task-linker.js +40 -0
- package/node_modules/@ocean/loop/dist/operations/task-operations.js +279 -0
- package/node_modules/@ocean/loop/dist/operations/write-guard.js +157 -0
- package/node_modules/@ocean/loop/dist/runs/prompt-assembly.js +112 -0
- package/node_modules/@ocean/loop/dist/runs/run-agent.js +425 -0
- package/node_modules/@ocean/loop/dist/runs/run-authorization.js +24 -0
- package/node_modules/@ocean/loop/dist/runs/tool-loop.js +173 -0
- package/node_modules/@ocean/loop/dist/sessions/session-closeout.js +150 -0
- package/node_modules/@ocean/loop/dist/sessions/session-pointer.js +133 -0
- package/node_modules/@ocean/loop/dist/sessions/session-projects.js +26 -0
- package/node_modules/@ocean/loop/dist/sessions/session-retention.js +132 -0
- package/node_modules/@ocean/loop/dist/tasks/archive-tasks.js +210 -0
- package/node_modules/@ocean/loop/dist/tasks/checkpoint-task.js +31 -0
- package/node_modules/@ocean/loop/dist/tasks/claim-task.js +126 -0
- package/node_modules/@ocean/loop/dist/tasks/list-tasks.js +113 -0
- package/node_modules/@ocean/loop/dist/tasks/new-task.js +42 -0
- package/node_modules/@ocean/loop/dist/tasks/renumber-tasks.js +134 -0
- package/node_modules/@ocean/loop/dist/tasks/verification-readiness.js +78 -0
- package/node_modules/@ocean/loop/dist/tasks/verify-task.js +234 -0
- package/node_modules/@ocean/loop/package.json +11 -0
- package/node_modules/@ocean/market/dist/adapters/mcp-adapter.js +64 -0
- package/node_modules/@ocean/market/dist/adapters/owned-directory.js +89 -0
- package/node_modules/@ocean/market/dist/adapters/plugin-adapter.js +39 -0
- package/node_modules/@ocean/market/dist/adapters/skill-adapter.js +32 -0
- package/node_modules/@ocean/market/dist/capability/adapter.js +2 -0
- package/node_modules/@ocean/market/dist/capability/catalog.js +63 -0
- package/node_modules/@ocean/market/dist/capability/content-digest.js +40 -0
- package/node_modules/@ocean/market/dist/capability/registry.js +81 -0
- package/node_modules/@ocean/market/dist/install/default-marketplace.js +47 -0
- package/node_modules/@ocean/market/dist/install/lock.js +34 -0
- package/node_modules/@ocean/market/dist/install/marketplace-service.js +165 -0
- package/node_modules/@ocean/market/dist/mcp/browser-bridge.js +263 -0
- package/node_modules/@ocean/market/dist/mcp/mcp-connection.js +67 -0
- package/node_modules/@ocean/market/dist/mcp/mcp-gateway.js +317 -0
- package/node_modules/@ocean/market/dist/mcp/mcp-launch.js +102 -0
- package/node_modules/@ocean/market/dist/mcp/mcp-runner.js +32 -0
- package/node_modules/@ocean/market/dist/security/description-scan.js +45 -0
- package/node_modules/@ocean/market/dist/security/permissions.js +57 -0
- package/node_modules/@ocean/market/dist/security/sandbox.js +74 -0
- package/node_modules/@ocean/market/dist/skills/core-skill-sync.js +113 -0
- package/node_modules/@ocean/market/dist/skills/signal-detection.js +84 -0
- package/node_modules/@ocean/market/dist/skills/skill-curation.js +123 -0
- package/node_modules/@ocean/market/dist/skills/skill-hub.js +220 -0
- package/node_modules/@ocean/market/dist/skills/task-observer.js +165 -0
- package/node_modules/@ocean/market/package.json +11 -0
- package/node_modules/@ocean/services/dist/browser/browser-service.js +124 -0
- package/node_modules/@ocean/services/dist/browser/browser-session.js +287 -0
- package/node_modules/@ocean/services/dist/browser/browser-task-runner.js +70 -0
- package/node_modules/@ocean/services/dist/doctor/workspace-doctor.js +547 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/call-ledger.js +114 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/mcp-client.js +162 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/obsidian-server.js +251 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/ocean-server.js +880 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/server-version.js +20 -0
- package/node_modules/@ocean/services/dist/infrastructure/mcp/tool-registry.js +29 -0
- package/node_modules/@ocean/services/dist/obsidian/conflict-log.js +68 -0
- package/node_modules/@ocean/services/dist/obsidian/inbox-promotion.js +80 -0
- package/node_modules/@ocean/services/dist/obsidian/vault-discovery.js +113 -0
- package/node_modules/@ocean/services/dist/obsidian/vault-ingestion.js +77 -0
- package/node_modules/@ocean/services/dist/obsidian/vault-sync.js +73 -0
- package/node_modules/@ocean/services/dist/obsidian/vault-writer.js +75 -0
- package/node_modules/@ocean/services/package.json +11 -0
- package/ocean-marketplace.json +415 -0
- package/package.json +67 -4
- package/skills/core/business-logic/SKILL.md +22 -0
- package/skills/core/catch-up/SKILL.md +17 -0
- package/skills/core/core-thinking/SKILL.md +11 -0
- package/skills/core/design-thinking/SKILL.md +19 -0
- package/skills/core/graft/SKILL.md +156 -0
- package/skills/core/loop/SKILL.md +20 -0
- package/skills/core/session-handoff/SKILL.md +15 -0
- package/skills/core/use-browser/SKILL.md +69 -0
- package/skills/core/verification/SKILL.md +11 -0
- package/skills/index.json +56 -0
- package/templates/README.md +4 -0
- package/templates/profiles/default.json +51 -0
- package/templates/profiles/developer.json +51 -0
- package/templates/profiles/reviewer.json +51 -0
- package/templates/profiles/strategist.json +51 -0
- package/templates/workspace/00-inbox/INBOX.md +7 -0
- package/templates/workspace/00-inbox/candidates/.gitkeep +0 -0
- package/templates/workspace/00-inbox/native/.gitkeep +0 -0
- package/templates/workspace/01-daily/.gitkeep +0 -0
- package/templates/workspace/02-personal/CONFLICTS.md +7 -0
- package/templates/workspace/02-personal/MEMORY.md +15 -0
- package/templates/workspace/02-personal/goals/.gitkeep +0 -0
- package/templates/workspace/02-personal/identity/.gitkeep +0 -0
- package/templates/workspace/02-personal/preferences/.gitkeep +0 -0
- package/templates/workspace/03-professional/.gitkeep +0 -0
- package/templates/workspace/04-projects/PROJECTS.md +5 -0
- package/templates/workspace/04-projects/_template/docs/.gitkeep +0 -0
- package/templates/workspace/04-projects/_template/memory/.gitkeep +0 -0
- package/templates/workspace/04-projects/_template/tasks/.gitkeep +0 -0
- package/templates/workspace/05-knowledge/KNOWLEDGE.md +8 -0
- package/templates/workspace/05-knowledge/decisions/.gitkeep +0 -0
- package/templates/workspace/05-knowledge/lessons/.gitkeep +0 -0
- package/templates/workspace/06-templates/TEMPLATES.md +25 -0
- package/templates/workspace/06-templates/decision.md +8 -0
- package/templates/workspace/06-templates/intelligence.md +32 -0
- package/templates/workspace/06-templates/project-claude.md +48 -0
- package/templates/workspace/06-templates/session.md +38 -0
- package/templates/workspace/06-templates/task.md +42 -0
- package/templates/workspace/MANIFEST.json +51 -0
- package/templates/workspace/bridge/config/CONFIG.md +21 -0
- package/templates/workspace/bridge/config/runtime.json +4 -0
- package/templates/workspace/charter/core.md +104 -0
- package/templates/workspace/charter/policies/README.md +31 -0
- package/templates/workspace/charter/policies/claude-code-context.md +90 -0
- package/templates/workspace/charter/policies/concise-output.md +29 -0
- package/templates/workspace/charter/policies/context.md +91 -0
- package/templates/workspace/charter/policies/contracts/task.md +189 -0
- package/templates/workspace/charter/policies/git.md +60 -0
- package/templates/workspace/charter/policies/graph.md +47 -0
- package/templates/workspace/charter/policies/knowledge.md +33 -0
- package/templates/workspace/charter/policies/lifecycle.md +119 -0
- package/templates/workspace/charter/policies/memory.md +67 -0
- package/templates/workspace/charter/policies/minimal-change.md +43 -0
- package/templates/workspace/charter/policies/models.md +57 -0
- package/templates/workspace/charter/policies/privacy-terms.txt +3 -0
- package/templates/workspace/charter/policies/response.md +39 -0
- package/templates/workspace/charter/policies/skill-observer.md +44 -0
- package/templates/workspace/charter/policies/stack.md +23 -0
- package/templates/workspace/charter/policies/task.md +139 -0
- package/templates/workspace/charter/policies/verification.md +29 -0
- package/templates/workspace/sessions/.gitkeep +0 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { bootstrapEnvironment, buildOceanBootstrap, } from "@ocean/context/context/resource-injection.js";
|
|
4
|
+
import { profileIdentity, } from "@ocean/core/domain/profiles/profile.js";
|
|
5
|
+
import { validateRunContract } from "@ocean/core/domain/runs/run-contract.js";
|
|
6
|
+
import { validateSessionEntryContract } from "@ocean/core/domain/sessions/entry-contract.js";
|
|
7
|
+
import { oceanEnvPair } from "@ocean/core/shared/paths.js";
|
|
8
|
+
import { projectRules, resolveProject, } from "@ocean/core/shared/project-resolution.js";
|
|
9
|
+
import { boundProjectManifest } from "@ocean/loop/hooks/session-start-hook.js";
|
|
10
|
+
import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
11
|
+
import { authorizeRun } from "@ocean/loop/runs/run-authorization.js";
|
|
12
|
+
import { finalizeSession } from "@ocean/loop/sessions/session-closeout.js";
|
|
13
|
+
import { authAdapter, authLogin, authStatus, } from "../../application/auth/auth-orchestrator.js";
|
|
14
|
+
import { defaultAuthDeps } from "../../composition/runtime.js";
|
|
15
|
+
import { redactRuntimeText } from "../../infrastructure/observability/runtime-logger.js";
|
|
16
|
+
import { runInteractive, runPassthrough, } from "../../infrastructure/process/interactive-process.js";
|
|
17
|
+
import { findProvider, resolveOriginalExecutable, validateExplicitExecutable, } from "../../infrastructure/providers/provider-registry.js";
|
|
18
|
+
async function rulesCount(project) {
|
|
19
|
+
const { manifest } = await boundProjectManifest(project);
|
|
20
|
+
try {
|
|
21
|
+
return manifest ? projectRules(manifest).length : 0;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function intercept(command, args, options = {}) {
|
|
28
|
+
const provider = findProvider(command);
|
|
29
|
+
if (provider.enabled === false || isUtilityInvocation(provider.id, args)) {
|
|
30
|
+
const executable = options.originalExecutable
|
|
31
|
+
? validateExplicitExecutable(options.originalExecutable)
|
|
32
|
+
: resolveOriginalExecutable(provider.command);
|
|
33
|
+
const result = await runPassthrough({
|
|
34
|
+
command: executable,
|
|
35
|
+
args,
|
|
36
|
+
cwd: path.resolve(process.cwd()),
|
|
37
|
+
env: oceanEnvPair("INTERCEPTED", "1"),
|
|
38
|
+
});
|
|
39
|
+
return result.exitCode;
|
|
40
|
+
}
|
|
41
|
+
const entryPoint = options.entryPoint ??
|
|
42
|
+
(options.originalExecutable ? "desktop-wrapper" : "terminal-shim");
|
|
43
|
+
const controlLevel = options.controlLevel ??
|
|
44
|
+
(options.originalExecutable ? "managed-partial" : "observed");
|
|
45
|
+
const inputCapture = options.originalExecutable ? "none" : "bounded-terminal";
|
|
46
|
+
const sessionId = randomUUID();
|
|
47
|
+
const profile = interceptedProfile(provider.id);
|
|
48
|
+
const store = await openSessionStore();
|
|
49
|
+
const workingDirectory = path.resolve(process.cwd());
|
|
50
|
+
const projectResolution = await resolveProject(workingDirectory);
|
|
51
|
+
// The env bootstrap carries only the rules count; the rules themselves reach the client
|
|
52
|
+
// through its own session-start hook.
|
|
53
|
+
const bootstrap = buildOceanBootstrap(projectResolution, {
|
|
54
|
+
rules: await rulesCount(projectResolution),
|
|
55
|
+
});
|
|
56
|
+
const runId = randomUUID();
|
|
57
|
+
const contract = validateRunContract({
|
|
58
|
+
runId,
|
|
59
|
+
sessionId,
|
|
60
|
+
profile: profile.name,
|
|
61
|
+
workingDirectory,
|
|
62
|
+
allowedTools: [provider.command],
|
|
63
|
+
deniedTools: [],
|
|
64
|
+
stopConditions: ["provider-process-exits"],
|
|
65
|
+
approval: { required: false, approved: true },
|
|
66
|
+
budget: {
|
|
67
|
+
timeoutMs: 24 * 60 * 60 * 1000,
|
|
68
|
+
maxAttempts: 1,
|
|
69
|
+
maxOutputBytes: 64_000,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
store.create({
|
|
73
|
+
sessionId,
|
|
74
|
+
title: options.title ?? `${provider.id} session`,
|
|
75
|
+
taskId: options.taskId ?? null,
|
|
76
|
+
handoffId: options.handoffId ?? null,
|
|
77
|
+
provider: provider.id,
|
|
78
|
+
providerSessionId: null,
|
|
79
|
+
parentSessionId: null,
|
|
80
|
+
profile: profile.name,
|
|
81
|
+
profileIdentity: profileIdentity(profile),
|
|
82
|
+
workingDirectory,
|
|
83
|
+
resumeData: null,
|
|
84
|
+
projectId: projectResolution.status === "bound" ? projectResolution.projectId : null,
|
|
85
|
+
});
|
|
86
|
+
store.appendEvent(sessionId, "session_entry_contract", JSON.stringify(validateSessionEntryContract({
|
|
87
|
+
entryPoint,
|
|
88
|
+
controlLevel,
|
|
89
|
+
inputCapture,
|
|
90
|
+
contextTransport: options.originalExecutable
|
|
91
|
+
? "desktop-passthrough"
|
|
92
|
+
: bootstrap.manifest.transport,
|
|
93
|
+
policyEnforcement: "shim-lifecycle-and-provider-owned-policy",
|
|
94
|
+
promotion: "explicit-review",
|
|
95
|
+
resume: provider.id === "claude"
|
|
96
|
+
? "provider-owned-if-exposed"
|
|
97
|
+
: "unsupported",
|
|
98
|
+
})));
|
|
99
|
+
store.appendEvent(sessionId, "intercept_requested", JSON.stringify({
|
|
100
|
+
runId,
|
|
101
|
+
command: provider.command,
|
|
102
|
+
args: args.map(redactRuntimeText),
|
|
103
|
+
}));
|
|
104
|
+
if (options.handoffId)
|
|
105
|
+
store.appendEvent(sessionId, "handoff_bound", JSON.stringify({
|
|
106
|
+
handoffId: options.handoffId,
|
|
107
|
+
taskId: options.taskId ?? null,
|
|
108
|
+
}));
|
|
109
|
+
store.appendEvent(sessionId, "project_resolved", JSON.stringify({ workingDirectory, ...projectResolution }));
|
|
110
|
+
store.appendEvent(sessionId, "ocean_bootstrap", JSON.stringify({
|
|
111
|
+
provider: provider.id,
|
|
112
|
+
...bootstrap.manifest,
|
|
113
|
+
}));
|
|
114
|
+
try {
|
|
115
|
+
store.updateStatus(sessionId, "running");
|
|
116
|
+
authorizeRun(store, contract);
|
|
117
|
+
const executable = options.originalExecutable
|
|
118
|
+
? validateExplicitExecutable(options.originalExecutable)
|
|
119
|
+
: resolveOriginalExecutable(provider.command);
|
|
120
|
+
const authState = await authStatus(provider.id, defaultAuthDeps);
|
|
121
|
+
store.appendEvent(sessionId, "auth_state", JSON.stringify({ provider: provider.id, state: authState }));
|
|
122
|
+
if (authState === "login_required") {
|
|
123
|
+
store.appendEvent(sessionId, "auth_login_started", JSON.stringify({ provider: provider.id }));
|
|
124
|
+
const verifiedState = await authLogin(provider.id, defaultAuthDeps);
|
|
125
|
+
store.appendEvent(sessionId, "auth_state", JSON.stringify({ provider: provider.id, state: verifiedState }));
|
|
126
|
+
if (verifiedState !== "authenticated") {
|
|
127
|
+
store.updateStatus(sessionId, "failed");
|
|
128
|
+
store.appendEvent(sessionId, "evidence", JSON.stringify({
|
|
129
|
+
sessionId,
|
|
130
|
+
type: "auth",
|
|
131
|
+
source: "ocean-interceptor",
|
|
132
|
+
result: "blocked_by_client_authentication",
|
|
133
|
+
criterion: "provider login did not verify successfully",
|
|
134
|
+
}));
|
|
135
|
+
await finalizeSession(store, sessionId, { exitCode: 1 });
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
store.appendEvent(sessionId, "provider_resolved", JSON.stringify({ executable, runtime: "direct" }));
|
|
140
|
+
const processRequest = {
|
|
141
|
+
command: provider.command,
|
|
142
|
+
args,
|
|
143
|
+
cwd: workingDirectory,
|
|
144
|
+
environment: {
|
|
145
|
+
...oceanEnvPair("INTERCEPTED", "1"),
|
|
146
|
+
...bootstrapEnvironment(bootstrap),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
const runProvider = async (signal) => await (options.originalExecutable ? runPassthrough : runInteractive)({
|
|
150
|
+
command: executable,
|
|
151
|
+
args,
|
|
152
|
+
cwd: workingDirectory,
|
|
153
|
+
env: processRequest.environment,
|
|
154
|
+
signal,
|
|
155
|
+
onData: (data) => store.appendEvent(sessionId, "provider_output", redactRuntimeText(data)),
|
|
156
|
+
onInput: (data) => store.appendEvent(sessionId, "terminal_input", redactRuntimeText(data)),
|
|
157
|
+
});
|
|
158
|
+
const abortController = new AbortController();
|
|
159
|
+
let terminationSignal;
|
|
160
|
+
const onTermination = (signal) => {
|
|
161
|
+
terminationSignal = signal;
|
|
162
|
+
abortController.abort();
|
|
163
|
+
};
|
|
164
|
+
process.once("SIGINT", onTermination);
|
|
165
|
+
process.once("SIGTERM", onTermination);
|
|
166
|
+
let result;
|
|
167
|
+
try {
|
|
168
|
+
result = await runProvider(abortController.signal);
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
process.off("SIGINT", onTermination);
|
|
172
|
+
process.off("SIGTERM", onTermination);
|
|
173
|
+
}
|
|
174
|
+
const exitCode = terminationSignal
|
|
175
|
+
? terminationSignal === "SIGINT"
|
|
176
|
+
? 130
|
|
177
|
+
: 143
|
|
178
|
+
: result.exitCode;
|
|
179
|
+
let evidence = classifyProviderResult(exitCode, result.output);
|
|
180
|
+
if (evidence.result === "blocked_by_client_authentication" &&
|
|
181
|
+
authAdapter(provider.id)) {
|
|
182
|
+
store.appendEvent(sessionId, "auth_recovery_started", JSON.stringify({ provider: provider.id, reason: evidence.criterion }));
|
|
183
|
+
const recoveredState = await authLogin(provider.id, defaultAuthDeps);
|
|
184
|
+
store.appendEvent(sessionId, "auth_state", JSON.stringify({
|
|
185
|
+
provider: provider.id,
|
|
186
|
+
state: recoveredState,
|
|
187
|
+
phase: "recovery",
|
|
188
|
+
}));
|
|
189
|
+
if (recoveredState === "authenticated") {
|
|
190
|
+
store.appendEvent(sessionId, "run_resumed", JSON.stringify({
|
|
191
|
+
provider: provider.id,
|
|
192
|
+
reason: "authentication verified",
|
|
193
|
+
}));
|
|
194
|
+
result = await runProvider(new AbortController().signal);
|
|
195
|
+
if (result.output)
|
|
196
|
+
store.appendEvent(sessionId, "provider_output", redactRuntimeText(result.output));
|
|
197
|
+
evidence = classifyProviderResult(result.exitCode, result.output);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const finalExitCode = terminationSignal ? exitCode : result.exitCode;
|
|
201
|
+
const status = finalExitCode === 0 ? "completed" : "failed";
|
|
202
|
+
store.updateStatus(sessionId, status);
|
|
203
|
+
store.appendEvent(sessionId, "process_exit", JSON.stringify({
|
|
204
|
+
exitCode: finalExitCode,
|
|
205
|
+
signal: terminationSignal ?? null,
|
|
206
|
+
}));
|
|
207
|
+
if (evidence.result === "blocked_by_client_authentication") {
|
|
208
|
+
store.appendEvent(sessionId, "provider_blocked", JSON.stringify({ reason: evidence.criterion }));
|
|
209
|
+
}
|
|
210
|
+
store.appendEvent(sessionId, "evidence", JSON.stringify({
|
|
211
|
+
sessionId,
|
|
212
|
+
type: "provider_exit",
|
|
213
|
+
source: "ocean-interceptor",
|
|
214
|
+
result: evidence.result,
|
|
215
|
+
criterion: evidence.criterion,
|
|
216
|
+
}));
|
|
217
|
+
store.scanCaptureItems(sessionId);
|
|
218
|
+
await finalizeSession(store, sessionId, {
|
|
219
|
+
exitCode: finalExitCode,
|
|
220
|
+
nextAction: terminationSignal
|
|
221
|
+
? `Session ended by ${terminationSignal}.`
|
|
222
|
+
: undefined,
|
|
223
|
+
});
|
|
224
|
+
return finalExitCode;
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
store.updateStatus(sessionId, "failed");
|
|
228
|
+
store.appendEvent(sessionId, "error", redactRuntimeText(error instanceof Error ? error.message : String(error)));
|
|
229
|
+
await finalizeSession(store, sessionId, { exitCode: 1 });
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
store.close();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const UTILITY_FLAGS = new Set(["--help", "-h", "--version", "-v", "-V"]);
|
|
237
|
+
// Management subcommands that never start a working session. `attach` and
|
|
238
|
+
// `ultrareview` are excluded on purpose: both are real work.
|
|
239
|
+
const UTILITY_SUBCOMMANDS = {
|
|
240
|
+
claude: new Set([
|
|
241
|
+
"agents",
|
|
242
|
+
"auth",
|
|
243
|
+
"auto-mode",
|
|
244
|
+
"doctor",
|
|
245
|
+
"gateway",
|
|
246
|
+
"import",
|
|
247
|
+
"install",
|
|
248
|
+
"logs",
|
|
249
|
+
"mcp",
|
|
250
|
+
"plugin",
|
|
251
|
+
"plugins",
|
|
252
|
+
"project",
|
|
253
|
+
"respawn",
|
|
254
|
+
"rm",
|
|
255
|
+
"setup-token",
|
|
256
|
+
"stop",
|
|
257
|
+
"kill",
|
|
258
|
+
"update",
|
|
259
|
+
"upgrade",
|
|
260
|
+
]),
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* True when an invocation is a lookup or management command (a version check,
|
|
264
|
+
* `claude agents --json` polled by a desktop client, `claude mcp list`) rather
|
|
265
|
+
* than a working session. These run straight through without a session record,
|
|
266
|
+
* which otherwise floods the store with hundreds of empty summaries a day.
|
|
267
|
+
*/
|
|
268
|
+
export function isUtilityInvocation(providerId, args) {
|
|
269
|
+
const first = args[0];
|
|
270
|
+
if (first === undefined)
|
|
271
|
+
return false;
|
|
272
|
+
if (args.length === 1 && UTILITY_FLAGS.has(first))
|
|
273
|
+
return true;
|
|
274
|
+
return UTILITY_SUBCOMMANDS[providerId]?.has(first) ?? false;
|
|
275
|
+
}
|
|
276
|
+
function classifyProviderResult(exitCode, output) {
|
|
277
|
+
if (exitCode === 0)
|
|
278
|
+
return {
|
|
279
|
+
result: "proven",
|
|
280
|
+
criterion: "intercepted provider process exits successfully",
|
|
281
|
+
};
|
|
282
|
+
if (/401\s+Unauthorized|missing bearer|not logged in|sign in to use/i.test(output)) {
|
|
283
|
+
return {
|
|
284
|
+
result: "blocked_by_client_authentication",
|
|
285
|
+
criterion: "provider authentication is required",
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
result: "not_proven",
|
|
290
|
+
criterion: "intercepted provider process exits successfully",
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function interceptedProfile(provider) {
|
|
294
|
+
return {
|
|
295
|
+
schemaVersion: 1,
|
|
296
|
+
name: `intercepted:${provider}`,
|
|
297
|
+
description: "Ocean transparent CLI interception profile",
|
|
298
|
+
version: "1.0.0",
|
|
299
|
+
provider: provider,
|
|
300
|
+
model: "provider-managed",
|
|
301
|
+
role: "intercepted worker",
|
|
302
|
+
skills: [],
|
|
303
|
+
allowedPaths: ["."],
|
|
304
|
+
allowedCommands: [],
|
|
305
|
+
writePolicy: "none",
|
|
306
|
+
contextSources: [],
|
|
307
|
+
clients: {
|
|
308
|
+
[provider]: { enabled: true, capabilities: [], limitations: [] },
|
|
309
|
+
},
|
|
310
|
+
defaultClient: provider,
|
|
311
|
+
memory: { enabled: true, scope: "profile" },
|
|
312
|
+
verification: { commands: [] },
|
|
313
|
+
contextCompression: "none",
|
|
314
|
+
instructions: "",
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=intercept-command.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { oceanRoot } from "@ocean/core/shared/paths.js";
|
|
2
|
+
import { applyLayout, rollbackLayout, } from "../../application/layout/layout-apply.js";
|
|
3
|
+
import { planLayout } from "../../application/layout/layout-plan.js";
|
|
4
|
+
const USAGE = "Usage: ocean layout plan | apply --yes | rollback --yes";
|
|
5
|
+
export async function runLayoutCommand(args) {
|
|
6
|
+
// Built and rehearsed for the macOS/Linux workspace (HOME-relative pointers, POSIX symlinks and
|
|
7
|
+
// modes); on Windows the home folder, links and permissions behave differently and are untested.
|
|
8
|
+
if (process.platform === "win32")
|
|
9
|
+
throw new Error("ocean layout supports macOS and Linux only.");
|
|
10
|
+
const action = args[0] ?? "plan";
|
|
11
|
+
const confirmed = args.includes("--yes");
|
|
12
|
+
const print = (value) => console.log(JSON.stringify(value, null, 2));
|
|
13
|
+
if (action === "plan")
|
|
14
|
+
return print(await planLayout(oceanRoot()));
|
|
15
|
+
if (action !== "apply" && action !== "rollback")
|
|
16
|
+
throw new Error(USAGE);
|
|
17
|
+
// Both write outside the workspace (client config, shell files), so neither runs by accident.
|
|
18
|
+
if (!confirmed) {
|
|
19
|
+
print(await planLayout(oceanRoot()));
|
|
20
|
+
throw new Error(`ocean layout ${action} changes files outside the workspace; review the plan above, then re-run with --yes.`);
|
|
21
|
+
}
|
|
22
|
+
if (action === "apply")
|
|
23
|
+
print(await applyLayout(oceanRoot()));
|
|
24
|
+
else
|
|
25
|
+
print(await rollbackLayout(oceanRoot()));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=layout-command.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createDefaultMarketplace, marketplacePaths, } from "@ocean/market/install/default-marketplace.js";
|
|
2
|
+
import { runInstalledMcp } from "@ocean/market/mcp/mcp-runner.js";
|
|
3
|
+
const usage = "Usage: ocean market list|install <name> [--version <v>]|update <name>|uninstall <name>|exec <name> [--index <file>]... [--yes] [--accept-flagged]";
|
|
4
|
+
function flagValues(args, flag) {
|
|
5
|
+
return args.flatMap((arg, index) => arg === flag && args[index + 1] ? [args[index + 1]] : []);
|
|
6
|
+
}
|
|
7
|
+
export async function runMarketCommand(action, args) {
|
|
8
|
+
const approved = args.includes("--yes");
|
|
9
|
+
const marketplace = createDefaultMarketplace({
|
|
10
|
+
indexFiles: flagValues(args, "--index"),
|
|
11
|
+
acceptFlagged: args.includes("--accept-flagged"),
|
|
12
|
+
// Non-interactive: permissions are granted only by an explicit --yes, and are always shown.
|
|
13
|
+
consent: async (manifest) => {
|
|
14
|
+
console.error(`${manifest.name}@${manifest.version} requests permissions: ${JSON.stringify(manifest.permissions)}`);
|
|
15
|
+
if (!approved)
|
|
16
|
+
console.error("Re-run with --yes to grant them.");
|
|
17
|
+
return approved;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const name = args.find((arg, index) => !arg.startsWith("--") &&
|
|
21
|
+
!["--index", "--version"].includes(args[index - 1]));
|
|
22
|
+
if (action === "list") {
|
|
23
|
+
const installed = await marketplace.installed();
|
|
24
|
+
console.log(JSON.stringify(Object.entries(installed).map(([id, entry]) => ({
|
|
25
|
+
name: id,
|
|
26
|
+
kind: entry.manifest.kind,
|
|
27
|
+
version: entry.manifest.version,
|
|
28
|
+
sha256: entry.manifest.integrity.sha256,
|
|
29
|
+
installedAt: entry.installedAt,
|
|
30
|
+
})), null, 2));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (action === "exec" && name) {
|
|
34
|
+
const paths = marketplacePaths();
|
|
35
|
+
process.exitCode = await runInstalledMcp(name, {
|
|
36
|
+
serversRoot: paths.mcpServers,
|
|
37
|
+
stateRoot: paths.mcpState,
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!name || !["install", "update", "uninstall"].includes(action))
|
|
42
|
+
throw new Error(usage);
|
|
43
|
+
if (action === "install")
|
|
44
|
+
console.log(JSON.stringify(await marketplace.install(name, flagValues(args, "--version")[0]), null, 2));
|
|
45
|
+
else if (action === "update")
|
|
46
|
+
console.log(JSON.stringify(await marketplace.update(name), null, 2));
|
|
47
|
+
else {
|
|
48
|
+
await marketplace.uninstall(name);
|
|
49
|
+
console.log(JSON.stringify({ name, status: "uninstalled" }, null, 2));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=market-command.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { marketplacePaths } from "@ocean/market/install/default-marketplace.js";
|
|
2
|
+
import { gatewayMembers, McpGateway, serveMcpGateway, } from "@ocean/market/mcp/mcp-gateway.js";
|
|
3
|
+
import { McpClient } from "@ocean/services/infrastructure/mcp/mcp-client.js";
|
|
4
|
+
import { oceanVersion } from "../../version.js";
|
|
5
|
+
// `ocean mcp gateway`: one stdio MCP endpoint for every registered server. Logs go to stderr,
|
|
6
|
+
// which MCP clients keep as the server's log.
|
|
7
|
+
export async function runMcpGatewayCommand() {
|
|
8
|
+
const log = (line) => console.error(`ocean mcp gateway: ${line}`);
|
|
9
|
+
const paths = marketplacePaths();
|
|
10
|
+
const { members, skipped } = await gatewayMembers({
|
|
11
|
+
serversRoot: paths.mcpServers,
|
|
12
|
+
stateRoot: paths.mcpState,
|
|
13
|
+
});
|
|
14
|
+
for (const skip of skipped)
|
|
15
|
+
log(`${skip.capability} not routed: ${skip.reason}`);
|
|
16
|
+
const gateway = new McpGateway(members, {
|
|
17
|
+
client: (member) => new McpClient({
|
|
18
|
+
command: member.command,
|
|
19
|
+
args: member.args,
|
|
20
|
+
cwd: member.cwd,
|
|
21
|
+
env: member.env,
|
|
22
|
+
inheritEnv: member.inheritEnv,
|
|
23
|
+
stderrLabel: `ocean mcp gateway [${member.capability}]`,
|
|
24
|
+
}),
|
|
25
|
+
version: await oceanVersion(),
|
|
26
|
+
log,
|
|
27
|
+
});
|
|
28
|
+
await serveMcpGateway(gateway);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=mcp-gateway-command.js.map
|