@amoree-code/ocean 2.10.0 → 2.12.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.
Files changed (27) hide show
  1. package/README.md +3 -2
  2. package/dist/interfaces/cli/browser-command.js +13 -2
  3. package/dist/interfaces/cli/browser-findings.js +18 -1
  4. package/dist/interfaces/cli/browser-settings.js +173 -0
  5. package/dist/interfaces/cli/command-registry.js +7 -1
  6. package/dist/interfaces/cli/failures-command.js +71 -0
  7. package/dist/interfaces/cli/help-command.js +7 -3
  8. package/dist/interfaces/cli/scorecard-command.js +15 -1
  9. package/dist/interfaces/cli/telemetry-command.js +23 -3
  10. package/market/mcp/chrome-devtools/ocean.capability.json +54 -5
  11. package/market/mcp/firefox-devtools/ocean.capability.json +71 -0
  12. package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +3 -1
  13. package/node_modules/@ocean/brain/package.json +1 -1
  14. package/node_modules/@ocean/context/package.json +1 -1
  15. package/node_modules/@ocean/core/package.json +1 -1
  16. package/node_modules/@ocean/loop/dist/runs/run-agent.js +3 -1
  17. package/node_modules/@ocean/loop/package.json +1 -1
  18. package/node_modules/@ocean/market/package.json +1 -1
  19. package/node_modules/@ocean/services/dist/journey/failures.js +252 -0
  20. package/node_modules/@ocean/services/dist/journey/lesson-effect.js +79 -0
  21. package/node_modules/@ocean/services/dist/journey/telemetry.js +63 -19
  22. package/node_modules/@ocean/services/dist/scorecard/scorecard.js +30 -7
  23. package/node_modules/@ocean/services/package.json +1 -1
  24. package/ocean-marketplace.json +186 -40
  25. package/package.json +7 -7
  26. package/skills/core/use-browser/SKILL.md +23 -12
  27. package/skills/index.json +1 -1
package/README.md CHANGED
@@ -168,8 +168,9 @@ prints its usage and never runs it. To hand `--help` to a wrapped client, put it
168
168
  | `ocean rhythm` | the day's rhythm, once per period and with no model: morning note, harvest, archive, last week's digest, last month's review, then the nightly upkeep (the service runs it) | Writes |
169
169
  | `ocean upkeep` | the nightly jobs with no model — doctor, telemetry, reindex, search eval, drift, curator, scorecard, and memory hygiene once a month — then the morning digest in `01-daily/digest/` | Writes with `--yes` |
170
170
  | `ocean curator` | marks lessons and skills stale after 30 days unused (or 90 unreviewed) and archives them after 90; `review` undoes a mark | Writes with `--yes` |
171
- | `ocean telemetry` | recurring session errors and failing providers, as proposed backlog lines | Writes |
172
- | `ocean scorecard` | Ocean's health numbers from real data: clients working, sessions verified and linked to tasks, attributed memory writes, search mode, schedules, lessons | Reads; `--write` saves `01-daily/scorecard/` |
171
+ | `ocean telemetry` | recurring session errors (each named by a signature) and failing providers, as proposed backlog lines; also proposes a guardrail climb for an absorbed failure that came back and retiring a lesson that does no better than without it | Writes |
172
+ | `ocean failures` | failure records by signature in `05-knowledge/failures/`: status `open → fix-landing → absorbed → superseded-by`, guardrail ladder `lesson → doctor → test`, recurrence counted from sessions | Reads; `open`, `status`, `climb` write |
173
+ | `ocean scorecard` | Ocean's health numbers from real data: clients working, sessions verified and linked to tasks, attributed memory writes, search mode, schedules, lessons applied, failures at zero | Reads; `--write` saves `01-daily/scorecard/` |
173
174
  | `ocean express` | draft a CV section, LinkedIn post or scholarship paragraph from milestones | Writes |
174
175
  | `ocean handoff` | hand work from one session or client to another | Reads; `create` writes |
175
176
  | `ocean daily` | the morning half of today's note: focus, coming up, open loops, your hours, what waits on you, the brief | Reads; `--apply` writes |
@@ -5,6 +5,7 @@ import { BrowserService, } from "@ocean/services/browser/browser-service.js";
5
5
  import { BrowserSessionManager, browserDownloadsPath, } from "@ocean/services/browser/browser-session.js";
6
6
  import { BrowserTaskRunner } from "@ocean/services/browser/browser-task-runner.js";
7
7
  import { PlaywrightBrowserProvider } from "../../infrastructure/providers/playwright-browser-provider.js";
8
+ import { browserBlocklist, browserConnection, browserProfile, browserUsage, useFirefox, } from "./browser-settings.js";
8
9
  // `ocean browser use <name|path>`: which Chromium browser `dev.ocean/chrome-devtools` attaches
9
10
  // to, stored on this machine (macOS keychain) and read by every client's launch. `use chrome`
10
11
  // clears it back to the default. `ocean browser attach` lists what can be attached right now.
@@ -20,8 +21,10 @@ async function runBrowserChoice(action, args) {
20
21
  });
21
22
  }
22
23
  const choice = args[0];
24
+ if (choice?.toLowerCase() === "firefox")
25
+ return print(useFirefox(store));
23
26
  if (!choice)
24
- throw new Error(`Usage: ocean browser use <${CHROMIUM_BROWSERS.map((each) => each.id).join("|")}|/absolute/profile/path>`);
27
+ throw new Error(`Usage: ocean browser use <${CHROMIUM_BROWSERS.map((each) => each.id).join("|")}|firefox|/absolute/profile/path>`);
25
28
  const root = resolveBrowserChoice(choice);
26
29
  if (root === browserProfileRoot("chrome"))
27
30
  store.remove(BROWSER_CAPABILITY, BROWSER_PROFILE_VARIABLE);
@@ -37,6 +40,14 @@ async function runBrowserChoice(action, args) {
37
40
  export async function runBrowserCommand(action, args) {
38
41
  if (action === "use" || action === "attach")
39
42
  return runBrowserChoice(action, args);
43
+ if (action === "profile")
44
+ return print(browserProfile(keychainStore(), args[0]));
45
+ if (action === "block")
46
+ return print(browserBlocklist(keychainStore(), args[0], args[1]));
47
+ if (action === "usage")
48
+ return print(browserUsage(undefined, { days: numberFlag(args, "--days") }));
49
+ if (action === "status" || action === "stop")
50
+ return browserConnection(action);
40
51
  const store = await openSessionStore();
41
52
  const manager = new BrowserSessionManager(store, new BrowserService(new PlaywrightBrowserProvider()));
42
53
  const runner = new BrowserTaskRunner(manager);
@@ -147,6 +158,6 @@ function print(value) {
147
158
  console.log(JSON.stringify(value, null, 2));
148
159
  }
149
160
  function usage() {
150
- console.error("Usage: ocean browser use|attach|detect|open|show|events|close|approve|navigate|read|observe|extract|click|type|replace-text|select|scroll|wait|upload|download|submit|run");
161
+ console.error("Usage: ocean browser use|attach|profile|block|usage|status|stop|detect|open|show|events|close|approve|navigate|read|observe|extract|click|type|replace-text|select|scroll|wait|upload|download|submit|run");
151
162
  }
152
163
  //# sourceMappingURL=browser-command.js.map
@@ -1,4 +1,4 @@
1
- import { existsSync } from "node:fs";
1
+ import { existsSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { mcpServerFile } from "@ocean/market/adapters/mcp-adapter.js";
4
4
  import { marketplacePaths } from "@ocean/market/install/default-marketplace.js";
@@ -9,6 +9,20 @@ export const BROWSER_CAPABILITIES = [
9
9
  "dev.ocean/chrome-devtools",
10
10
  "dev.ocean/browser",
11
11
  ];
12
+ // chrome-devtools-mcp attaches with --autoConnect, which needs the inspect page's remote
13
+ // debugging switch: Chromium 144 or later.
14
+ export const MIN_AUTO_CONNECT_MAJOR = 144;
15
+ // The Chromium major the browser last ran, from the `Last Version` file it keeps in its profile
16
+ // root (Brave writes the Chromium version there too). No DevTools connection, so no prompt.
17
+ export function browserMajorVersion(root) {
18
+ try {
19
+ const major = Number.parseInt(readFileSync(path.join(root, "Last Version"), "utf8"), 10);
20
+ return Number.isInteger(major) ? major : undefined;
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
12
26
  // `ocean doctor`: once a browser capability is installed, whether the chosen browser is there
13
27
  // to attach to — and, when it is not, whether another Chromium browser is. Nothing installed is
14
28
  // nothing to report.
@@ -26,6 +40,9 @@ export async function browserFindings(options = {}) {
26
40
  stored: () => keychainStore().get(BROWSER_CAPABILITY, BROWSER_PROFILE_VARIABLE),
27
41
  });
28
42
  const label = browserLabel(root);
43
+ const major = (options.major ?? browserMajorVersion)(root);
44
+ if (major !== undefined && major < MIN_AUTO_CONNECT_MAJOR)
45
+ return finding("WARN", `${label} is on Chromium ${major}; attaching needs ${MIN_AUTO_CONNECT_MAJOR} or later: update the browser`);
29
46
  if (await probe(path.join(root, "DevToolsActivePort")))
30
47
  return finding("OK", `${installed.join(", ")} installed and ${label} debugging is listening`);
31
48
  const other = (await listeningBrowsers({ listening: probe })).find((each) => each.root !== root);
@@ -0,0 +1,173 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { mcpServerFile } from "@ocean/market/adapters/mcp-adapter.js";
6
+ import { marketplacePaths } from "@ocean/market/install/default-marketplace.js";
7
+ import { BROWSER_CAPABILITY } from "@ocean/market/mcp/chrome-debugging.js";
8
+ // Settings of ocean-browser-mcp (T-324), stored like `ocean browser use`: one value per
9
+ // variable in the secret store, read by every client's launch of `dev.ocean/chrome-devtools`.
10
+ // Restart open clients after a change.
11
+ export const PROFILE_VARIABLE = "OCEAN_BROWSER_PROFILE";
12
+ export const BLOCKED_VARIABLE = "OCEAN_BROWSER_BLOCKED";
13
+ export const BROWSER_PROFILES = ["standard", "full", "lean", "slim"];
14
+ const DEFAULT_PROFILE = "standard";
15
+ // `dev.ocean/firefox-devtools` keeps its own profile folder once `ocean browser use firefox`
16
+ // names one; unset, Mozilla's server starts a fresh temporary profile each run.
17
+ export const FIREFOX_CAPABILITY = "dev.ocean/firefox-devtools";
18
+ export const FIREFOX_PROFILE_VARIABLE = "OCEAN_FIREFOX_PROFILE";
19
+ export function firefoxProfileDir(env = process.env) {
20
+ const base = env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
21
+ return path.join(base, "ocean-firefox", "profile");
22
+ }
23
+ export function useFirefox(store, env = process.env) {
24
+ const profile = firefoxProfileDir(env);
25
+ store.set(FIREFOX_CAPABILITY, FIREFOX_PROFILE_VARIABLE, profile);
26
+ return {
27
+ browser: "Firefox",
28
+ capability: FIREFOX_CAPABILITY,
29
+ profile,
30
+ in: store.name,
31
+ next: `ocean market add ${FIREFOX_CAPABILITY} (once), then restart open clients. To drive your own running Firefox instead, start it with --marionette --remote-debugging-port and set CONNECT_EXISTING=true.`,
32
+ };
33
+ }
34
+ // `ocean browser profile [standard|full|lean|slim]`: which tools clients see.
35
+ export function browserProfile(store, name) {
36
+ if (name !== undefined) {
37
+ const chosen = name.trim().toLowerCase();
38
+ if (!BROWSER_PROFILES.includes(chosen))
39
+ throw new Error(`Usage: ocean browser profile <${BROWSER_PROFILES.join("|")}>`);
40
+ if (chosen === DEFAULT_PROFILE)
41
+ store.remove(BROWSER_CAPABILITY, PROFILE_VARIABLE);
42
+ else
43
+ store.set(BROWSER_CAPABILITY, PROFILE_VARIABLE, chosen);
44
+ }
45
+ return {
46
+ profile: store.get(BROWSER_CAPABILITY, PROFILE_VARIABLE) ?? DEFAULT_PROFILE,
47
+ profiles: {
48
+ standard: "default: browsing, forms, network, console, Lighthouse, traces",
49
+ full: "every upstream tool",
50
+ lean: "browsing only: no performance, emulation, CSS or drag tools",
51
+ slim: "3 tools: navigate, evaluate, screenshot",
52
+ },
53
+ ...(name === undefined ? {} : { next: "restart open clients" }),
54
+ };
55
+ }
56
+ // `ocean browser block [list|add <pattern>|rm <pattern>]`: URL patterns
57
+ // (https://urlpattern.spec.whatwg.org/) the browser refuses while an agent is attached.
58
+ // Stored comma-separated: the keychain's command form keeps a value on one line.
59
+ export function browserBlocklist(store, action = "list", pattern) {
60
+ const read = () => (store.get(BROWSER_CAPABILITY, BLOCKED_VARIABLE) ?? "")
61
+ .split(/[\n,]/)
62
+ .map((each) => each.trim())
63
+ .filter(Boolean);
64
+ let patterns = read();
65
+ if (action === "add" || action === "rm") {
66
+ const value = pattern?.trim();
67
+ if (!value || value.includes(","))
68
+ throw new Error(`Usage: ocean browser block ${action} <url-pattern> (no commas), e.g. https://*.mybank.com/*`);
69
+ patterns =
70
+ action === "add"
71
+ ? [...new Set([...patterns, value])]
72
+ : patterns.filter((each) => each !== value);
73
+ if (patterns.length)
74
+ store.set(BROWSER_CAPABILITY, BLOCKED_VARIABLE, patterns.join(","));
75
+ else
76
+ store.remove(BROWSER_CAPABILITY, BLOCKED_VARIABLE);
77
+ }
78
+ else if (action !== "list")
79
+ throw new Error("Usage: ocean browser block list|add|rm <url-pattern>");
80
+ return {
81
+ blocked: patterns,
82
+ ...(action === "list" ? {} : { next: "restart open clients" }),
83
+ };
84
+ }
85
+ // The wrapper's own state folder (usage log, screenshot previews); same rule as its stateDir().
86
+ export function browserStateDir(env = process.env) {
87
+ if (env.OCEAN_BROWSER_STATE_DIR)
88
+ return env.OCEAN_BROWSER_STATE_DIR;
89
+ const base = env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
90
+ return path.join(base, "ocean-browser-mcp");
91
+ }
92
+ // `ocean browser usage [--days N]`: totals per tool from the wrapper's usage log. Text is
93
+ // counted in characters (about 4 per token); images in KB as sent.
94
+ export function browserUsage(dir = browserStateDir(), options = {}) {
95
+ const now = options.now ?? Date.now();
96
+ const since = options.days ? now - options.days * 86_400_000 : 0;
97
+ const lines = [];
98
+ for (const file of ["usage.1.jsonl", "usage.jsonl"]) {
99
+ const full = path.join(dir, file);
100
+ if (!existsSync(full))
101
+ continue;
102
+ for (const raw of readFileSync(full, "utf8").split("\n")) {
103
+ if (!raw.trim())
104
+ continue;
105
+ try {
106
+ const line = JSON.parse(raw);
107
+ if (line.tool && (!since || Date.parse(line.t ?? "") >= since))
108
+ lines.push(line);
109
+ }
110
+ catch {
111
+ // A line cut by a crash is skipped.
112
+ }
113
+ }
114
+ }
115
+ const tools = new Map();
116
+ for (const line of lines) {
117
+ const row = tools.get(line.tool) ?? {
118
+ calls: 0,
119
+ chars: 0,
120
+ imageKB: 0,
121
+ ms: 0,
122
+ errors: 0,
123
+ };
124
+ row.calls += 1;
125
+ row.chars += line.chars ?? 0;
126
+ row.imageKB += line.imageKB ?? 0;
127
+ row.ms += line.ms ?? 0;
128
+ if (line.error)
129
+ row.errors += 1;
130
+ tools.set(line.tool, row);
131
+ }
132
+ const rows = [...tools.entries()]
133
+ .map(([tool, row]) => ({
134
+ tool,
135
+ calls: row.calls,
136
+ textTokens: Math.round(row.chars / 4),
137
+ imageKB: Math.round(row.imageKB),
138
+ avgMs: Math.round(row.ms / row.calls),
139
+ errors: row.errors,
140
+ }))
141
+ .sort((a, b) => b.textTokens - a.textTokens);
142
+ return {
143
+ log: path.join(dir, "usage.jsonl"),
144
+ calls: lines.length,
145
+ textTokens: rows.reduce((sum, row) => sum + row.textTokens, 0),
146
+ imageKB: rows.reduce((sum, row) => sum + row.imageKB, 0),
147
+ since: lines[0]?.t,
148
+ tools: rows,
149
+ };
150
+ }
151
+ // The ocean-browser-mcp version the installed capability runs, so `status`/`stop` talk to the
152
+ // daemons that version started.
153
+ export function installedWrapperVersion(serversRoot = marketplacePaths().mcpServers) {
154
+ try {
155
+ const server = JSON.parse(readFileSync(mcpServerFile(serversRoot, BROWSER_CAPABILITY), "utf8"));
156
+ const found = (server?.server?.packages ?? server?.packages ?? []).find((each) => each?.identifier === "ocean-browser-mcp");
157
+ return found?.version;
158
+ }
159
+ catch {
160
+ return undefined;
161
+ }
162
+ }
163
+ // `ocean browser status|stop`: the wrapper lists or stops its shared background connections
164
+ // (the browser stays open; the next call reconnects and the browser asks to allow it again).
165
+ export function browserConnection(action) {
166
+ const version = installedWrapperVersion();
167
+ if (!version)
168
+ throw new Error(`${BROWSER_CAPABILITY} is not installed: ocean market add ${BROWSER_CAPABILITY}`);
169
+ const result = spawnSync("npx", ["-y", `ocean-browser-mcp@${version}`, action], { stdio: "inherit" });
170
+ if (result.status !== 0)
171
+ process.exitCode = result.status ?? 1;
172
+ }
173
+ //# sourceMappingURL=browser-settings.js.map
@@ -63,6 +63,7 @@ import { runDailyCommand } from "./daily-command.js";
63
63
  import { runDesktopCommand } from "./desktop-command.js";
64
64
  import { runDistillCommand } from "./distill-command.js";
65
65
  import { runExpressCommand } from "./express-command.js";
66
+ import { runFailuresCommand } from "./failures-command.js";
66
67
  import { gatewayFindings } from "./gateway-findings.js";
67
68
  import { runLifecycleCommand, runPolicyCommand } from "./governance-command.js";
68
69
  import { runHandoffCommand } from "./handoff-command.js";
@@ -980,7 +981,11 @@ async function commandSkill() {
980
981
  else {
981
982
  const store = await defaultSessionStoreFactory();
982
983
  try {
983
- console.log(JSON.stringify(await learnFromSession(store, sessionId), null, 2));
984
+ const learning = await learnFromSession(store, sessionId);
985
+ console.log(JSON.stringify(learning, null, 2));
986
+ // Lessons come only from verified sessions (T-323); say so instead of silently learning nothing.
987
+ if (!learning.score.verified)
988
+ console.error(`Session ${sessionId} is not verified: no lessons were learned from it.`);
984
989
  }
985
990
  finally {
986
991
  store.close();
@@ -1324,6 +1329,7 @@ export const commandRegistry = {
1324
1329
  harvest: () => runHarvestCommand(process.argv.slice(3)),
1325
1330
  rhythm: () => runRhythmCommand(process.argv.slice(3)),
1326
1331
  telemetry: () => runTelemetryCommand(process.argv.slice(3)),
1332
+ failures: () => runFailuresCommand(process.argv.slice(3)),
1327
1333
  scorecard: () => runScorecardCommand(process.argv.slice(3)),
1328
1334
  upkeep: () => runUpkeepCommand(process.argv.slice(3)),
1329
1335
  curator: () => runCuratorCommand(process.argv.slice(3)),
@@ -0,0 +1,71 @@
1
+ import { openSessionStoreReadOnly } from "@ocean/loop/infrastructure/persistence/session-store.js";
2
+ import { ABSORB_MECHANISMS, climbFailure, failureRecurrence, listFailures, openFailure, RECURRENCE_WINDOW_DAYS, setFailureStatus, } from "@ocean/services/journey/failures.js";
3
+ import { signatureStats } from "@ocean/services/journey/telemetry.js";
4
+ const USAGE = [
5
+ "Usage: ocean failures [list] [--json]",
6
+ " ocean failures open <id> <signature> --title <text> --mechanism <why it happens> [--lesson <id>] [--rung lesson|doctor|test] [--fix <text>] [--guardrail <text>]",
7
+ ` ocean failures status <id> fix-landing|open|absorbed --by ${ABSORB_MECHANISMS.join("|")}|superseded-by <id>`,
8
+ " ocean failures climb <id>",
9
+ ].join("\n");
10
+ function option(args, name) {
11
+ const at = args.indexOf(name);
12
+ return at >= 0 ? args[at + 1] : undefined;
13
+ }
14
+ // `ocean failures` (T-323): failure records in 05-knowledge/failures/, each tracked by its
15
+ // telemetry signature. Every change goes through code, one field at a time; `climb` is the
16
+ // owner's approval of a guardrail climb that telemetry proposed.
17
+ export async function runFailuresCommand(args) {
18
+ const [action = "list", id, ...rest] = args;
19
+ if (action === "list" || action === "--json") {
20
+ const store = await openSessionStoreReadOnly();
21
+ let recurrence;
22
+ try {
23
+ recurrence = failureRecurrence(await listFailures(), signatureStats(store.list(), (session) => store.listEvents(session), ""));
24
+ }
25
+ finally {
26
+ store.close();
27
+ }
28
+ if (args.includes("--json")) {
29
+ console.log(JSON.stringify(recurrence, null, 2));
30
+ return;
31
+ }
32
+ if (!recurrence.length)
33
+ console.log("No failure records with a signature.");
34
+ for (const entry of recurrence)
35
+ console.log(`${entry.id} ${entry.status} rung ${entry.rung} ${entry.recent} sessions in ${RECURRENCE_WINDOW_DAYS} d${entry.cleanDays === null ? "" : ` clean ${entry.cleanDays} d`} ${entry.signature}`);
36
+ return;
37
+ }
38
+ if (!id)
39
+ throw new Error(USAGE);
40
+ if (action === "open") {
41
+ const [signature] = rest;
42
+ const title = option(rest, "--title");
43
+ const mechanism = option(rest, "--mechanism");
44
+ if (!signature || !title || !mechanism)
45
+ throw new Error(USAGE);
46
+ console.log(JSON.stringify(await openFailure({
47
+ id,
48
+ title,
49
+ signature,
50
+ mechanism,
51
+ lesson: option(rest, "--lesson"),
52
+ rung: option(rest, "--rung"),
53
+ fix: option(rest, "--fix"),
54
+ guardrail: option(rest, "--guardrail"),
55
+ }), null, 2));
56
+ }
57
+ else if (action === "status") {
58
+ const [next, target] = rest;
59
+ if (!next)
60
+ throw new Error(USAGE);
61
+ const status = next === "superseded-by" && target
62
+ ? `superseded-by ${target}`
63
+ : next;
64
+ console.log(JSON.stringify(await setFailureStatus(id, status, { by: option(rest, "--by") }), null, 2));
65
+ }
66
+ else if (action === "climb")
67
+ console.log(JSON.stringify(await climbFailure(id), null, 2));
68
+ else
69
+ throw new Error(USAGE);
70
+ }
71
+ //# sourceMappingURL=failures-command.js.map
@@ -13,7 +13,7 @@ const commandGroups = [
13
13
  ],
14
14
  [
15
15
  "Knowledge",
16
- "memory, pull, desktop, observe, capture, note, brief, interests, distill, harvest, rhythm, upkeep, curator, telemetry, scorecard, express, handoff, idea, daily, skill, catalog",
16
+ "memory, pull, desktop, observe, capture, note, brief, interests, distill, harvest, rhythm, upkeep, curator, telemetry, failures, scorecard, express, handoff, idea, daily, skill, catalog",
17
17
  ],
18
18
  ["Integrations", "obsidian, hook, migrate, layout, env"],
19
19
  ];
@@ -134,7 +134,7 @@ export const commandHelp = {
134
134
  ],
135
135
  browser: [
136
136
  "Drive a browser session; uploads and submits need --approve.",
137
- "ocean browser use|attach|detect|open|show|events|close|approve|navigate|read|observe|extract|click|type|replace-text|select|scroll|wait|upload|download|submit|run",
137
+ "ocean browser use|attach|profile|block|usage|status|stop|detect|open|show|events|close|approve|navigate|read|observe|extract|click|type|replace-text|select|scroll|wait|upload|download|submit|run",
138
138
  ],
139
139
  memory: [
140
140
  "Search, read, review and maintain memory records and the brain index.",
@@ -185,9 +185,13 @@ export const commandHelp = {
185
185
  "ocean curator [--yes] | review <lesson:id|skill:name>",
186
186
  ],
187
187
  telemetry: [
188
- "Find recurring errors and failing providers in recent sessions; propose them as backlog lines.",
188
+ "Find recurring errors (by signature) and failing providers in recent sessions; propose them, guardrail climbs for absorbed failures that came back, and lessons that do not help, as backlog lines.",
189
189
  "ocean telemetry [--days N] [--yes]",
190
190
  ],
191
+ failures: [
192
+ "Failure records by signature: open -> fix-landing -> absorbed -> superseded-by; climb the guardrail ladder lesson -> doctor -> test.",
193
+ "ocean failures [list] [--json] | open <id> <signature> --title <t> --mechanism <why> [--lesson <id>] [--rung <r>] | status <id> <status> [--by <mechanism>] | climb <id>",
194
+ ],
191
195
  scorecard: [
192
196
  "Print Ocean's health numbers from real data; --write saves 01-daily/scorecard/YYYY-MM-DD.md.",
193
197
  "ocean scorecard [--json] [--write]",
@@ -4,6 +4,9 @@ import { readAudit } from "@ocean/brain/memory/memory-audit.js";
4
4
  import { localDate } from "@ocean/core/shared/local-date.js";
5
5
  import { openSessionStoreReadOnly } from "@ocean/loop/infrastructure/persistence/session-store.js";
6
6
  import { readDrift, readHygieneHistory, } from "@ocean/services/hygiene/hygiene.js";
7
+ import { failureRecurrence, listFailures, } from "@ocean/services/journey/failures.js";
8
+ import { appliedLessonIds } from "@ocean/services/journey/lesson-effect.js";
9
+ import { isFailureEvent, signatureStats, } from "@ocean/services/journey/telemetry.js";
7
10
  import { readLessonFrontmatter, readSearchEval, readTaskFrontmatter, renderTable, scorecardRows, sessionTokens, writeScorecard, } from "@ocean/services/scorecard/scorecard.js";
8
11
  import { clientFindings } from "../../application/clients/clients.js";
9
12
  import { CLIENT_ADAPTERS } from "../../application/clients/registry.js";
@@ -39,18 +42,27 @@ async function collect() {
39
42
  let sessions;
40
43
  const providers = new Map();
41
44
  const tokens = { sessions: 0, reporting: 0, total: 0 };
45
+ const applied = new Set();
46
+ let failures;
42
47
  try {
43
48
  const all = store.list();
44
49
  sessions = all;
45
50
  tokens.sessions = all.length;
51
+ // Only failure events are kept: the store holds far more than the signatures need.
52
+ const failed = new Map();
46
53
  for (const session of all) {
47
54
  providers.set(session.sessionId, session.provider);
48
- const used = sessionTokens(store.listEvents(session.sessionId));
55
+ const listed = store.listEvents(session.sessionId);
56
+ failed.set(session.sessionId, listed.filter((event) => isFailureEvent(event.type)));
57
+ for (const id of appliedLessonIds(listed))
58
+ applied.add(id);
59
+ const used = sessionTokens(listed);
49
60
  if (used === null)
50
61
  continue;
51
62
  tokens.reporting += 1;
52
63
  tokens.total += used;
53
64
  }
65
+ failures = failureRecurrence(await listFailures(), signatureStats(all, (id) => failed.get(id) ?? [], ""));
54
66
  }
55
67
  finally {
56
68
  store.close();
@@ -71,6 +83,8 @@ async function collect() {
71
83
  searchEval: await readSearchEval(),
72
84
  schedules: await listSchedules(),
73
85
  lessons: await readLessonFrontmatter(),
86
+ lessonsApplied: [...applied],
87
+ failures,
74
88
  tokens,
75
89
  hygiene: (await readHygieneHistory()).at(-1) ?? null,
76
90
  drift: await readDrift().then((drift) => drift
@@ -1,7 +1,12 @@
1
1
  import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
2
- import { analyzeSessions, proposeTelemetry, } from "@ocean/services/journey/telemetry.js";
2
+ import { failureRecurrence, ladderFindings, listFailures, } from "@ocean/services/journey/failures.js";
3
+ import { lessonEffects, retirementFindings, } from "@ocean/services/journey/lesson-effect.js";
4
+ import { analyzeSessions, proposeTelemetry, signatureStats, } from "@ocean/services/journey/telemetry.js";
3
5
  // `ocean telemetry [--days N] [--yes]` (T-314): recurring errors and failing providers in the
4
6
  // last N days (30) of sessions, proposed as backlog lines for review; a dry run until --yes.
7
+ // T-323: each error carries its signature; one that already has a failure record is tracked
8
+ // there instead, an absorbed one that came back proposes a guardrail climb, and a lesson that
9
+ // does no better than without it is proposed for retirement.
5
10
  export async function runTelemetryCommand(args) {
6
11
  const at = args.indexOf("--days");
7
12
  const days = at >= 0 ? Number(args[at + 1]) : 30;
@@ -10,9 +15,24 @@ export async function runTelemetryCommand(args) {
10
15
  const since = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
11
16
  const store = await openSessionStore();
12
17
  try {
13
- const findings = analyzeSessions(store.list(), (id) => store.listEvents(id), since);
18
+ const sessions = store.list();
19
+ // Three passes read the same sessions; each is read from the store once.
20
+ const cache = new Map();
21
+ const eventsOf = (id) => {
22
+ const events = cache.get(id) ?? store.listEvents(id);
23
+ cache.set(id, events);
24
+ return events;
25
+ };
26
+ const records = await listFailures();
27
+ const tracked = new Set(records.map((record) => record.signature));
28
+ const recurrence = failureRecurrence(records, signatureStats(sessions, eventsOf, ""));
29
+ const findings = [
30
+ ...analyzeSessions(sessions, eventsOf, since).filter((finding) => !finding.signature || !tracked.has(finding.signature)),
31
+ ...ladderFindings(recurrence),
32
+ ...retirementFindings(lessonEffects(sessions, eventsOf, since, records)),
33
+ ];
14
34
  const result = await proposeTelemetry(findings, args.includes("--yes"));
15
- console.log(JSON.stringify({ findings, proposed: result }, null, 2));
35
+ console.log(JSON.stringify({ findings, failures: recurrence, proposed: result }, null, 2));
16
36
  if (!args.includes("--yes"))
17
37
  console.error("Dry run: pass --yes to propose them as backlog lines.");
18
38
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "kind": "mcp",
3
3
  "name": "dev.ocean/chrome-devtools",
4
- "description": "Control the owner's real, signed-in Chromium browser (Chrome by default; Brave, Edge, Arc, Vivaldi, Opera or Chromium through `ocean browser use`) through the ocean-browser-mcp package (pinned Chrome DevTools MCP): tabs, navigation, clicks, forms, uploads, screenshots, console and network errors. Reads every open tab and acts inside any signed-in session of the attached browser, for every client wired to it. The browser asks to allow each new connection. The filesystem permission is declared for consent but not enforced at runtime, and the npm package is pinned by version, not by digest.",
4
+ "description": "Control the owner's real, signed-in Chromium browser (Chrome by default; Brave, Edge, Arc, Vivaldi, Opera or Chromium through `ocean browser use`) through the ocean-browser-mcp package (pinned Chrome DevTools MCP): tabs, navigation, clicks, forms, uploads, screenshots, console and network errors. Reads every open tab and acts inside any signed-in session of the attached browser, for every client wired to it. The browser asks to allow the connection once: one background connection (disconnected after 8 idle hours) serves every session; a pointer and a blue frame show which tab the agent is using. Cookies and auth headers are redacted, file:// pages are refused, and URL patterns can be blocked. Writes a usage log (tool names and sizes, no URLs), screenshot previews and oversized page snapshots under ~/.local/state/ocean-browser-mcp (kept 7 days). The filesystem permission is declared for consent but not enforced at runtime, and the npm package is pinned by version, not by digest.",
5
5
  "permissions": {
6
6
  "filesystem": {
7
7
  "read": [
@@ -12,23 +12,32 @@
12
12
  "~/Library/Application Support/Vivaldi",
13
13
  "~/Library/Application Support/com.operasoftware.Opera",
14
14
  "~/Library/Application Support/Arc"
15
- ]
15
+ ],
16
+ "write": ["~/.local/state/ocean-browser-mcp"]
16
17
  },
17
18
  "network": ["registry.npmjs.org", "localhost", "127.0.0.1"],
18
19
  "env": [
19
20
  "CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS",
20
- "OCEAN_BROWSER_USER_DATA_DIR"
21
+ "OCEAN_BROWSER_USER_DATA_DIR",
22
+ "OCEAN_BROWSER_PROFILE",
23
+ "OCEAN_BROWSER_BLOCKED",
24
+ "OCEAN_BROWSER_CURSOR",
25
+ "OCEAN_BROWSER_PREVIEW",
26
+ "OCEAN_BROWSER_USAGE",
27
+ "OCEAN_BROWSER_SHARED",
28
+ "OCEAN_BROWSER_IDLE_MIN",
29
+ "OCEAN_BROWSER_SNAPSHOT_MAX_CHARS"
21
30
  ],
22
31
  "exec": ["npx"]
23
32
  },
24
33
  "server": {
25
34
  "name": "dev.ocean/chrome-devtools",
26
- "description": "ocean-browser-mcp runs Chrome DevTools MCP 1.12.0 attached to the owner's running Chromium browser, with usage statistics and CrUX lookups off, so page URLs stay on this machine.",
35
+ "description": "ocean-browser-mcp runs Chrome DevTools MCP 1.13.0 attached to the owner's running Chromium browser, with usage statistics and CrUX lookups off, so page URLs stay on this machine.",
27
36
  "packages": [
28
37
  {
29
38
  "registryType": "npm",
30
39
  "identifier": "ocean-browser-mcp",
31
- "version": "0.2.0",
40
+ "version": "0.3.0",
32
41
  "transport": {
33
42
  "type": "stdio"
34
43
  },
@@ -47,6 +56,46 @@
47
56
  "default": "1",
48
57
  "isRequired": false,
49
58
  "description": "Skips upstream's update check (an npm child process and a registry fetch) on every start; the version is pinned."
59
+ },
60
+ {
61
+ "name": "OCEAN_BROWSER_PROFILE",
62
+ "isRequired": false,
63
+ "description": "Tool profile: standard (default), full, lean or slim. Set with `ocean browser profile <name>`."
64
+ },
65
+ {
66
+ "name": "OCEAN_BROWSER_BLOCKED",
67
+ "isRequired": false,
68
+ "description": "URL patterns the browser refuses while attached, comma- or newline-separated. Set with `ocean browser block`."
69
+ },
70
+ {
71
+ "name": "OCEAN_BROWSER_CURSOR",
72
+ "isRequired": false,
73
+ "description": "0 hides the agent pointer and frame."
74
+ },
75
+ {
76
+ "name": "OCEAN_BROWSER_PREVIEW",
77
+ "isRequired": false,
78
+ "description": "0 stops saving screenshot previews."
79
+ },
80
+ {
81
+ "name": "OCEAN_BROWSER_USAGE",
82
+ "isRequired": false,
83
+ "description": "0 stops the usage log."
84
+ },
85
+ {
86
+ "name": "OCEAN_BROWSER_SHARED",
87
+ "isRequired": false,
88
+ "description": "0 gives each session its own connection (and its own allow prompt)."
89
+ },
90
+ {
91
+ "name": "OCEAN_BROWSER_IDLE_MIN",
92
+ "isRequired": false,
93
+ "description": "Minutes without a call before the shared connection disconnects (default 480; 0 or never keeps it)."
94
+ },
95
+ {
96
+ "name": "OCEAN_BROWSER_SNAPSHOT_MAX_CHARS",
97
+ "isRequired": false,
98
+ "description": "Largest page snapshot sent whole, in characters (default 40000; 0 = no cap). Larger ones keep interactive elements and headings; the whole tree is saved to a file."
50
99
  }
51
100
  ]
52
101
  }