@clipy/cli 0.18.0 → 0.19.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-APACHE +202 -0
- package/README.md +210 -9
- package/dist/context/importCmd.js +1 -1
- package/dist/context/ytdlp.js +1 -1
- package/dist/context-core/arec.js +1 -1
- package/dist/index.js +1042 -88
- package/dist/local/arec.js +186 -0
- package/dist/local/commands.js +1103 -0
- package/dist/local/deps.js +42 -0
- package/dist/local/media.js +154 -0
- package/dist/local/pipeline.js +530 -0
- package/dist/local/ports.js +1 -0
- package/dist/local/speechEngine.js +260 -0
- package/dist/local/transcriptFile.js +54 -0
- package/dist/local/vendor/capture/capture.js +442 -0
- package/dist/local/vendor/capture/check.js +103 -0
- package/dist/local/vendor/capture/children.js +69 -0
- package/dist/local/vendor/capture/ffmpegArgs.js +108 -0
- package/dist/local/vendor/capture/index.js +36 -0
- package/dist/local/vendor/capture/proc.js +71 -0
- package/dist/local/vendor/capture/scripts.js +107 -0
- package/dist/local/vendor/capture/sidecar.js +199 -0
- package/dist/local/vendor/capture/sources.js +272 -0
- package/dist/local/vendor/capture/types.js +1 -0
- package/dist/local/vendor/capture/virtualDisplay.js +170 -0
- package/dist/local/vendor/capture/xauth.js +68 -0
- package/dist/local/vendor/config/errors.js +12 -0
- package/dist/local/vendor/config/index.js +241 -0
- package/dist/local/vendor/config/paths.js +37 -0
- package/dist/local/vendor/config/presets.js +61 -0
- package/dist/local/vendor/config/schema.js +66 -0
- package/dist/local/vendor/moments/generated/drawStrokes.js +127 -0
- package/dist/local/vendor/moments/generated/keyMomentsCursorContext.js +568 -0
- package/dist/local/vendor/moments/generated/keyMomentsFusion.js +406 -0
- package/dist/local/vendor/moments/generated/localMomentPlan.js +178 -0
- package/dist/local/vendor/moments/generated/types.js +1 -0
- package/dist/local/vendor/moments/index.js +147 -0
- package/dist/local/vendor/moments/llm.js +158 -0
- package/dist/local/vendor/transcribe/audio.js +251 -0
- package/dist/local/vendor/transcribe/chunking.js +250 -0
- package/dist/local/vendor/transcribe/index.js +89 -0
- package/dist/local/vendor/transcribe/local.js +221 -0
- package/dist/local/vendor/transcribe/localWorker.js +79 -0
- package/dist/local/vendor/transcribe/models.js +369 -0
- package/dist/local/vendor/transcribe/providers/assemblyai.js +61 -0
- package/dist/local/vendor/transcribe/providers/common.js +105 -0
- package/dist/local/vendor/transcribe/providers/deepgram.js +59 -0
- package/dist/local/vendor/transcribe/providers/elevenlabs.js +43 -0
- package/dist/local/vendor/transcribe/providers/gemini.js +102 -0
- package/dist/local/vendor/transcribe/providers/http.js +214 -0
- package/dist/local/vendor/transcribe/providers/openai.js +48 -0
- package/dist/local/vendor/transcribe/tar.js +53 -0
- package/dist/local/vendor/transcribe/types.js +1 -0
- package/dist/macBridge.js +78 -9
- package/dist/skill.js +46 -1
- package/package.json +19 -9
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import { cmdAnalytics, cmdComment, cmdComments, cmdDelete, cmdDiagnostics, cmdFo
|
|
|
41
41
|
import { waitForAgentContext } from "./agentReadiness.js";
|
|
42
42
|
import { cmdRecheck } from "./recheckCmd.js";
|
|
43
43
|
import { RECHECK_MAX_STEPS } from "./recheck.js";
|
|
44
|
-
import { BridgeUnavailableError, bridgeRequest, inspectBridge, listSources, readBridgeInfo, resolveCaptureSource, windowLabel, probeSocketOpenable, probeBridgeHandshake, bridgeInfoFromFile, bridgeAppOutdated, MIN_BRIDGE_APP_VERSION, describeWindow, describeDisplay, resolveFromSources, } from "./macBridge.js";
|
|
44
|
+
import { BridgeUnavailableError, bridgeRequest, inspectBridge, listSources, readBridgeInfo, resolveCaptureSource, windowLabel, probeSocketOpenable, probeBridgeHandshake, bridgeInfoFromFile, bridgeAppOutdated, MIN_BRIDGE_APP_VERSION, describeWindow, describeDisplay, bridgeApplicable, resolveFromSources, } from "./macBridge.js";
|
|
45
45
|
import { defaultDisplay, describeCaps, ffmpegCaps, isWaylandSession, listLinuxSources, orphanedCaptureProcesses, parseDisplaySize, realRunner, startScreenRecorder, startVirtualDisplay, } from "./linuxScreen.js";
|
|
46
46
|
// Exit quietly when stdout/stderr close early (e.g. `clipy list | head`).
|
|
47
47
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -75,6 +75,89 @@ function die(message, code = 1) {
|
|
|
75
75
|
process.stderr.write(`${c.red("error:")} ${message}\n`);
|
|
76
76
|
process.exit(code);
|
|
77
77
|
}
|
|
78
|
+
let localModuleCache = null;
|
|
79
|
+
let localEnvCache = null;
|
|
80
|
+
/** --yes: a local take may download the speech engine without asking. */
|
|
81
|
+
let localAssumeYes = false;
|
|
82
|
+
function localModule() {
|
|
83
|
+
return (localModuleCache ??= import("./local/commands.js"));
|
|
84
|
+
}
|
|
85
|
+
async function localMode() {
|
|
86
|
+
const mod = await localModule();
|
|
87
|
+
const env = await (localEnvCache ??= mod.realLocalEnv(VERSION, { assumeYes: localAssumeYes }));
|
|
88
|
+
return { mod, env };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Runs the local pipeline on a finished capture and prints the result: the
|
|
92
|
+
* AREC path last on stdout, or one JSON object with --json. Returns false (and
|
|
93
|
+
* sets the exit code) on failure, so the caller's own cleanup still runs.
|
|
94
|
+
*/
|
|
95
|
+
async function finishLocalTake(req, extra = {}) {
|
|
96
|
+
const { mod, env } = await localMode();
|
|
97
|
+
try {
|
|
98
|
+
const result = await mod.runLocalTake(req, env);
|
|
99
|
+
mod.printLocalResult(result, req.json, env.io, extra);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// A LocalTakeError says where the capture was kept; it is never deleted.
|
|
104
|
+
mod.printLocalError(error, req.json, env.io);
|
|
105
|
+
process.exitCode = error instanceof mod.UsageError ? 2 : 1;
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Settles everything a --local take needs before anything is recorded: the
|
|
111
|
+
* config file and model provider, ffmpeg, and the output folder (claimed
|
|
112
|
+
* here; a non-empty --out is refused unless --force). A mistake in any of them
|
|
113
|
+
* exits now, with exit code 2 for a usage error, instead of after a capture.
|
|
114
|
+
*/
|
|
115
|
+
async function prepareLocalOrExit(opts) {
|
|
116
|
+
const { mod, env } = await localMode();
|
|
117
|
+
try {
|
|
118
|
+
return await mod.prepareLocalTake({ out: opts.out, force: opts.force, inputs: opts.inputs, speech: opts.speech, speechFile: opts.speechFile, json: opts.json }, env);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
mod.printLocalError(error, opts.json, env.io);
|
|
122
|
+
process.exit(error instanceof mod.UsageError ? 2 : 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Removes a claimed --local folder that stayed empty because the capture never started. */
|
|
126
|
+
async function releaseLocalOut(dir) {
|
|
127
|
+
if (!dir)
|
|
128
|
+
return;
|
|
129
|
+
const { mod } = await localMode();
|
|
130
|
+
await mod.releaseOutDir(dir);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* While a --local capture runs (headless --url, Linux --source screen),
|
|
134
|
+
* Ctrl-C, SIGTERM and SIGHUP stop it early and the take is still built, instead
|
|
135
|
+
* of killing the CLI and leaving ffmpeg or Xvfb running. Returns a disposer.
|
|
136
|
+
*/
|
|
137
|
+
function onStopSignal(stop) {
|
|
138
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
139
|
+
const handler = () => stop();
|
|
140
|
+
for (const sig of signals)
|
|
141
|
+
process.on(sig, handler);
|
|
142
|
+
return () => {
|
|
143
|
+
for (const sig of signals)
|
|
144
|
+
process.off(sig, handler);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Narration notes in the local pipeline's shape. */
|
|
148
|
+
function localNarration(notes) {
|
|
149
|
+
return notes.map((n) => ({ startMs: n.startMs, ...(n.endMs !== undefined ? { endMs: n.endMs } : {}), text: n.text }));
|
|
150
|
+
}
|
|
151
|
+
/** --local real-screen takes on macOS go through Clipy Local, the local edition of the Mac app. */
|
|
152
|
+
const LOCAL_MAC_PLATFORM = "--source mac-screen with --local records through Clipy Local, which runs on macOS. " +
|
|
153
|
+
"Use clipy record --local (the CLI's own screen recorder), a web page with --url, or clipy proof --local.";
|
|
154
|
+
const LOCAL_MAC_OUT = "--out and --force do not apply to --source mac-screen with --local: Clipy Local keeps each take in its own folder, reported as out";
|
|
155
|
+
/** `--source mac-screen`, or `--source screen` on macOS, with --local. */
|
|
156
|
+
function isLocalMacSource(source, platform = process.platform) {
|
|
157
|
+
return source === "mac-screen" || (source === "screen" && platform === "darwin");
|
|
158
|
+
}
|
|
159
|
+
const LOCAL_EXTENSION_REFUSAL = "--source chrome-extension is not available with --local: the Clipy extension uploads its own recordings. " +
|
|
160
|
+
"Use --source chrome-for-clipy or --url with --local.";
|
|
78
161
|
function statusGlyph(status) {
|
|
79
162
|
switch (status) {
|
|
80
163
|
case "ready":
|
|
@@ -595,6 +678,59 @@ ${c.bold("SESSION")} ${c.dim("(agent works, Clipy records — one active session
|
|
|
595
678
|
session abort Discard the session — nothing is uploaded
|
|
596
679
|
session status Show the active session's state
|
|
597
680
|
|
|
681
|
+
${c.bold("LOCAL")} ${c.dim("(--local: no Clipy account, nothing uploaded)")}
|
|
682
|
+
${c.dim("Add --local to record, session, proof or context import and Clipy builds the")}
|
|
683
|
+
${c.dim("recording into an AREC folder on this machine instead of uploading it: video,")}
|
|
684
|
+
${c.dim("transcript, key moments with a screenshot each, and recording.arec for your AI")}
|
|
685
|
+
${c.dim("agent (Claude Code, Codex, Cursor and others). The last line printed is the")}
|
|
686
|
+
${c.dim("absolute path of recording.arec; --json prints one object with it.")}
|
|
687
|
+
${c.dim("Where data goes: with no provider, or a model or transcription running on this")}
|
|
688
|
+
${c.dim("machine (Ollama, LM Studio, the downloadable speech models), nothing leaves it.")}
|
|
689
|
+
${c.dim("With a model provider, the transcript text, click labels and a bounded sample")}
|
|
690
|
+
${c.dim("of pointer and key events go to it. With a transcription key, the audio goes")}
|
|
691
|
+
${c.dim("to that provider. The video and screenshots never leave this machine.")}
|
|
692
|
+
record --local [--max <sec>] [--mic] [--virtual-display] [--display|--window <id>]
|
|
693
|
+
Record the screen until Enter, Ctrl-C, SIGTERM or
|
|
694
|
+
--max. With no --max and stdin not a terminal, it
|
|
695
|
+
also stops when stdin closes. --virtual-display
|
|
696
|
+
(Linux) records a private Xvfb display. With
|
|
697
|
+
--url: the headless web capture. With --source
|
|
698
|
+
screen on Linux: the X11 recorder. With
|
|
699
|
+
--source screen (or mac-screen) on macOS:
|
|
700
|
+
Clipy Local, the open-source Mac app, records
|
|
701
|
+
for --for seconds (default 15)
|
|
702
|
+
session start ... --local Same session, marks and chapters; stop builds
|
|
703
|
+
the AREC (web, --source screen, chrome-for-clipy;
|
|
704
|
+
on macOS --source screen drives Clipy Local)
|
|
705
|
+
proof --frame <img>... --local Proof from screenshots or --video, built locally;
|
|
706
|
+
each frame and caption becomes a key moment
|
|
707
|
+
context import <file> --local Transcribe (unless --transcript), pick moments,
|
|
708
|
+
extract frames. URLs keep their transcript-only
|
|
709
|
+
bundle and never call Clipy; --sync is refused
|
|
710
|
+
--out <dir> Output folder (default ~/clipy/recordings/<date-time>/).
|
|
711
|
+
A folder that holds files is refused; --force replaces
|
|
712
|
+
the take in it. Checked, with the config, before recording
|
|
713
|
+
sources --local Screens and windows the local recorder can use
|
|
714
|
+
(add --source mac-screen for Clipy Local's ids)
|
|
715
|
+
local setup [flags] Choose who picks spoken moments and who transcribes
|
|
716
|
+
--model-provider openrouter|openai|gemini|groq|ollama|lmstudio|custom|none
|
|
717
|
+
--model-key - --model <name> --base-url <url>
|
|
718
|
+
--transcribe local-english|local-multilingual|openai|groq|deepgram|assemblyai|elevenlabs|gemini|none
|
|
719
|
+
--transcribe-key -
|
|
720
|
+
${c.dim("A key of - is read from stdin. Better still, set")}
|
|
721
|
+
${c.dim("CLIPY_MODEL_API_KEY or CLIPY_TRANSCRIBE_API_KEY in your")}
|
|
722
|
+
${c.dim("environment; a key typed on the command line can stay in")}
|
|
723
|
+
${c.dim("shell history and the process list.")}
|
|
724
|
+
local status [--json] Config file, provider, transcription, models, capture
|
|
725
|
+
models list | models download <english-fast|multilingual>
|
|
726
|
+
On-device speech models (one-time download, about
|
|
727
|
+
104 MB and 161 MB)
|
|
728
|
+
speech status | speech install The engine that runs them (sherpa-onnx-node, about
|
|
729
|
+
35 MB). Not installed with the CLI: a take that
|
|
730
|
+
needs it asks first. --yes or
|
|
731
|
+
CLIPY_INSTALL_SPEECH_ENGINE=1 accepts up front
|
|
732
|
+
${c.dim("Want a share link anyone can watch, with no signup to watch? clipy upload <file>.")}
|
|
733
|
+
|
|
598
734
|
${c.bold("AGENTS")}
|
|
599
735
|
setup [claude|codex|cursor|windsurf|opencode] [--with-browser]
|
|
600
736
|
Wire Clipy into a coding agent in ONE command:
|
|
@@ -620,8 +756,10 @@ ${c.bold("AGENTS")}
|
|
|
620
756
|
installing the Clipy extension and signing in
|
|
621
757
|
there, then waits until it is ready. install-app
|
|
622
758
|
saves a named macOS launcher in ~/Applications
|
|
623
|
-
doctor [--json]
|
|
624
|
-
Playwright, and install mode
|
|
759
|
+
doctor [--json] [--local] Health check: API key, Mac agent bridge,
|
|
760
|
+
Playwright, and install mode, with fix hints.
|
|
761
|
+
Also reports local mode (never a failure);
|
|
762
|
+
--local checks only local mode, no request to Clipy
|
|
625
763
|
guide --json Machine-readable manifest: every command,
|
|
626
764
|
flag, env var, and exit code
|
|
627
765
|
playwright-path [--json] Print the node_modules dir of the Playwright
|
|
@@ -1650,23 +1788,51 @@ function doctorLinuxScreenChecks() {
|
|
|
1650
1788
|
}
|
|
1651
1789
|
return out;
|
|
1652
1790
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1791
|
+
/**
|
|
1792
|
+
* Local mode (--local) in doctor: what it would use and whether it can run.
|
|
1793
|
+
* Informational until the user has a local config file; even then a missing
|
|
1794
|
+
* piece is a warning, never a failure, because local mode is optional.
|
|
1795
|
+
*/
|
|
1796
|
+
async function doctorLocalChecks() {
|
|
1797
|
+
let checks;
|
|
1798
|
+
try {
|
|
1799
|
+
const { mod, env } = await localMode();
|
|
1800
|
+
checks = await mod.localChecks(env);
|
|
1801
|
+
}
|
|
1802
|
+
catch (error) {
|
|
1803
|
+
return [{ name: "local mode", status: "info", detail: `unavailable: ${error.message}` }];
|
|
1804
|
+
}
|
|
1805
|
+
const configured = checks.some((chk) => chk.name === "local config" && chk.data?.exists);
|
|
1806
|
+
return checks.map((chk) => ({
|
|
1807
|
+
name: chk.name,
|
|
1808
|
+
status: chk.status === "pass" ? "pass" : chk.status === "warn" && configured ? "warn" : "info",
|
|
1809
|
+
detail: chk.detail,
|
|
1810
|
+
...(chk.hint ? { hint: chk.hint } : {}),
|
|
1811
|
+
...(chk.data ? { data: chk.data } : {}),
|
|
1812
|
+
}));
|
|
1813
|
+
}
|
|
1814
|
+
async function cmdDoctor(ctx, json, localOnly = false) {
|
|
1815
|
+
// --local: only what local mode uses. No API or sign-in check, so doctor
|
|
1816
|
+
// makes no request to Clipy.
|
|
1817
|
+
const checks = localOnly
|
|
1818
|
+
? await doctorLocalChecks()
|
|
1819
|
+
: [
|
|
1820
|
+
await doctorApiCheck(ctx),
|
|
1821
|
+
await doctorAuthCheck(ctx),
|
|
1822
|
+
...(await doctorBridgeChecks()),
|
|
1823
|
+
await doctorPlaywrightCheck(),
|
|
1824
|
+
doctorChromeCheck(),
|
|
1825
|
+
await doctorYtDlpCheck(),
|
|
1826
|
+
...(await doctorFfmpegChecks()),
|
|
1827
|
+
...doctorLinuxScreenChecks(),
|
|
1828
|
+
doctorInstallCheck(),
|
|
1829
|
+
...(await doctorLocalChecks()),
|
|
1830
|
+
];
|
|
1665
1831
|
const failed = checks.filter((chk) => chk.status === "fail").length;
|
|
1666
1832
|
if (json) {
|
|
1667
1833
|
printJson({
|
|
1668
1834
|
version: VERSION,
|
|
1669
|
-
apiUrl: ctx.apiUrl,
|
|
1835
|
+
...(localOnly ? { local: true } : { apiUrl: ctx.apiUrl }),
|
|
1670
1836
|
ok: failed === 0,
|
|
1671
1837
|
checks: checks.map((chk) => ({
|
|
1672
1838
|
name: chk.name,
|
|
@@ -1680,8 +1846,15 @@ async function cmdDoctor(ctx, json) {
|
|
|
1680
1846
|
process.exitCode = 1;
|
|
1681
1847
|
return;
|
|
1682
1848
|
}
|
|
1683
|
-
process.stdout.write(
|
|
1849
|
+
process.stdout.write(localOnly
|
|
1850
|
+
? `${c.bold("clipy doctor --local")} ${c.dim(`· v${VERSION} · no request to Clipy`)}\n\n`
|
|
1851
|
+
: `${c.bold("clipy doctor")} ${c.dim(`· v${VERSION} · ${ctx.apiUrl}`)}\n\n`);
|
|
1852
|
+
let localHeader = false;
|
|
1684
1853
|
for (const chk of checks) {
|
|
1854
|
+
if (!localHeader && chk.name.startsWith("local ")) {
|
|
1855
|
+
localHeader = true;
|
|
1856
|
+
process.stdout.write(`\n${c.bold("Local mode")} ${c.dim("(--local: no account, nothing uploaded; never a failure)")}\n`);
|
|
1857
|
+
}
|
|
1685
1858
|
// Pad to the longest check name ("bridge handshake") so details align.
|
|
1686
1859
|
process.stdout.write(`${doctorGlyph(chk.status)} ${chk.name.padEnd(16)} ${chk.detail}\n`);
|
|
1687
1860
|
if (chk.hint)
|
|
@@ -2396,13 +2569,31 @@ async function cmdProof(ctx, opts) {
|
|
|
2396
2569
|
if (maxPassRef(opts.notes) > 0) {
|
|
2397
2570
|
die('proof notes use absolute timestamps such as --note "3: saved state"; passN notes need record --viewports', 2);
|
|
2398
2571
|
}
|
|
2399
|
-
|
|
2572
|
+
if (opts.local && opts.verificationFor) {
|
|
2573
|
+
die("--for links a proof to a recording in your Clipy library; it does not apply with --local", 2);
|
|
2574
|
+
}
|
|
2575
|
+
if (!opts.local)
|
|
2576
|
+
requireKey(ctx);
|
|
2400
2577
|
const verificationFor = opts.verificationFor
|
|
2401
2578
|
? normalizeId(opts.verificationFor, ctx)
|
|
2402
2579
|
: null;
|
|
2403
2580
|
if (verificationFor) {
|
|
2404
2581
|
await apiJson(ctx, `/api/v1/recordings/${encodeURIComponent(verificationFor)}`);
|
|
2405
2582
|
}
|
|
2583
|
+
// --local: config, provider, ffmpeg and --out first, before frames are rendered.
|
|
2584
|
+
// The frames and video are inputs: an --out that holds them is refused.
|
|
2585
|
+
const prepared = opts.local
|
|
2586
|
+
? await prepareLocalOrExit({
|
|
2587
|
+
out: opts.local.out,
|
|
2588
|
+
force: opts.local.force,
|
|
2589
|
+
json: opts.json,
|
|
2590
|
+
inputs: [...opts.framePaths, ...(opts.videoPath ? [opts.videoPath] : [])],
|
|
2591
|
+
// Frames make a silent video; a supplied --video may have speech.
|
|
2592
|
+
speech: Boolean(opts.videoPath),
|
|
2593
|
+
speechFile: opts.videoPath,
|
|
2594
|
+
})
|
|
2595
|
+
: undefined;
|
|
2596
|
+
let localStarted = false;
|
|
2406
2597
|
const tmpDir = join(tmpdir(), `clipy-proof-${randomUUID()}`);
|
|
2407
2598
|
let generatedVideo = false;
|
|
2408
2599
|
let videoPath = opts.videoPath ? resolve(opts.videoPath) : "";
|
|
@@ -2446,6 +2637,42 @@ async function cmdProof(ctx, opts) {
|
|
|
2446
2637
|
if (narrationNotes.length > 200) {
|
|
2447
2638
|
throw new Error("proof supports at most 200 captions/notes");
|
|
2448
2639
|
}
|
|
2640
|
+
if (opts.local) {
|
|
2641
|
+
// Every frame gets a key moment (its caption, or its number), taken in
|
|
2642
|
+
// the middle of its hold so the screenshot is that frame.
|
|
2643
|
+
const local = narrationNotes.filter((n) => !/^\[proof frame \d+\/\d+\]/.test(n.text)).map((n) => ({ ...n }));
|
|
2644
|
+
const holdMs = Math.round(opts.holdSeconds * 1000);
|
|
2645
|
+
opts.framePaths.forEach((_frame, index) => {
|
|
2646
|
+
const caption = opts.captions[index]?.trim();
|
|
2647
|
+
local.push({
|
|
2648
|
+
startMs: index * holdMs,
|
|
2649
|
+
endMs: (index + 1) * holdMs,
|
|
2650
|
+
frameAtMs: index * holdMs + Math.floor(holdMs / 2),
|
|
2651
|
+
text: `[proof frame ${index + 1}/${opts.framePaths.length}]${caption ? ` ${caption}` : ""}`,
|
|
2652
|
+
});
|
|
2653
|
+
});
|
|
2654
|
+
local.sort((a, b) => a.startMs - b.startMs);
|
|
2655
|
+
localStarted = true;
|
|
2656
|
+
const ok = await finishLocalTake({
|
|
2657
|
+
videoPath,
|
|
2658
|
+
moveVideo: generatedVideo,
|
|
2659
|
+
prepared,
|
|
2660
|
+
title: opts.name ?? "Agent verification proof",
|
|
2661
|
+
description: opts.description,
|
|
2662
|
+
expectedResult: opts.expectedResult,
|
|
2663
|
+
recordingKind: opts.recordingKind,
|
|
2664
|
+
narration: local,
|
|
2665
|
+
origin: hasFrames ? { kind: "capture", sourceName: "proof frames" } : { kind: "import", fileName: basename(videoPath) },
|
|
2666
|
+
json: opts.json,
|
|
2667
|
+
}, {
|
|
2668
|
+
source: hasFrames
|
|
2669
|
+
? { kind: "proof-frames", frameCount: opts.framePaths.length, holdSeconds: opts.holdSeconds, durationSeconds }
|
|
2670
|
+
: { kind: "proof-video" },
|
|
2671
|
+
});
|
|
2672
|
+
if (!ok)
|
|
2673
|
+
process.exitCode = 1;
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2449
2676
|
const uploaded = await uploadVideoToClipy(ctx, {
|
|
2450
2677
|
videoPath,
|
|
2451
2678
|
name: opts.name ?? "Agent verification proof",
|
|
@@ -2501,6 +2728,8 @@ async function cmdProof(ctx, opts) {
|
|
|
2501
2728
|
if (generatedVideo || existsSync(tmpDir)) {
|
|
2502
2729
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
2503
2730
|
}
|
|
2731
|
+
if (prepared && !localStarted)
|
|
2732
|
+
await releaseLocalOut(prepared.dir);
|
|
2504
2733
|
}
|
|
2505
2734
|
if (failure)
|
|
2506
2735
|
die(failure.message);
|
|
@@ -2894,16 +3123,18 @@ function sweepStaleProfileCopies() {
|
|
|
2894
3123
|
* context tears down that browser. */
|
|
2895
3124
|
async function launchRecordingContext(chromium, opts) {
|
|
2896
3125
|
const recordVideo = { dir: opts.recordVideoDir, size: opts.viewport };
|
|
3126
|
+
const signals = opts.callerHandlesSignals ? { handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false } : {};
|
|
2897
3127
|
if (opts.userDataDir) {
|
|
2898
3128
|
const context = await chromium.launchPersistentContext(opts.userDataDir, {
|
|
2899
3129
|
headless: true,
|
|
2900
3130
|
viewport: opts.viewport,
|
|
2901
3131
|
recordVideo,
|
|
2902
3132
|
args: opts.args,
|
|
3133
|
+
...signals,
|
|
2903
3134
|
});
|
|
2904
3135
|
return { context, browser: null };
|
|
2905
3136
|
}
|
|
2906
|
-
const browser = await chromium.launch({ headless: true, args: opts.args });
|
|
3137
|
+
const browser = await chromium.launch({ headless: true, args: opts.args, ...signals });
|
|
2907
3138
|
const context = await browser.newContext({
|
|
2908
3139
|
viewport: opts.viewport,
|
|
2909
3140
|
recordVideo,
|
|
@@ -2927,27 +3158,15 @@ async function cmdRecord(ctx, opts) {
|
|
|
2927
3158
|
validateAuthCapture(opts.auth, target.href); // usage errors (exit 2) before auth/browser
|
|
2928
3159
|
if (opts.userDataDir)
|
|
2929
3160
|
validateUserDataDir(opts.userDataDir, opts.profileDirectory);
|
|
2930
|
-
|
|
3161
|
+
if (!opts.local)
|
|
3162
|
+
requireKey(ctx); // fail fast before we spin up a browser
|
|
2931
3163
|
sweepStaleProfileCopies(); // clear any profile copy a prior SIGKILL stranded
|
|
2932
3164
|
const chromium = await loadChromium();
|
|
2933
3165
|
const tmpDir = join(tmpdir(), `clipy-record-${randomUUID()}`);
|
|
2934
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
2935
3166
|
const log = (m) => {
|
|
2936
3167
|
if (!opts.json)
|
|
2937
3168
|
process.stderr.write(`${m}\n`);
|
|
2938
3169
|
};
|
|
2939
|
-
// --profile-directory ⇒ copy the named profile into a scratch root's Default and
|
|
2940
|
-
// launch against THAT (Playwright can't select a named profile in-place). The
|
|
2941
|
-
// copy is disclosed loudly and cleaned up in the finally below. Always writes
|
|
2942
|
-
// the disclosure to stderr, even under --json (no silent profile substitution).
|
|
2943
|
-
let profileScratchRoot;
|
|
2944
|
-
const launchUserDataDir = (() => {
|
|
2945
|
-
if (opts.userDataDir && opts.profileDirectory) {
|
|
2946
|
-
profileScratchRoot = copyProfileToScratchRoot(opts.userDataDir, opts.profileDirectory, (m) => process.stderr.write(`${m}\n`));
|
|
2947
|
-
return profileScratchRoot;
|
|
2948
|
-
}
|
|
2949
|
-
return opts.userDataDir;
|
|
2950
|
-
})();
|
|
2951
3170
|
// Multi-viewport mode records every size sequentially into ONE video; the
|
|
2952
3171
|
// frame is sized to the largest viewport and smaller passes letterbox
|
|
2953
3172
|
// inside it. Each pass emits an auto note so the transcript chapters the
|
|
@@ -2966,11 +3185,43 @@ async function cmdRecord(ctx, opts) {
|
|
|
2966
3185
|
die(`--note "pass${maxRef}: …" refers to pass ${maxRef}, but this recording has ${passes.length} pass${passes.length === 1 ? "" : "es"}` +
|
|
2967
3186
|
`${opts.viewports ? "" : " (pass-scoped notes are for --viewports; use an absolute timestamp otherwise)"}`, 2);
|
|
2968
3187
|
}
|
|
2969
|
-
|
|
3188
|
+
// --local: config, provider, ffmpeg and --out are settled before the browser
|
|
3189
|
+
// records anything, so none of them can cost the take afterwards.
|
|
3190
|
+
const prepared = opts.local
|
|
3191
|
+
? await prepareLocalOrExit({ out: opts.local.out, force: opts.local.force, json: opts.json })
|
|
3192
|
+
: undefined;
|
|
3193
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
3194
|
+
// --profile-directory ⇒ copy the named profile into a scratch root's Default and
|
|
3195
|
+
// launch against THAT (Playwright can't select a named profile in-place). The
|
|
3196
|
+
// copy is disclosed loudly and cleaned up in the finally below. Always writes
|
|
3197
|
+
// the disclosure to stderr, even under --json (no silent profile substitution).
|
|
3198
|
+
let profileScratchRoot;
|
|
3199
|
+
const launchUserDataDir = (() => {
|
|
3200
|
+
if (opts.userDataDir && opts.profileDirectory) {
|
|
3201
|
+
profileScratchRoot = copyProfileToScratchRoot(opts.userDataDir, opts.profileDirectory, (m) => process.stderr.write(`${m}\n`));
|
|
3202
|
+
return profileScratchRoot;
|
|
3203
|
+
}
|
|
3204
|
+
return opts.userDataDir;
|
|
3205
|
+
})();
|
|
3206
|
+
// --local: Ctrl-C, SIGTERM or SIGHUP end the capture early and the take is
|
|
3207
|
+
// still built (Playwright is told not to kill the browser on them).
|
|
3208
|
+
let stopEarly = () => { };
|
|
3209
|
+
let stoppedEarly = false;
|
|
3210
|
+
const stopRequested = new Promise((resolveStop) => {
|
|
3211
|
+
stopEarly = () => {
|
|
3212
|
+
if (!stoppedEarly)
|
|
3213
|
+
log(c.dim("stopping early; building the take…"));
|
|
3214
|
+
stoppedEarly = true;
|
|
3215
|
+
resolveStop();
|
|
3216
|
+
};
|
|
3217
|
+
});
|
|
3218
|
+
const releaseSignals = opts.local ? onStopSignal(() => stopEarly()) : () => { };
|
|
3219
|
+
let uploaded = null;
|
|
2970
3220
|
const autoNotes = [];
|
|
2971
3221
|
// The real start of each pass, measured from the capture clock (index 0 =
|
|
2972
3222
|
// pass 1). Pass-scoped notes anchor to these actual times, not fixed guesses.
|
|
2973
3223
|
const passStartsMs = [];
|
|
3224
|
+
let capturedLocally = false;
|
|
2974
3225
|
try {
|
|
2975
3226
|
// --- Capture -----------------------------------------------------------
|
|
2976
3227
|
let videoPath;
|
|
@@ -2985,7 +3236,10 @@ async function cmdRecord(ctx, opts) {
|
|
|
2985
3236
|
recordVideoDir: tmpDir,
|
|
2986
3237
|
args: ["--no-sandbox", "--disable-dev-shm-usage"],
|
|
2987
3238
|
storageStatePath: opts.auth.storageStatePath,
|
|
3239
|
+
callerHandlesSignals: Boolean(opts.local),
|
|
2988
3240
|
});
|
|
3241
|
+
// A wait that a stop signal (--local only) cuts short.
|
|
3242
|
+
const hold = (page, ms) => Promise.race([page.waitForTimeout(ms), stopRequested]);
|
|
2989
3243
|
try {
|
|
2990
3244
|
// Seed cookies/localStorage/init-script before the first navigation. These
|
|
2991
3245
|
// compose with a persistent profile too; --storage-state does not (rejected
|
|
@@ -2996,6 +3250,8 @@ async function cmdRecord(ctx, opts) {
|
|
|
2996
3250
|
// and pass marks aren't anchored to the blank t=0 a compiling app shows.
|
|
2997
3251
|
let captureStart = 0;
|
|
2998
3252
|
for (const [i, vp] of passes.entries()) {
|
|
3253
|
+
if (stoppedEarly)
|
|
3254
|
+
break;
|
|
2999
3255
|
if (opts.viewports) {
|
|
3000
3256
|
await page.setViewportSize({ width: vp.width, height: vp.height }).catch(() => { });
|
|
3001
3257
|
log(`${c.dim(`viewport ${vp.label}…`)}`);
|
|
@@ -3030,13 +3286,13 @@ async function cmdRecord(ctx, opts) {
|
|
|
3030
3286
|
// just the fold. Scroll in ~6 steps across the pass duration.
|
|
3031
3287
|
const steps = 6;
|
|
3032
3288
|
const stepMs = (opts.forSec * 1000) / steps;
|
|
3033
|
-
for (let s = 0; s < steps; s++) {
|
|
3034
|
-
await page
|
|
3289
|
+
for (let s = 0; s < steps && !stoppedEarly; s++) {
|
|
3290
|
+
await hold(page, stepMs);
|
|
3035
3291
|
await page.mouse.wheel(0, Math.round(vp.height * 0.7)).catch(() => { });
|
|
3036
3292
|
}
|
|
3037
3293
|
}
|
|
3038
3294
|
else {
|
|
3039
|
-
await page
|
|
3295
|
+
await hold(page, opts.forSec * 1000);
|
|
3040
3296
|
}
|
|
3041
3297
|
}
|
|
3042
3298
|
const video = page.video();
|
|
@@ -3057,6 +3313,25 @@ async function cmdRecord(ctx, opts) {
|
|
|
3057
3313
|
}
|
|
3058
3314
|
// --- Upload ------------------------------------------------------------
|
|
3059
3315
|
const notes = [...autoNotes, ...resolveNarrationNotes(opts.notes, passStartsMs)].sort((a, b) => a.startMs - b.startMs);
|
|
3316
|
+
if (opts.local) {
|
|
3317
|
+
// --local: the same capture, built into an AREC here instead of uploaded.
|
|
3318
|
+
// A failure from here on keeps the video in the take folder.
|
|
3319
|
+
capturedLocally = true;
|
|
3320
|
+
releaseSignals();
|
|
3321
|
+
await finishLocalTake({
|
|
3322
|
+
videoPath,
|
|
3323
|
+
moveVideo: true,
|
|
3324
|
+
prepared,
|
|
3325
|
+
title: opts.name ?? `Recording of ${target.href}`,
|
|
3326
|
+
description: opts.description,
|
|
3327
|
+
expectedResult: opts.expectedResult,
|
|
3328
|
+
recordingKind: opts.recordingKind,
|
|
3329
|
+
narration: localNarration(notes),
|
|
3330
|
+
origin: { kind: "capture", sourceName: target.href },
|
|
3331
|
+
json: opts.json,
|
|
3332
|
+
}, { source: { kind: "web", url: target.href } });
|
|
3333
|
+
return;
|
|
3334
|
+
}
|
|
3060
3335
|
uploaded = await uploadVideoToClipy(ctx, {
|
|
3061
3336
|
videoPath,
|
|
3062
3337
|
name: opts.name,
|
|
@@ -3068,6 +3343,10 @@ async function cmdRecord(ctx, opts) {
|
|
|
3068
3343
|
});
|
|
3069
3344
|
}
|
|
3070
3345
|
finally {
|
|
3346
|
+
releaseSignals();
|
|
3347
|
+
// A --local take that never captured anything leaves no empty folder.
|
|
3348
|
+
if (prepared && !capturedLocally)
|
|
3349
|
+
await releaseLocalOut(prepared.dir);
|
|
3071
3350
|
try {
|
|
3072
3351
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
3073
3352
|
}
|
|
@@ -3083,6 +3362,8 @@ async function cmdRecord(ctx, opts) {
|
|
|
3083
3362
|
}
|
|
3084
3363
|
}
|
|
3085
3364
|
}
|
|
3365
|
+
if (!uploaded)
|
|
3366
|
+
return; // --local printed its own result
|
|
3086
3367
|
if (opts.wait && uploaded.publicId) {
|
|
3087
3368
|
log(`${c.dim("waiting for transcript…")}`);
|
|
3088
3369
|
await waitForArtifacts(ctx, uploaded.publicId).catch(() => {
|
|
@@ -3636,7 +3917,8 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3636
3917
|
}
|
|
3637
3918
|
if (existing)
|
|
3638
3919
|
reportKeptCapture(cleanupSessionFiles(existing, file));
|
|
3639
|
-
const key = requireKey(ctx);
|
|
3920
|
+
const key = opts.local ? null : requireKey(ctx);
|
|
3921
|
+
const localOut = opts.local ? await localSessionOut(opts.local.out, opts.local.force, opts.json) : undefined;
|
|
3640
3922
|
const plan = planLinuxCapture(opts);
|
|
3641
3923
|
const maxSec = Math.min(Math.max(1, opts.maxSec), SESSION_HARD_CAP_SEC);
|
|
3642
3924
|
const id = randomUUID();
|
|
@@ -3659,6 +3941,7 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3659
3941
|
maxSec,
|
|
3660
3942
|
width: opts.width,
|
|
3661
3943
|
height: opts.height,
|
|
3944
|
+
...(localOut ? { local: { out: localOut } } : {}),
|
|
3662
3945
|
state: "starting",
|
|
3663
3946
|
marksPath: join(dir, `marks-${id}.jsonl`),
|
|
3664
3947
|
controlPath: join(dir, `control-${id}.json`),
|
|
@@ -3669,7 +3952,7 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3669
3952
|
const child = spawn(process.execPath, [process.argv[1], "__session-daemon", file], {
|
|
3670
3953
|
detached: true,
|
|
3671
3954
|
stdio: ["ignore", logFd, logFd],
|
|
3672
|
-
env: { ...process.env, CLIPY_API_KEY: key, CLIPY_API_URL: ctx.apiUrl },
|
|
3955
|
+
env: { ...process.env, ...(key ? { CLIPY_API_KEY: key } : {}), CLIPY_API_URL: ctx.apiUrl },
|
|
3673
3956
|
});
|
|
3674
3957
|
closeSync(logFd);
|
|
3675
3958
|
if (!child.pid)
|
|
@@ -3707,10 +3990,13 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3707
3990
|
sessionFile: file,
|
|
3708
3991
|
source: captureSourceResult(plan.resolved),
|
|
3709
3992
|
...(plan.windowCapture ? { windowCapture: plan.windowCapture } : {}),
|
|
3993
|
+
...(localOut ? { local: true, out: localOut } : {}),
|
|
3710
3994
|
});
|
|
3711
3995
|
return;
|
|
3712
3996
|
}
|
|
3713
3997
|
process.stdout.write(`${c.green("✓")} recording ${plan.label} on ${xDisplay} (max ${maxSec}s)\n`);
|
|
3998
|
+
if (localOut)
|
|
3999
|
+
process.stdout.write(`${c.dim("local mode:")} nothing is uploaded; the AREC is written to ${localOut} at stop\n`);
|
|
3714
4000
|
if (plan.virtualDisplay) {
|
|
3715
4001
|
process.stdout.write(`${c.bold("virtual display:")} ${xDisplay}: only what you launch there is recorded, and it never touches the user's screen.\n` +
|
|
3716
4002
|
`${c.dim("launch apps on it with:")} DISPLAY=${xDisplay} <command> ${c.dim("(or use clipy session run, which sets DISPLAY)")}\n`);
|
|
@@ -3723,21 +4009,226 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3723
4009
|
process.stdout.write(`${c.dim("while it runs:")} clipy mark "what just happened"\n` +
|
|
3724
4010
|
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
3725
4011
|
}
|
|
4012
|
+
/**
|
|
4013
|
+
* `clipy record --local`: the capture each flag combination uses today, with
|
|
4014
|
+
* the upload replaced by the local pipeline.
|
|
4015
|
+
*
|
|
4016
|
+
* - `--url <u>`: the headless browser capture (silent; notes become narration).
|
|
4017
|
+
* - `--source screen` on Linux: the CLI's X11 recorder, as without --local.
|
|
4018
|
+
* - no `--url` and no `--source`, or `--source screen` on macOS or Windows:
|
|
4019
|
+
* the local capture package (ffmpeg), until Enter, Ctrl-C or `--max`.
|
|
4020
|
+
*
|
|
4021
|
+
* Never needs `clipy login`.
|
|
4022
|
+
*/
|
|
4023
|
+
async function cmdRecordLocalDispatch(ctx, values, rest, h) {
|
|
4024
|
+
const str = (k) => typeof values[k] === "string" ? values[k].trim() || undefined : undefined;
|
|
4025
|
+
const out = str("out");
|
|
4026
|
+
const url = str("url") || rest[0]?.trim() || undefined;
|
|
4027
|
+
const rawSource = str("source");
|
|
4028
|
+
const name = str("title") ?? str("name");
|
|
4029
|
+
const description = str("description");
|
|
4030
|
+
const recordingKind = values.type ? requireRecordingKind(String(values.type)) : undefined;
|
|
4031
|
+
const notes = (values.note ?? []).map(parseNoteFlag);
|
|
4032
|
+
const window = str("window");
|
|
4033
|
+
const display = str("display");
|
|
4034
|
+
if (window && display)
|
|
4035
|
+
die("--window and --display are mutually exclusive: pick one capture source", 2);
|
|
4036
|
+
if (url) {
|
|
4037
|
+
if (rawSource && rawSource !== "web") {
|
|
4038
|
+
die("--url records a web page in a headless browser; drop --source, or record the screen without --url", 2);
|
|
4039
|
+
}
|
|
4040
|
+
if (h.audioFlagsPresent) {
|
|
4041
|
+
die("--mic/--no-system-audio: a headless web capture records no audio; drop the audio flag", 2);
|
|
4042
|
+
}
|
|
4043
|
+
if (values["virtual-display"] || values["x-display"] || window || display) {
|
|
4044
|
+
die("--virtual-display, --x-display, --window and --display record the screen; drop --url to use them", 2);
|
|
4045
|
+
}
|
|
4046
|
+
await cmdRecord(ctx, {
|
|
4047
|
+
url,
|
|
4048
|
+
forSec: h.num(values.for ?? values.max, 15),
|
|
4049
|
+
name,
|
|
4050
|
+
description,
|
|
4051
|
+
recordingKind,
|
|
4052
|
+
expectedResult: h.expectedResult,
|
|
4053
|
+
notes,
|
|
4054
|
+
viewports: values.viewports ? parseViewports(String(values.viewports)) : null,
|
|
4055
|
+
width: h.num(values.width, 1280),
|
|
4056
|
+
height: h.num(values.height, 720),
|
|
4057
|
+
wait: false,
|
|
4058
|
+
json: h.json,
|
|
4059
|
+
auth: h.authCapture(),
|
|
4060
|
+
userDataDir: h.userDataDir(),
|
|
4061
|
+
profileDirectory: h.profileDirectory(),
|
|
4062
|
+
local: { out, force: Boolean(values.force) },
|
|
4063
|
+
});
|
|
4064
|
+
return;
|
|
4065
|
+
}
|
|
4066
|
+
if (rawSource === "web")
|
|
4067
|
+
die("usage: clipy record --local --url <http(s) url> [--for <sec>] [--out <dir>]", 2);
|
|
4068
|
+
if (isLocalMacSource(rawSource)) {
|
|
4069
|
+
if (!bridgeApplicable("local"))
|
|
4070
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
4071
|
+
if (out || values.force)
|
|
4072
|
+
die(LOCAL_MAC_OUT, 2);
|
|
4073
|
+
if (h.authFlagsPresent) {
|
|
4074
|
+
die("auth state (--storage-state/--user-data-dir/--cookie/--local-storage/--init-script) applies to --url captures; --source mac-screen records the real, already signed-in screen", 2);
|
|
4075
|
+
}
|
|
4076
|
+
if (values.viewports)
|
|
4077
|
+
die("--viewports applies to --url captures", 2);
|
|
4078
|
+
if (values["x-display"] || values["virtual-display"])
|
|
4079
|
+
die("--x-display/--virtual-display apply to --source screen on Linux", 2);
|
|
4080
|
+
const forSec = h.num(values.for ?? values.max, 15);
|
|
4081
|
+
// Clipy Local's watchdog stops a bridge take at 1800 s.
|
|
4082
|
+
if (forSec > 1740)
|
|
4083
|
+
die("--for is capped at 1740s for --source mac-screen (the app stops at 1800s)", 2);
|
|
4084
|
+
await cmdRecordMacLocal({
|
|
4085
|
+
audio: h.audioChoice(),
|
|
4086
|
+
forSec,
|
|
4087
|
+
name,
|
|
4088
|
+
description,
|
|
4089
|
+
recordingKind,
|
|
4090
|
+
expectedResult: h.expectedResult,
|
|
4091
|
+
window,
|
|
4092
|
+
display,
|
|
4093
|
+
notes,
|
|
4094
|
+
json: h.json,
|
|
4095
|
+
});
|
|
4096
|
+
return;
|
|
4097
|
+
}
|
|
4098
|
+
if (rawSource && rawSource !== "screen" && rawSource !== "linux-screen") {
|
|
4099
|
+
die("with --local, --source is web (with --url) or screen", 2);
|
|
4100
|
+
}
|
|
4101
|
+
if (rawSource === "linux-screen" && process.platform !== "linux") {
|
|
4102
|
+
die("--source linux-screen records an X11 display and only runs on Linux", 2);
|
|
4103
|
+
}
|
|
4104
|
+
if (h.authFlagsPresent) {
|
|
4105
|
+
die("auth state (--storage-state/--user-data-dir/--cookie/--local-storage/--init-script) applies to --url captures", 2);
|
|
4106
|
+
}
|
|
4107
|
+
if (values.viewports)
|
|
4108
|
+
die("--viewports applies to --url captures", 2);
|
|
4109
|
+
if (maxPassRef(notes) > 0) {
|
|
4110
|
+
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
4111
|
+
}
|
|
4112
|
+
if (process.platform === "linux" && rawSource) {
|
|
4113
|
+
// --source screen on Linux: today's recorder, built locally.
|
|
4114
|
+
if (h.audioFlagsPresent) {
|
|
4115
|
+
die("--mic/--no-system-audio: Linux screen recordings are silent for now (narrate with --note); drop the audio flag, or record without --source to use --mic", 2);
|
|
4116
|
+
}
|
|
4117
|
+
const forSec = h.num(values.for ?? values.max, 15);
|
|
4118
|
+
if (forSec > SESSION_HARD_CAP_SEC)
|
|
4119
|
+
die(`--for is capped at ${SESSION_HARD_CAP_SEC}s`, 2);
|
|
4120
|
+
await cmdRecordLinux(ctx, {
|
|
4121
|
+
forSec,
|
|
4122
|
+
name,
|
|
4123
|
+
description,
|
|
4124
|
+
recordingKind,
|
|
4125
|
+
expectedResult: h.expectedResult,
|
|
4126
|
+
window,
|
|
4127
|
+
display,
|
|
4128
|
+
xDisplay: str("x-display"),
|
|
4129
|
+
virtualDisplay: Boolean(values["virtual-display"]),
|
|
4130
|
+
width: h.num(values.width, 1280),
|
|
4131
|
+
height: h.num(values.height, 720),
|
|
4132
|
+
notes,
|
|
4133
|
+
json: h.json,
|
|
4134
|
+
local: { out, force: Boolean(values.force) },
|
|
4135
|
+
}).catch((e) => die(e.message));
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
// The local capture package: any OS, until Enter, Ctrl-C or --max.
|
|
4139
|
+
if (values["x-display"])
|
|
4140
|
+
die("--x-display applies to --source screen on Linux", 2);
|
|
4141
|
+
if (values["virtual-display"] && process.platform !== "linux")
|
|
4142
|
+
die("--virtual-display needs Linux with Xvfb", 2);
|
|
4143
|
+
const maxRaw = values.max ?? values.for;
|
|
4144
|
+
let maxSeconds;
|
|
4145
|
+
if (maxRaw !== undefined) {
|
|
4146
|
+
maxSeconds = Number(maxRaw);
|
|
4147
|
+
if (!Number.isFinite(maxSeconds) || maxSeconds <= 0)
|
|
4148
|
+
die("--max must be a number of seconds above 0", 2);
|
|
4149
|
+
if (maxSeconds > SESSION_HARD_CAP_SEC * 4)
|
|
4150
|
+
die(`--max is capped at ${SESSION_HARD_CAP_SEC * 4}s`, 2);
|
|
4151
|
+
}
|
|
4152
|
+
const { mod, env } = await localMode();
|
|
4153
|
+
process.exitCode = await mod.localCaptureRecord({
|
|
4154
|
+
source: window ?? display,
|
|
4155
|
+
maxSeconds,
|
|
4156
|
+
mic: Boolean(values.mic),
|
|
4157
|
+
virtualDisplay: values["virtual-display"]
|
|
4158
|
+
? { width: h.num(values.width, 1280), height: h.num(values.height, 720) }
|
|
4159
|
+
: undefined,
|
|
4160
|
+
out,
|
|
4161
|
+
force: Boolean(values.force),
|
|
4162
|
+
title: name,
|
|
4163
|
+
description,
|
|
4164
|
+
expectedResult: h.expectedResult,
|
|
4165
|
+
recordingKind,
|
|
4166
|
+
narration: notes.map((n) => ({ startMs: n.startMs ?? 0, text: n.text })),
|
|
4167
|
+
json: h.json,
|
|
4168
|
+
}, env);
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* `clipy context import <file> --local`: transcribe on this machine (or with
|
|
4172
|
+
* the user's key) unless --transcript is given, pick moments, extract frames,
|
|
4173
|
+
* and write the full local AREC folder. Never calls Clipy.
|
|
4174
|
+
*/
|
|
4175
|
+
async function cmdContextImportLocal(target, opts) {
|
|
4176
|
+
const file = resolve(target);
|
|
4177
|
+
let transcript = null;
|
|
4178
|
+
if (opts.transcriptPath) {
|
|
4179
|
+
const { mod, env } = await localMode();
|
|
4180
|
+
try {
|
|
4181
|
+
const { readTranscriptFile } = await import("./local/transcriptFile.js");
|
|
4182
|
+
transcript = await readTranscriptFile(resolve(opts.transcriptPath));
|
|
4183
|
+
}
|
|
4184
|
+
catch (error) {
|
|
4185
|
+
mod.printLocalError(error, opts.json, env.io);
|
|
4186
|
+
process.exitCode = 1;
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
await finishLocalTake({
|
|
4191
|
+
videoPath: file,
|
|
4192
|
+
out: opts.out,
|
|
4193
|
+
force: opts.force,
|
|
4194
|
+
title: opts.title ?? basename(file),
|
|
4195
|
+
transcript,
|
|
4196
|
+
origin: { kind: "import", fileName: basename(file) },
|
|
4197
|
+
json: opts.json,
|
|
4198
|
+
}, { source: { kind: "local-file", fileName: basename(file) } });
|
|
4199
|
+
}
|
|
3726
4200
|
/** One-shot `clipy record --source screen --for N` on Linux. */
|
|
3727
4201
|
async function cmdRecordLinux(ctx, opts) {
|
|
3728
|
-
|
|
4202
|
+
if (!opts.local)
|
|
4203
|
+
requireKey(ctx);
|
|
3729
4204
|
if (maxPassRef(opts.notes) > 0) {
|
|
3730
4205
|
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
3731
4206
|
}
|
|
3732
4207
|
const plan = planLinuxCapture(opts);
|
|
3733
|
-
|
|
3734
|
-
const
|
|
4208
|
+
// --local: config, provider, ffmpeg and --out are settled before recording.
|
|
4209
|
+
const prepared = opts.local
|
|
4210
|
+
? await prepareLocalOrExit({ out: opts.local.out, force: opts.local.force, json: opts.json })
|
|
4211
|
+
: undefined;
|
|
4212
|
+
let localStarted = false;
|
|
4213
|
+
// --local: Ctrl-C, SIGTERM and SIGHUP end the take early and it is still
|
|
4214
|
+
// built, instead of killing the CLI and leaving ffmpeg and Xvfb running.
|
|
4215
|
+
let stopRequested = false;
|
|
4216
|
+
const releaseSignals = opts.local
|
|
4217
|
+
? onStopSignal(() => {
|
|
4218
|
+
if (!stopRequested && !opts.json)
|
|
4219
|
+
process.stderr.write(`${c.dim("stopping early; building the take…")}\n`);
|
|
4220
|
+
stopRequested = true;
|
|
4221
|
+
})
|
|
4222
|
+
: () => { };
|
|
4223
|
+
let vd = null;
|
|
3735
4224
|
const auto = [];
|
|
3736
4225
|
const workDir = join(tmpdir(), `clipy-record-${randomUUID()}`);
|
|
3737
4226
|
// Set when an upload fails: the finished video is kept for the user to
|
|
3738
4227
|
// retry, and only the intermediate segments are removed.
|
|
3739
4228
|
let keptVideo = null;
|
|
3740
4229
|
try {
|
|
4230
|
+
vd = plan.virtualDisplay ? await startVirtualDisplay(plan.virtualDisplay) : null;
|
|
4231
|
+
const xDisplay = vd?.display ?? plan.xDisplay;
|
|
3741
4232
|
if (vd) {
|
|
3742
4233
|
process.stderr.write(`${c.bold("virtual display:")} ${xDisplay}: launch apps there with DISPLAY=${xDisplay}; it closes when the recording ends.\n`);
|
|
3743
4234
|
}
|
|
@@ -3750,7 +4241,7 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3750
4241
|
if (!opts.json)
|
|
3751
4242
|
process.stderr.write(`${c.dim(`recording ${plan.label} for ${opts.forSec}s…`)}\n`);
|
|
3752
4243
|
const until = recorder.startedAt + opts.forSec * 1000;
|
|
3753
|
-
while (Date.now() < until) {
|
|
4244
|
+
while (Date.now() < until && !stopRequested) {
|
|
3754
4245
|
await new Promise((r) => setTimeout(r, 400));
|
|
3755
4246
|
let note = null;
|
|
3756
4247
|
try {
|
|
@@ -3765,11 +4256,39 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3765
4256
|
if (recorder.ended())
|
|
3766
4257
|
break;
|
|
3767
4258
|
}
|
|
3768
|
-
|
|
4259
|
+
let videoPath;
|
|
4260
|
+
try {
|
|
4261
|
+
videoPath = await recorder.finish();
|
|
4262
|
+
}
|
|
4263
|
+
catch (e) {
|
|
4264
|
+
if (!opts.local)
|
|
4265
|
+
throw e;
|
|
4266
|
+
// --local keeps what was recorded: the segments stay for the user.
|
|
4267
|
+
keptVideo = workDir;
|
|
4268
|
+
throw new Error(`${e.message}\nThe capture segments were kept at ${workDir}`);
|
|
4269
|
+
}
|
|
3769
4270
|
const notes = [
|
|
3770
4271
|
...opts.notes.map((n) => ({ startMs: n.startMs ?? 0, text: n.text })),
|
|
3771
4272
|
...auto,
|
|
3772
4273
|
].sort((a, b) => a.startMs - b.startMs);
|
|
4274
|
+
if (opts.local) {
|
|
4275
|
+
// A failure from here on keeps the video in the take folder.
|
|
4276
|
+
localStarted = true;
|
|
4277
|
+
releaseSignals();
|
|
4278
|
+
await finishLocalTake({
|
|
4279
|
+
videoPath,
|
|
4280
|
+
moveVideo: true,
|
|
4281
|
+
prepared,
|
|
4282
|
+
title: opts.name ?? `Screen recording of ${plan.label}`,
|
|
4283
|
+
description: opts.description,
|
|
4284
|
+
expectedResult: opts.expectedResult,
|
|
4285
|
+
recordingKind: opts.recordingKind,
|
|
4286
|
+
narration: localNarration(notes),
|
|
4287
|
+
origin: { kind: "capture", sourceName: plan.label },
|
|
4288
|
+
json: opts.json,
|
|
4289
|
+
}, { source: captureSourceResult(plan.resolved), ...(plan.windowCapture ? { windowCapture: plan.windowCapture } : {}) });
|
|
4290
|
+
return null;
|
|
4291
|
+
}
|
|
3773
4292
|
let uploaded;
|
|
3774
4293
|
try {
|
|
3775
4294
|
uploaded = await uploadVideoToClipy(ctx, {
|
|
@@ -3799,8 +4318,14 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3799
4318
|
};
|
|
3800
4319
|
}
|
|
3801
4320
|
finally {
|
|
4321
|
+
releaseSignals();
|
|
3802
4322
|
await vd?.stop();
|
|
3803
|
-
if (keptVideo)
|
|
4323
|
+
if (prepared && !localStarted && keptVideo !== workDir)
|
|
4324
|
+
await releaseLocalOut(prepared.dir);
|
|
4325
|
+
if (keptVideo === workDir) {
|
|
4326
|
+
// --local capture that could not be joined: everything stays.
|
|
4327
|
+
}
|
|
4328
|
+
else if (keptVideo) {
|
|
3804
4329
|
for (const name of readdirSync(workDir)) {
|
|
3805
4330
|
if (name.startsWith("segment-"))
|
|
3806
4331
|
rmSync(join(workDir, name), { force: true });
|
|
@@ -4026,12 +4551,200 @@ async function cmdRecordMac(opts) {
|
|
|
4026
4551
|
...(windowCapture ? { windowCapture } : {}),
|
|
4027
4552
|
};
|
|
4028
4553
|
}
|
|
4554
|
+
/** What a running app can capture, so --window/--display have ids. */
|
|
4555
|
+
function printBridgeSources(sources, json, hint) {
|
|
4556
|
+
if (json) {
|
|
4557
|
+
// Each entry carries the SAME `source` descriptor shape that
|
|
4558
|
+
// `session start --json` / `record --json` report for the resolved
|
|
4559
|
+
// capture, so a caller can compare "what I picked" against "what the
|
|
4560
|
+
// camera reports" with a direct object comparison — no transforming.
|
|
4561
|
+
printJson({
|
|
4562
|
+
displays: sources.displays.map((d) => ({ ...d, source: describeDisplay(d) })),
|
|
4563
|
+
windows: sources.windows.map((w) => ({ ...w, source: describeWindow(w) })),
|
|
4564
|
+
});
|
|
4565
|
+
return;
|
|
4566
|
+
}
|
|
4567
|
+
process.stdout.write(`${c.bold("DISPLAYS")}\n`);
|
|
4568
|
+
for (const d of sources.displays) {
|
|
4569
|
+
process.stdout.write(` ${d.id}\t${d.name || "display"}\t${c.dim(`${d.width}×${d.height}`)}\n`);
|
|
4570
|
+
}
|
|
4571
|
+
process.stdout.write(`${c.bold("WINDOWS")}\n`);
|
|
4572
|
+
for (const w of sources.windows) {
|
|
4573
|
+
process.stdout.write(` ${w.id}\t${windowLabel(w)}\t${c.dim(`${w.width}×${w.height}`)}\n`);
|
|
4574
|
+
}
|
|
4575
|
+
process.stdout.write(`${c.dim(hint)}\n`);
|
|
4576
|
+
}
|
|
4577
|
+
function appGoneMessage(state) {
|
|
4578
|
+
return state.bridge?.edition === "local"
|
|
4579
|
+
? "Clipy Local is no longer running, so the session was cleared. Start a new one."
|
|
4580
|
+
: "the Clipy app is no longer running — session cleared. Start a new one.";
|
|
4581
|
+
}
|
|
4582
|
+
/** Clipy Local through its bridge; a missing or wrong app is a clear error, never the official app. */
|
|
4583
|
+
function readLocalBridgeOrDie() {
|
|
4584
|
+
try {
|
|
4585
|
+
return readBridgeInfo("local");
|
|
4586
|
+
}
|
|
4587
|
+
catch (e) {
|
|
4588
|
+
die(e.message);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
/** Waits `seconds`, or less when Ctrl-C, SIGTERM or SIGHUP arrives (the take is still kept). */
|
|
4592
|
+
function waitOrStopSignal(seconds) {
|
|
4593
|
+
return new Promise((resolveWait) => {
|
|
4594
|
+
let dispose = () => { };
|
|
4595
|
+
const timer = setTimeout(() => {
|
|
4596
|
+
dispose();
|
|
4597
|
+
resolveWait();
|
|
4598
|
+
}, seconds * 1000);
|
|
4599
|
+
dispose = onStopSignal(() => {
|
|
4600
|
+
clearTimeout(timer);
|
|
4601
|
+
dispose();
|
|
4602
|
+
resolveWait();
|
|
4603
|
+
});
|
|
4604
|
+
});
|
|
4605
|
+
}
|
|
4606
|
+
/** Clipy Local's `stop` payload in the shape of the other --local results. */
|
|
4607
|
+
function localBridgeResultJson(result, extra = {}) {
|
|
4608
|
+
const arec = String(result.arecPath ?? "");
|
|
4609
|
+
const dir = typeof result.directory === "string" && result.directory ? result.directory : dirname(arec);
|
|
4610
|
+
const status = typeof result.status === "string" ? result.status : "processing";
|
|
4611
|
+
return {
|
|
4612
|
+
ok: status !== "failed",
|
|
4613
|
+
local: true,
|
|
4614
|
+
app: "Clipy Local",
|
|
4615
|
+
arec,
|
|
4616
|
+
arecPath: arec,
|
|
4617
|
+
dir,
|
|
4618
|
+
out: dir,
|
|
4619
|
+
video: join(dir, "recording.mp4"),
|
|
4620
|
+
status,
|
|
4621
|
+
message: typeof result.message === "string" ? result.message : "",
|
|
4622
|
+
recordingId: typeof result.recordingId === "string" ? result.recordingId : null,
|
|
4623
|
+
sizeBytes: Number(result.sizeBytes ?? 0),
|
|
4624
|
+
autoStopped: Boolean(result.autoStopped),
|
|
4625
|
+
...(result.timedOut ? { timedOut: true } : {}),
|
|
4626
|
+
...extra,
|
|
4627
|
+
};
|
|
4628
|
+
}
|
|
4629
|
+
/** The end of a Clipy Local take: the AREC path last on stdout, or one JSON object. */
|
|
4630
|
+
function reportLocalBridgeResult(result, json, extra = {}) {
|
|
4631
|
+
const out = localBridgeResultJson(result, extra);
|
|
4632
|
+
if (out.status === "failed")
|
|
4633
|
+
process.exitCode = 1;
|
|
4634
|
+
if (out.status !== "ready") {
|
|
4635
|
+
process.stderr.write(`Warning: Clipy Local reports ${out.status}${out.message ? `: ${out.message}` : ""}\n`);
|
|
4636
|
+
}
|
|
4637
|
+
if (json) {
|
|
4638
|
+
printJson(out);
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
process.stderr.write(`Done in Clipy Local (${out.status}). Nothing was uploaded. Give your AI agent the path below.\n` +
|
|
4642
|
+
`Want a share link anyone can watch, with no signup to watch? Run: clipy upload ${JSON.stringify(out.video)}\n`);
|
|
4643
|
+
process.stdout.write(`${out.arec}\n`);
|
|
4644
|
+
}
|
|
4645
|
+
/** `clipy record --local --source mac-screen`: one take through Clipy Local, kept on this computer. */
|
|
4646
|
+
async function cmdRecordMacLocal(opts) {
|
|
4647
|
+
if (maxPassRef(opts.notes) > 0) {
|
|
4648
|
+
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
4649
|
+
}
|
|
4650
|
+
const info = readLocalBridgeOrDie();
|
|
4651
|
+
const log = (m) => {
|
|
4652
|
+
if (!opts.json)
|
|
4653
|
+
process.stderr.write(`${m}\n`);
|
|
4654
|
+
};
|
|
4655
|
+
const target = await resolveBridgeTarget(info, opts);
|
|
4656
|
+
log(c.dim(`asking Clipy Local (v${info.appVersion || "?"}) to record ${target?.label ?? "the screen"}…`));
|
|
4657
|
+
if (target) {
|
|
4658
|
+
log(`${c.bold(`recording ${target.resolved.kind}:`)} "${target.resolved.title}" (id ${target.resolved.id})\n` +
|
|
4659
|
+
c.dim("confirm that is the surface you are driving; Clipy never brings it to the front for you."));
|
|
4660
|
+
}
|
|
4661
|
+
if (opts.recordingKind || opts.expectedResult) {
|
|
4662
|
+
log(c.yellow("note: --type and --expected are not applied to Clipy Local takes"));
|
|
4663
|
+
}
|
|
4664
|
+
const audioUncontrollable = warnAudioUncontrollable(info.protocolVersion, opts.audio, (m) => process.stderr.write(`${m}\n`));
|
|
4665
|
+
const windowWarned = warnWindowCaptureUnknown(info.protocolVersion, target, (m) => process.stderr.write(`${m}\n`));
|
|
4666
|
+
const startResult = await bridgeRequest(info, "start", {
|
|
4667
|
+
audio: { includeSystemAudio: opts.audio.includeSystemAudio, includeMic: opts.audio.includeMic },
|
|
4668
|
+
maxSec: Math.min(opts.forSec + 60, 1800),
|
|
4669
|
+
title: opts.name,
|
|
4670
|
+
description: opts.description,
|
|
4671
|
+
notes: resolveNarrationNotes(opts.notes, [0]).map((n) => ({ startMs: n.startMs, text: n.text })),
|
|
4672
|
+
...(target ? { source: target.source } : {}),
|
|
4673
|
+
}).catch((e) => die(e.message));
|
|
4674
|
+
const appliedAudio = reportAudio(opts.audio, echoedAudio(startResult), log, audioUncontrollable);
|
|
4675
|
+
const windowCapture = appliedWindowCapture(target, startResult, (m) => process.stderr.write(`${m}\n`), windowWarned);
|
|
4676
|
+
log(c.dim(`recording for ${opts.forSec}s (Ctrl-C stops early and keeps the take)…`));
|
|
4677
|
+
await waitOrStopSignal(opts.forSec);
|
|
4678
|
+
log(c.dim("stopping; Clipy Local is building the AREC on this computer…"));
|
|
4679
|
+
const result = await bridgeRequest(info, "stop").catch((e) => die(e.message));
|
|
4680
|
+
reportLocalBridgeResult(result, opts.json, {
|
|
4681
|
+
captureMode: "mac-screen",
|
|
4682
|
+
source: captureSourceResult(target?.resolved),
|
|
4683
|
+
audio: appliedAudio,
|
|
4684
|
+
...(windowCapture ? { windowCapture } : {}),
|
|
4685
|
+
});
|
|
4686
|
+
}
|
|
4687
|
+
/** `clipy session start --local --source mac-screen`: Clipy Local owns the take; stop returns its AREC. */
|
|
4688
|
+
async function cmdSessionStartMacLocal(opts) {
|
|
4689
|
+
const file = sessionFilePath(process.cwd());
|
|
4690
|
+
const existing = readSessionState(file);
|
|
4691
|
+
if (existing && sessionIsActive(existing)) {
|
|
4692
|
+
die("a recording session is already active here: finish it with `clipy session stop` or discard it with `clipy session abort`");
|
|
4693
|
+
}
|
|
4694
|
+
const info = readLocalBridgeOrDie();
|
|
4695
|
+
const maxSec = Math.min(Math.max(1, opts.maxSec), SESSION_HARD_CAP_SEC);
|
|
4696
|
+
const target = await resolveBridgeTarget(info, opts);
|
|
4697
|
+
if ((opts.recordingKind || opts.expectedResult) && !opts.json) {
|
|
4698
|
+
process.stderr.write(`${c.yellow("note: --type and --expected are not applied to Clipy Local takes")}\n`);
|
|
4699
|
+
}
|
|
4700
|
+
const audioUncontrollable = warnAudioUncontrollable(info.protocolVersion, opts.audio, (m) => process.stderr.write(`${m}\n`));
|
|
4701
|
+
const windowWarned = warnWindowCaptureUnknown(info.protocolVersion, target, (m) => process.stderr.write(`${m}\n`));
|
|
4702
|
+
const startResult = await bridgeRequest(info, "start", {
|
|
4703
|
+
audio: { includeSystemAudio: opts.audio.includeSystemAudio, includeMic: opts.audio.includeMic },
|
|
4704
|
+
maxSec,
|
|
4705
|
+
title: opts.name,
|
|
4706
|
+
description: opts.description,
|
|
4707
|
+
...(target ? { source: target.source } : {}),
|
|
4708
|
+
}).catch((e) => die(e.message));
|
|
4709
|
+
writeSessionState(file, macSessionState(info, maxSec));
|
|
4710
|
+
const appliedAudio = reportAudio(opts.audio, echoedAudio(startResult), (m) => process.stderr.write(`${m}\n`), audioUncontrollable);
|
|
4711
|
+
const windowCapture = appliedWindowCapture(target, startResult, (m) => process.stderr.write(`${m}\n`), windowWarned);
|
|
4712
|
+
if (opts.json) {
|
|
4713
|
+
printJson({
|
|
4714
|
+
state: "recording",
|
|
4715
|
+
local: true,
|
|
4716
|
+
app: "Clipy Local",
|
|
4717
|
+
captureMode: "mac-screen",
|
|
4718
|
+
maxSec,
|
|
4719
|
+
recordingId: typeof startResult.recordingId === "string" ? startResult.recordingId : null,
|
|
4720
|
+
arec: typeof startResult.arecPath === "string" ? startResult.arecPath : null,
|
|
4721
|
+
out: typeof startResult.directory === "string" ? startResult.directory : null,
|
|
4722
|
+
target: target?.label,
|
|
4723
|
+
source: captureSourceResult(target?.resolved),
|
|
4724
|
+
audio: appliedAudio,
|
|
4725
|
+
...(windowCapture ? { windowCapture } : {}),
|
|
4726
|
+
});
|
|
4727
|
+
return;
|
|
4728
|
+
}
|
|
4729
|
+
process.stdout.write(`${c.green("✓")} Clipy Local is recording ${target ? target.label : "your screen"} (max ${maxSec}s); nothing is uploaded\n`);
|
|
4730
|
+
if (target) {
|
|
4731
|
+
process.stdout.write(`${c.bold(`recording ${target.resolved.kind}:`)} "${target.resolved.title}" (id ${target.resolved.id})\n` +
|
|
4732
|
+
`${c.dim("confirm that is the surface you are driving; Clipy never brings it to the front for you.")}\n`);
|
|
4733
|
+
}
|
|
4734
|
+
process.stdout.write(`${c.dim("while it runs:")} clipy mark "what just happened"\n` +
|
|
4735
|
+
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
4736
|
+
}
|
|
4029
4737
|
function macSessionState(info, maxSec) {
|
|
4030
4738
|
const dir = sessionDir();
|
|
4031
4739
|
return {
|
|
4032
4740
|
version: 1,
|
|
4033
4741
|
kind: "mac",
|
|
4034
|
-
bridge: {
|
|
4742
|
+
bridge: {
|
|
4743
|
+
socketPath: info.socketPath,
|
|
4744
|
+
token: info.token,
|
|
4745
|
+
pid: info.pid,
|
|
4746
|
+
...(info.edition === "local" ? { edition: "local" } : {}),
|
|
4747
|
+
},
|
|
4035
4748
|
pid: info.pid,
|
|
4036
4749
|
cwd: process.cwd(),
|
|
4037
4750
|
url: "mac-screen",
|
|
@@ -4056,6 +4769,7 @@ function bridgeInfoFromSession(state) {
|
|
|
4056
4769
|
pid: state.bridge.pid,
|
|
4057
4770
|
appVersion: "",
|
|
4058
4771
|
protocolVersion: 1,
|
|
4772
|
+
edition: state.bridge.edition ?? "cloud",
|
|
4059
4773
|
};
|
|
4060
4774
|
}
|
|
4061
4775
|
/** The ready-to-run Playwright snippet printed after `session start --expose-cdp`.
|
|
@@ -4299,6 +5013,12 @@ async function cmdSessionStartExtension(opts) {
|
|
|
4299
5013
|
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
4300
5014
|
}
|
|
4301
5015
|
async function cmdSessionStart(ctx, opts) {
|
|
5016
|
+
if (opts.local && opts.source === "chrome-extension")
|
|
5017
|
+
die(LOCAL_EXTENSION_REFUSAL, 2);
|
|
5018
|
+
if (opts.local && opts.source === "mac-screen") {
|
|
5019
|
+
await cmdSessionStartMacLocal(opts);
|
|
5020
|
+
return;
|
|
5021
|
+
}
|
|
4302
5022
|
if (opts.source === "chrome-extension") {
|
|
4303
5023
|
await cmdSessionStartExtension(opts);
|
|
4304
5024
|
return;
|
|
@@ -4385,7 +5105,9 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4385
5105
|
validateAuthCapture(opts.auth, target.href); // usage errors (exit 2) before auth/daemonizing
|
|
4386
5106
|
if (opts.userDataDir)
|
|
4387
5107
|
validateUserDataDir(opts.userDataDir, opts.profileDirectory);
|
|
4388
|
-
const key = requireKey(ctx);
|
|
5108
|
+
const key = opts.local ? null : requireKey(ctx);
|
|
5109
|
+
// Chrome for Clipy records the tab's audio; headless captures are silent.
|
|
5110
|
+
const localOut = opts.local ? await localSessionOut(opts.local.out, opts.local.force, opts.json, isChromeForClipy) : undefined;
|
|
4389
5111
|
await loadChromium(); // fail fast with install instructions before daemonizing
|
|
4390
5112
|
// Chrome for Clipy is started HERE, in the parent, so a missing Chrome or a
|
|
4391
5113
|
// dead CDP port is a loud immediate error rather than a daemon-log mystery.
|
|
@@ -4438,6 +5160,7 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4438
5160
|
localStorageSpecs: opts.auth.localStorageSpecs.length ? opts.auth.localStorageSpecs : undefined,
|
|
4439
5161
|
userDataDir: launchUserDataDir,
|
|
4440
5162
|
profileScratchRoot,
|
|
5163
|
+
...(localOut ? { local: { out: localOut } } : {}),
|
|
4441
5164
|
state: "starting",
|
|
4442
5165
|
marksPath: join(dir, `marks-${id}.jsonl`),
|
|
4443
5166
|
controlPath: join(dir, `control-${id}.json`),
|
|
@@ -4450,7 +5173,7 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4450
5173
|
stdio: ["ignore", logFd, logFd],
|
|
4451
5174
|
env: {
|
|
4452
5175
|
...process.env,
|
|
4453
|
-
CLIPY_API_KEY: key,
|
|
5176
|
+
...(key ? { CLIPY_API_KEY: key } : {}),
|
|
4454
5177
|
CLIPY_API_URL: ctx.apiUrl,
|
|
4455
5178
|
},
|
|
4456
5179
|
});
|
|
@@ -4487,10 +5210,13 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4487
5210
|
sessionFile: file,
|
|
4488
5211
|
cdpUrl: started?.cdpUrl ?? null,
|
|
4489
5212
|
cdpHttpUrl: started?.cdpHttpUrl ?? null,
|
|
5213
|
+
...(localOut ? { local: true, out: localOut } : {}),
|
|
4490
5214
|
});
|
|
4491
5215
|
return;
|
|
4492
5216
|
}
|
|
4493
5217
|
process.stdout.write(`${c.green("✓")} recording ${c.bold(target.href)} (max ${maxSec}s)\n`);
|
|
5218
|
+
if (localOut)
|
|
5219
|
+
process.stdout.write(`${c.dim("local mode:")} nothing is uploaded; the AREC is written to ${localOut} at stop\n`);
|
|
4494
5220
|
if (started?.cdpHttpUrl) {
|
|
4495
5221
|
process.stdout.write(`${c.yellow("⚠ CDP exposed:")} any local process can attach to and control this browser while the session runs.\n`);
|
|
4496
5222
|
process.stdout.write(`${cdpDriverSnippet(started.cdpHttpUrl)}\n`);
|
|
@@ -4598,7 +5324,7 @@ async function cmdMark(text, json, opts) {
|
|
|
4598
5324
|
const result = await bridgeRequest(bridgeInfoFromSession(state), "mark", { text: macText }).catch((e) => {
|
|
4599
5325
|
if (e instanceof BridgeUnavailableError) {
|
|
4600
5326
|
cleanupSessionFiles(state, file);
|
|
4601
|
-
die(
|
|
5327
|
+
die(appGoneMessage(state));
|
|
4602
5328
|
}
|
|
4603
5329
|
die(e.message);
|
|
4604
5330
|
});
|
|
@@ -4723,7 +5449,7 @@ async function cmdChapter(label, json) {
|
|
|
4723
5449
|
const result = await bridgeRequest(bridgeInfoFromSession(state), "mark", { text: chapterText }).catch((e) => {
|
|
4724
5450
|
if (e instanceof BridgeUnavailableError) {
|
|
4725
5451
|
cleanupSessionFiles(state, file);
|
|
4726
|
-
die(
|
|
5452
|
+
die(appGoneMessage(state));
|
|
4727
5453
|
}
|
|
4728
5454
|
die(e.message);
|
|
4729
5455
|
});
|
|
@@ -4766,8 +5492,10 @@ async function cmdChapter(label, json) {
|
|
|
4766
5492
|
process.stdout.write(`${c.green("✓")} chapter @ ${(tMs / 1000).toFixed(1)}s — ${label}\n`);
|
|
4767
5493
|
}
|
|
4768
5494
|
}
|
|
4769
|
-
async function cmdSessionStop(json) {
|
|
5495
|
+
async function cmdSessionStop(json, local = false) {
|
|
4770
5496
|
const { file, state } = requireSession();
|
|
5497
|
+
if (local)
|
|
5498
|
+
refuseLocalFlagOnUploadSession(state);
|
|
4771
5499
|
if (state.kind === "chrome-extension") {
|
|
4772
5500
|
if (!json)
|
|
4773
5501
|
process.stderr.write(`${c.dim("stopping; the extension is uploading…")}\n`);
|
|
@@ -4805,8 +5533,10 @@ async function cmdSessionStop(json) {
|
|
|
4805
5533
|
return;
|
|
4806
5534
|
}
|
|
4807
5535
|
if (state.kind === "mac") {
|
|
4808
|
-
|
|
4809
|
-
|
|
5536
|
+
const localApp = state.bridge?.edition === "local";
|
|
5537
|
+
if (!json) {
|
|
5538
|
+
process.stderr.write(`${c.dim(localApp ? "stopping; Clipy Local is building the AREC on this computer…" : "stopping + uploading…")}\n`);
|
|
5539
|
+
}
|
|
4810
5540
|
// No daemon on the mac path to merge a tally, so emit the [verification]
|
|
4811
5541
|
// summary ourselves as a final bridge mark (stamped at stop) BEFORE stopping.
|
|
4812
5542
|
const macTally = verificationNote({
|
|
@@ -4826,6 +5556,10 @@ async function cmdSessionStop(json) {
|
|
|
4826
5556
|
die(e.message);
|
|
4827
5557
|
});
|
|
4828
5558
|
cleanupSessionFiles(state, file);
|
|
5559
|
+
if (localApp) {
|
|
5560
|
+
reportLocalBridgeResult(result, json);
|
|
5561
|
+
return;
|
|
5562
|
+
}
|
|
4829
5563
|
const publicId = String(result.publicId ?? "");
|
|
4830
5564
|
reportSessionResult({
|
|
4831
5565
|
publicId,
|
|
@@ -4838,8 +5572,8 @@ async function cmdSessionStop(json) {
|
|
|
4838
5572
|
if (!pidAlive(state.pid)) {
|
|
4839
5573
|
// Daemon already gone: it may have finished (auto-stop at max duration)
|
|
4840
5574
|
// or crashed. Report whatever terminal state it left behind.
|
|
4841
|
-
if (state.state === "done" && state.result) {
|
|
4842
|
-
|
|
5575
|
+
if (state.state === "done" && (state.result || state.localResult)) {
|
|
5576
|
+
reportSessionOutcome(state, json);
|
|
4843
5577
|
cleanupSessionFiles(state, file);
|
|
4844
5578
|
return;
|
|
4845
5579
|
}
|
|
@@ -4851,20 +5585,20 @@ async function cmdSessionStop(json) {
|
|
|
4851
5585
|
}
|
|
4852
5586
|
writeFileSync(state.controlPath, JSON.stringify({ action: "stop" }));
|
|
4853
5587
|
if (!json)
|
|
4854
|
-
process.stderr.write(`${c.dim("stopping + uploading…")}\n`);
|
|
5588
|
+
process.stderr.write(`${c.dim(state.local ? "stopping; building the AREC on this machine…" : "stopping + uploading…")}\n`);
|
|
4855
5589
|
// Stop = close browser + upload; give long recordings room to finish.
|
|
4856
5590
|
const deadline = Date.now() + 600_000;
|
|
4857
5591
|
for (;;) {
|
|
4858
5592
|
const s = readSessionState(file);
|
|
4859
|
-
if (s?.state === "done" && s.result) {
|
|
4860
|
-
|
|
5593
|
+
if (s?.state === "done" && (s.result || s.localResult)) {
|
|
5594
|
+
reportSessionOutcome(s, json);
|
|
4861
5595
|
cleanupSessionFiles(s, file);
|
|
4862
5596
|
return;
|
|
4863
5597
|
}
|
|
4864
5598
|
if (s?.state === "failed") {
|
|
4865
5599
|
const keptPath = cleanupSessionFiles(s, file);
|
|
4866
5600
|
const kept = keptPath ? `\nThe capture was kept at: ${keptPath}` : "";
|
|
4867
|
-
die(
|
|
5601
|
+
die(`${s.local ? "session failed" : "session upload failed"}: ${s.error ?? "unknown"}${kept}`);
|
|
4868
5602
|
}
|
|
4869
5603
|
if (s?.state === "aborted") {
|
|
4870
5604
|
cleanupSessionFiles(s, file);
|
|
@@ -4881,6 +5615,45 @@ async function cmdSessionStop(json) {
|
|
|
4881
5615
|
await new Promise((r) => setTimeout(r, 500));
|
|
4882
5616
|
}
|
|
4883
5617
|
}
|
|
5618
|
+
/**
|
|
5619
|
+
* `session stop|status --local` on a session that was started without
|
|
5620
|
+
* --local: stopping it would upload, which --local promises never happens,
|
|
5621
|
+
* so refuse instead of quietly uploading.
|
|
5622
|
+
*/
|
|
5623
|
+
function refuseLocalFlagOnUploadSession(state) {
|
|
5624
|
+
if (state.local || state.bridge?.edition === "local")
|
|
5625
|
+
return;
|
|
5626
|
+
die("this session was started without --local and uploads on stop; use clipy session abort to discard it", 2);
|
|
5627
|
+
}
|
|
5628
|
+
/** A finished daemon session: the share link, or with --local the AREC path. */
|
|
5629
|
+
function reportSessionOutcome(state, json) {
|
|
5630
|
+
if (state.localResult) {
|
|
5631
|
+
reportLocalSessionResult(state.localResult, json);
|
|
5632
|
+
return;
|
|
5633
|
+
}
|
|
5634
|
+
if (state.result)
|
|
5635
|
+
reportSessionResult(state.result, json);
|
|
5636
|
+
}
|
|
5637
|
+
function reportLocalSessionResult(result, json) {
|
|
5638
|
+
for (const warning of result.warnings)
|
|
5639
|
+
process.stderr.write(`Warning: ${warning}\n`);
|
|
5640
|
+
if (json) {
|
|
5641
|
+
printJson(result);
|
|
5642
|
+
return;
|
|
5643
|
+
}
|
|
5644
|
+
process.stderr.write(`Done: ${result.frames} screenshot${result.frames === 1 ? "" : "s"}, ${result.transcript.segments} transcript segment${result.transcript.segments === 1 ? "" : "s"}. Nothing was uploaded. Give your AI agent the path below.\n` +
|
|
5645
|
+
`Want a share link anyone can watch, with no signup to watch? Run: clipy upload ${JSON.stringify(result.video)}\n`);
|
|
5646
|
+
process.stdout.write(`${result.arec}\n`);
|
|
5647
|
+
}
|
|
5648
|
+
/**
|
|
5649
|
+
* The folder a --local session writes to, claimed when it starts (so two
|
|
5650
|
+
* sessions started in the same second never share one). The config file,
|
|
5651
|
+
* model provider and ffmpeg are checked here too, so a mistake in them is
|
|
5652
|
+
* reported now, not after the take at `session stop`.
|
|
5653
|
+
*/
|
|
5654
|
+
async function localSessionOut(out, force, json, speech = false) {
|
|
5655
|
+
return (await prepareLocalOrExit({ out, force, json, speech })).dir;
|
|
5656
|
+
}
|
|
4884
5657
|
function reportSessionResult(result, json) {
|
|
4885
5658
|
if (json) {
|
|
4886
5659
|
printJson({
|
|
@@ -5038,7 +5811,7 @@ async function cmdSessionAbort(json) {
|
|
|
5038
5811
|
else
|
|
5039
5812
|
process.stdout.write(`${c.green("✓")} session aborted — nothing was uploaded\n`);
|
|
5040
5813
|
}
|
|
5041
|
-
async function cmdSessionStatus(json) {
|
|
5814
|
+
async function cmdSessionStatus(json, local = false) {
|
|
5042
5815
|
const file = sessionFileToUse();
|
|
5043
5816
|
const state = readSessionState(file);
|
|
5044
5817
|
if (!state) {
|
|
@@ -5048,6 +5821,8 @@ async function cmdSessionStatus(json) {
|
|
|
5048
5821
|
process.stdout.write(`${c.dim("no session in this workspace")}\n`);
|
|
5049
5822
|
return;
|
|
5050
5823
|
}
|
|
5824
|
+
if (local)
|
|
5825
|
+
refuseLocalFlagOnUploadSession(state);
|
|
5051
5826
|
if (state.kind === "chrome-extension") {
|
|
5052
5827
|
const elapsedSec = state.recordStartEpochMs ? Math.round((Date.now() - state.recordStartEpochMs) / 1000) : null;
|
|
5053
5828
|
let live;
|
|
@@ -5962,6 +6737,59 @@ async function runSessionDaemon(file) {
|
|
|
5962
6737
|
log(`mark limit: merged ${notes.length} marks — keeping the first 200 (dropped ${notes.length - 200})`);
|
|
5963
6738
|
notes = notes.slice(0, 200);
|
|
5964
6739
|
}
|
|
6740
|
+
if (state.local) {
|
|
6741
|
+
// --local: the pipeline moves the capture into the output folder first,
|
|
6742
|
+
// so a failure after that still leaves the video there.
|
|
6743
|
+
save({ state: "uploading", videoPath });
|
|
6744
|
+
const { mod, env } = await localMode();
|
|
6745
|
+
const result = await mod
|
|
6746
|
+
.runLocalTake({
|
|
6747
|
+
videoPath,
|
|
6748
|
+
moveVideo: true,
|
|
6749
|
+
out: state.local.out,
|
|
6750
|
+
// Claimed (and checked) by `session start`.
|
|
6751
|
+
outClaimed: true,
|
|
6752
|
+
title: state.name ?? (state.kind === "linux-screen" ? `Screen recording (${state.url})` : `Recording of ${state.url}`),
|
|
6753
|
+
description: state.description,
|
|
6754
|
+
expectedResult: state.expectedResult,
|
|
6755
|
+
recordingKind: state.recordingKind,
|
|
6756
|
+
narration: localNarration(notes),
|
|
6757
|
+
origin: { kind: "capture", sourceName: state.url },
|
|
6758
|
+
json: true,
|
|
6759
|
+
}, { ...env, io: { ...env.io, stderr: (m) => log(m.trim()), onInterrupt: () => () => { } } })
|
|
6760
|
+
.catch((e) => {
|
|
6761
|
+
// runLocalTake keeps the capture in the take folder and says where;
|
|
6762
|
+
// `session stop` reports that path, so the error carries only the reason.
|
|
6763
|
+
if (e instanceof mod.LocalTakeError && e.keptPath && existsSync(e.keptPath)) {
|
|
6764
|
+
save({ keptVideoPath: e.keptPath });
|
|
6765
|
+
throw new Error(e.reason);
|
|
6766
|
+
}
|
|
6767
|
+
if (existsSync(videoPath)) {
|
|
6768
|
+
const kept = join(sessionDir(), `kept-${randomUUID()}${extname(videoPath) || ".webm"}`);
|
|
6769
|
+
try {
|
|
6770
|
+
moveFile(videoPath, kept);
|
|
6771
|
+
save({ keptVideoPath: kept });
|
|
6772
|
+
}
|
|
6773
|
+
catch {
|
|
6774
|
+
save({ keptVideoPath: videoPath });
|
|
6775
|
+
}
|
|
6776
|
+
}
|
|
6777
|
+
else if (existsSync(join(state.local.out, "recording.mp4"))) {
|
|
6778
|
+
save({ keptVideoPath: join(state.local.out, "recording.mp4") });
|
|
6779
|
+
}
|
|
6780
|
+
throw e;
|
|
6781
|
+
});
|
|
6782
|
+
const localJson = mod.resultJson(result, state.kind === "linux-screen" && state.screenSource ? { source: captureSourceResult(state.screenSource) } : {});
|
|
6783
|
+
save({ state: "done", localResult: localJson });
|
|
6784
|
+
log(`done (local): ${localJson.arec}`);
|
|
6785
|
+
try {
|
|
6786
|
+
rmSync(state.tmpDir, { recursive: true, force: true });
|
|
6787
|
+
}
|
|
6788
|
+
catch {
|
|
6789
|
+
// best-effort
|
|
6790
|
+
}
|
|
6791
|
+
return;
|
|
6792
|
+
}
|
|
5965
6793
|
save({ state: "uploading", videoPath });
|
|
5966
6794
|
const uploaded = await uploadVideoToClipy(ctx, {
|
|
5967
6795
|
videoPath,
|
|
@@ -6415,7 +7243,7 @@ async function cmdAgents(ctx, sub, targetRaw, json) {
|
|
|
6415
7243
|
// command's shape without trial-and-error. Bump GUIDE_SCHEMA_VERSION when the
|
|
6416
7244
|
// contract changes.
|
|
6417
7245
|
// ---------------------------------------------------------------------------
|
|
6418
|
-
const GUIDE_SCHEMA_VERSION =
|
|
7246
|
+
const GUIDE_SCHEMA_VERSION = 22;
|
|
6419
7247
|
/** The stable machine-readable failure taxonomy carried in `--json` error
|
|
6420
7248
|
* envelopes. Codes are the contract; messages are not. Published through the
|
|
6421
7249
|
* guide so an agent discovers the full recovery table without the skill. */
|
|
@@ -6447,6 +7275,7 @@ const GUIDE_ERROR_CODES = [
|
|
|
6447
7275
|
{ code: "chrome_unavailable", meaning: "clipy recheck: Chrome for Clipy could not be started or driven", retryable: true, remediation: "run `clipy chrome status --json` and `clipy chrome start`, then re-run once" },
|
|
6448
7276
|
{ code: "start_url_unreachable", meaning: "clipy recheck: the --url page could not be opened (connection refused, unknown host)", retryable: false, remediation: "check that --url loads (is the server running, is it the right host?), then re-run" },
|
|
6449
7277
|
{ code: "recheck_upload_failed", meaning: "clipy recheck finished, but its step frames were not uploaded (a warning on an ok:true report, not a failure)", retryable: false, remediation: "the report and frames are saved locally (files.json); do not re-run the whole re-check just for the upload" },
|
|
7278
|
+
{ code: "speech_engine_required", meaning: "a --local take needs on-device transcription and the speech engine is not installed, and there was no terminal to ask in (or the user said no). Nothing was recorded", retryable: false, remediation: "with the user's consent run `clipy speech install` (downloads sherpa-onnx-node from npm, about 35 MB) or re-run with --yes; or choose another transcription option with `clipy local setup --transcribe`" },
|
|
6450
7279
|
{ code: "unknown", meaning: "an unclassified failure", retryable: true, remediation: "re-run once; if it repeats, hand the user the whole envelope as a bug report rather than improvising a workaround" },
|
|
6451
7280
|
];
|
|
6452
7281
|
function cmdGuide(json) {
|
|
@@ -6479,6 +7308,7 @@ function cmdGuide(json) {
|
|
|
6479
7308
|
{ name: "CLIPY_API_URL", description: "API base URL override (default https://clipy.online)" },
|
|
6480
7309
|
{ name: "CLIPY_DISABLE_CDP", description: "set to 1 to force session --expose-cdp off (a hard kill switch that wins over the flag)" },
|
|
6481
7310
|
{ name: "CLIPY_SESSION_FILE", description: "path to a session state file that mark/chapter/session stop|abort|status resolve FIRST (before the cwd hash). `session run` exports it to the child so a driver can mark from any cwd." },
|
|
7311
|
+
{ name: "CLIPY_LOCAL_BRIDGE_FILE", description: "path to Clipy Local's agent-bridge.json (default ~/Library/Application Support/Clipy Local/agent-bridge.json). Only --local commands read it; they never read the official app's file." },
|
|
6482
7312
|
{ name: "NO_COLOR", description: "disable ANSI color" },
|
|
6483
7313
|
],
|
|
6484
7314
|
exitCodes: [
|
|
@@ -6529,12 +7359,21 @@ function cmdGuide(json) {
|
|
|
6529
7359
|
cmdDoc("session", "clipy session <start|run|stop|abort|status> [--url <url>] [--max sec] [--type kind] [--expected text] [--source web|screen|chrome-for-clipy|chrome-extension] [--window w] [--display d] [--x-display :N] [--virtual-display] [--expose-cdp] [--diagnostics off|errors|all] [--network-detail] [--storage-state f] [--cookie 'n=v']… [--local-storage 'k=v']… [--init-script f] [--json]", "Background recording session; auto-stops + uploads at --max (default 600s, cap 1800s). --type sets the recording kind (see record). --expected states what should have happened, shown to agents as the recording's Expected result (web, chrome-for-clipy and Linux screen sessions; for the others run clipy update afterwards). Web and chrome-for-clipy sessions attach browser evidence read from the browser itself (console output, uncaught errors, failed requests including GraphQL errors, WebSocket activity, environment) as the recording's browser diagnostics: --diagnostics errors (default) keeps warnings/errors and failures, all keeps every message and request, off keeps none; --network-detail also keeps request/response headers and text bodies (cookie and authorization headers never leave the machine; the server redacts the rest by field name and value pattern). With --source screen (mac-screen on macOS), --window records that window by itself (windows on top of it stay out only when --json reports windowCapture \"window\"; \"area\", from a Clipy Mac app older than bridge protocol v3 or on ffmpeg older than 5.1, records whatever is on top, and on Linux covered parts are black without a compositor) and --display records one display; on Linux --x-display :N picks the X display and --virtual-display records a private X display whose name is returned as xDisplay (session run exports it to the command as DISPLAY). --source chrome-extension records ONE TAB through the Clipy extension inside Chrome for Clipy (needs a one-time clipy chrome setup): no daemon, the extension records and uploads; start returns cdpHttpUrl and the recorded tab's url (opened in the background, never focused), --name titles the recording, the tab's sound is left out unless --tab-audio (detected speech would replace the marks as the transcript), mark/chapter (plain or --observed/--verdict, not --assert-*) are kept by the CLI and sent at stop as the transcript, stop waits for the upload and returns the link. --source chrome-for-clipy records ONE TAB (tab video + tab audio, no picker or gesture) inside the persistent Chrome for Clipy instance: the instance is started automatically (sign in once via clipy chrome start and the profile stays signed in), the recorded tab opens at --url, its CDP endpoint is always published as cdpUrl/cdpHttpUrl so drivers attach to the very browser being recorded, and stopping the session leaves Chrome for Clipy running; auth-capture flags and --user-data-dir are rejected for this source. --expose-cdp (web sessions) opens a CDP endpoint (cdpUrl/cdpHttpUrl in the state file + session start/status output) so your own tools can drive the page while it records; OFF by default (any local process could attach), and CLIPY_DISABLE_CDP=1 forces it off. `session run [start flags] -- <command…>` starts a session, runs the command with inherited stdio (env CLIPY_SESSION=1, plus CLIPY_CDP_URL when --expose-cdp, plus CLIPY_TARGET_ID/CLIPY_PAGE_WS_URL for the recorded tab with --source chrome-extension), then GUARANTEES cleanup: exit 0 uploads, any non-zero exit or signal discards (session abort) and propagates the child's code. It is the crash-safe wrapper, so a dead driver never records dead air. Accepts the same auth flags as record (--storage-state/--user-data-dir/--profile-directory/--cookie/--local-storage/--init-script; web only, rejected on --source mac-screen). `session run` exports CLIPY_SESSION_FILE to the child so mark/chapter resolve the session from any cwd. --json is supported on start/stop/status (start returns cdpUrl/cdpHttpUrl)", ["run", "--url", "--max", "--type", "--expected", "--source", "--window", "--display", "--x-display", "--virtual-display", "--tab-audio", "--expose-cdp", "--diagnostics", "--network-detail", "--storage-state", "--user-data-dir", "--profile-directory", "--cookie", "--local-storage", "--init-script", "--json"]),
|
|
6530
7360
|
cmdDoc("mark", "clipy mark \"<text>\" [--observed \"<values>\" --verdict pass|fail] [--assert-selector <css> [--assert-text <substr>]] [--assert-url <glob>] [--fail-mode warn|abort] [--at <sec>|--ago <sec>] [--json]", "Drop a live-timestamped note into the active session. A mark carries at most ONE evidence provenance, and the two are labeled + tallied separately so they can never be pooled. DRIVER-ATTESTED (--observed '<values>' --verdict pass|fail, both required together): you drove the browser and report what YOU observed — renders '<text> [≈ ASSERT driver-attested; observed=<values>]' (pass) / '<text> [≈ FAILED driver-attested; observed=<values>]' (fail) — a HEDGE glyph, never ✓/✗, so a skim distinguishes provenance by shape alone and works in EVERY session type including --source mac-screen. Honesty rule: driver-attested means Clipy vouches the agent SAID it, not that Clipy verified it — put real observed values there. Combining --observed/--verdict with --assert-* is a usage error. CLIPY-VERIFIED assertion marks (Clipy-owned page only) make the note evidence Clipy itself checked: --assert-selector checks a CSS selector matches (its trimmed textContent is recorded as 'observed'); --assert-text requires that element's text to contain a substring (needs --assert-selector); --assert-url matches the page URL against a glob (** = any, * = any non-slash, no * = substring). The daemon evaluates against its live page and annotates the mark: pass ⇒ '<text> [assert ✓ verified-by-clipy; <observed>]', fail ⇒ '<text> [ASSERT ✗ verified-by-clipy; expected …; observed …]' — a false claim cannot read as fact. --fail-mode warn (default) records the ✗; --fail-mode abort DISCARDS the whole session on a failed assertion (no upload) and the CLI exits non-zero. If any assertion was attempted, a leading 0ms [verification] note is prepended, reporting the provenances as SEPARATE segments: '[verification] N clipy-verified: P passed, F failed, K unverified · M driver-attested: P passed, F failed' (a segment is omitted when empty; with only clipy-verified marks the legacy 'N assertion(s): …' rendering is byte-identical). --at <sec> stamps at an absolute recording time; --ago <sec> stamps N seconds before now (mutually exclusive). Assertions/backdating need a web session (rejected on --source mac-screen). Up to 200 marks per recording.", ["--observed", "--verdict", "--assert-selector", "--assert-text", "--assert-url", "--fail-mode", "--at", "--ago", "--json"]),
|
|
6531
7361
|
cmdDoc("chapter", "clipy chapter \"<label>\" [--json]", "Mark a BEFORE/AFTER section boundary in the active recording (stored as '=== CHAPTER: <label> ==='). The PR-review shape: demo the base branch, run `clipy chapter \"AFTER — fix applied\"`, swap branches + restart the dev server, demo the fix — one video carrying both states. Works on web + --source mac-screen sessions.", ["--json"]),
|
|
6532
|
-
cmdDoc("doctor", "clipy doctor [--json]", "One-shot health check: API reachability (GET /api/health, with latency), API key + whoami round-trip, Mac agent bridge (exists/parses/pid/appVersion>=" + MIN_BRIDGE_APP_VERSION + "), Playwright resolvability (and the resolved path/node_modules dir), context/proof prerequisites (yt-dlp presence/path/version, ffmpeg + ffprobe presence/version, and whether that ffmpeg has libwebp), and install mode (npx/global/local)
|
|
7362
|
+
cmdDoc("doctor", "clipy doctor [--json] [--local]", "One-shot health check: API reachability (GET /api/health, with latency), API key + whoami round-trip, Mac agent bridge (exists/parses/pid/appVersion>=" + MIN_BRIDGE_APP_VERSION + "), Playwright resolvability (and the resolved path/node_modules dir), context/proof prerequisites (yt-dlp presence/path/version, ffmpeg + ffprobe presence/version, and whether that ffmpeg has libwebp), and install mode (npx/global/local), each a pass/warn/fail with a fix hint; exits non-zero if any check fails. Read-only: it never installs anything, so a missing yt-dlp/ffmpeg reports WARN with the install command rather than silently downloading a binary. Run it first whenever an import, proof, or recording fails. With --local it checks only local mode (config, models, speech engine, capture) and makes no request to Clipy.", ["--json", "--local"]),
|
|
6533
7363
|
cmdDoc("playwright-path", "clipy playwright-path [--json]", "Print the node_modules directory of the Playwright this CLI resolves, so your own --expose-cdp driver scripts can load the same copy: NODE_PATH=$(clipy playwright-path) node driver.js. Exits 1 (empty stdout) if Playwright is unresolvable. --json prints {path, nodeModulesDir, source}", ["--json"]),
|
|
6534
7364
|
cmdDoc("sources", "clipy sources [--x-display :N] [--json]", "List displays + windows that --source screen can capture (the Clipy Mac app's on macOS; the X display's on Linux, where listing windows needs x11-utils) — ids feed --window/--display. --json gives each entry a `source` {kind,id,title} in the SAME shape session start/record report for the resolved capture, so a caller can compare what it picked against what the camera reports without transforming either."),
|
|
6535
7365
|
cmdDoc("setup", "clipy setup [claude|codex|cursor|windsurf|opencode] [--with-browser] [--json]", "Wire Clipy into one coding agent in a single command: sign in if needed, install the bundled skill, and register the MCP server in that agent's own config (`claude`/`codex` through their own `mcp add`; `cursor`/`windsurf`/`opencode` by merging their JSON config, never replacing other servers). Omit the agent to auto-detect from the environment — ambiguous or unknown exits 2 rather than guessing. Re-running is safe. Successful --json output is {ok:true, target, skill:{installed,path}, mcp:{method,path,changed,alreadyPresent}, authenticated:true, restartRequired:true}. Failures use {ok:false,code,error,remediation,partial}; partial.mcp.method 'manual' means the caller must run partial.mcp.command or paste partial.mcp.snippet before setup is complete. The MCP server is read at agent startup, so the calling session will not see the tools until it restarts. --with-browser additionally provisions Chrome for Clipy, the agent-owned automation browser (see chrome): on macOS it installs the launcher app once, then it starts the instance. Its outcome is reported under a `browser` key ({ok, chrome:{appInstalled, appPath?, running, error?}}) and a browser failure never fails core setup.", ["--with-browser", "--json"]),
|
|
6536
7366
|
cmdDoc("agents", "clipy agents <status|install|uninstall> <claude|codex|cursor|windsurf|opencode>", "Skill file only — does NOT register MCP. `clipy setup` is the one-command form; install triggers a browser login first when no key is configured (interactive terminals only)"),
|
|
6537
7367
|
cmdDoc("chrome", "clipy chrome <setup|start|stop|status|install-app> [--port <n>] [--foreground] [--json]", "setup (one time, for --source chrome-extension): starts Chrome for Clipy, opens the Clipy extension's Web Store page and then clipy.online in that window, and waits up to 15 minutes until the extension reports it is installed and signed in; returns {ok:true, extension:{version,email}, chrome} and is a quick check on a ready machine. The two steps it waits for are the user's: an agent relays them and never performs them. Chrome for Clipy also launches with --allowlisted-extension-id (CLIPY_EXTENSION_ID overrides the store id), and an instance found running without the current flags is relaunched. Launch and manage 'Chrome for Clipy', a dedicated persistent automation browser: its own profile (sign in once, identity persists across launches), CDP on --port (default 9333) for any driver, --auto-select-tab-capture-source-by-title so a page's getDisplayMedia captures the tab whose title starts with the 'clipy-rec' marker without any picker or gesture UI, and background-throttling disabled so hidden tabs keep rendering. start is idempotent (re-reports the running instance) and, on macOS, launches in the background without taking focus from the app the user is in (--foreground brings the window forward, e.g. to sign in; setup always does); status returns {running,pid,port,cdpUrl,cdpReady,profileDir,appInstalled,captureTitleMarker}; install-app writes a named 'Chrome for Clipy.app' launcher into ~/Applications (macOS only). Drivers attach over raw CDP; no extension is needed.", ["--port", "--foreground", "--json"]),
|
|
7368
|
+
cmdDoc("record --local", "clipy record --local [--max sec] [--mic] [--virtual-display] [--display <id>|--window <id>] [--url <u>] [--source screen] [--note '12: text']… [--title t] [--out dir] [--json]", "Local mode: no Clipy account and nothing uploaded. The capture is the same as without --local (with --url the headless browser capture, silent; with --source screen on Linux the X11 recorder, timed by --for or --max; with --source screen or mac-screen on macOS, Clipy Local, the open-source local edition of the Mac app, records through its agent bridge for --for or --max seconds (default 15, cap 1740; Ctrl-C stops early and keeps the take), never the official Clipy app, and fails with a clear message when Clipy Local is not running; --window and --display name a window or display Clipy Local can see; --out and --force do not apply because Clipy Local keeps each take in its own folder); with no --url and no --source, or --source screen on Windows, the CLI's local screen recorder (ffmpeg) runs until Enter, Ctrl-C, SIGTERM, SIGHUP or --max (with no --max and stdin not a terminal, also until stdin closes, with a warning), with the microphone only on --mic. The config file, model provider, ffmpeg and --out are checked before recording starts; a later failure keeps the capture and prints where. Then, on this machine: transcription (the configured engine; skipped when the capture has no audio track), key moments (rules for highlights, drawings, clicks and pointer rests, plus spoken references when a model provider is configured), one frame per moment, and an AREC 1.4 folder: recording.mp4, transcript.json, moments.json, frames/, recording.arec. Notes become narration in the transcript and a key moment each. Default folder ~/clipy/recordings/<YYYY-MM-DD-HHMMSS>/ (mode 0700), or --out; an --out that holds files is refused (exit 2) unless --force, which replaces the previous take's files there. The last stdout line is the absolute recording.arec path; --json prints {ok:true, local:true, arec, dir, video, durationMs, moments, frames, planner, transcript:{engine,segments}, warnings}; a failure prints {ok:false, local:true, error, keptVideo?}. A Clipy Local take prints {ok, local:true, app:\"Clipy Local\", arec, arecPath, dir, out, video, status (ready, failed, or the stage still running when the 300 s processing wait ran out, with timedOut:true), message, recordingId, sizeBytes, autoStopped, captureMode:\"mac-screen\", source, audio}; status failed exits 1 and still prints the Partial AREC path. Data boundary: with no provider (or Ollama/LM Studio) and on-device transcription, nothing leaves the machine; with a model provider, the transcript text, click labels and a bounded sample of pointer and key events go to it; with a transcription key, the audio goes to that provider. The video and screenshots never leave the machine. Share later with `clipy upload <dir>/recording.mp4` (needs an account; watching needs no signup).", ["--local", "--max", "--for", "--mic", "--virtual-display", "--display", "--window", "--url", "--source", "--note", "--title", "--description", "--type", "--expected", "--width", "--height", "--out", "--force", "--json"]),
|
|
7369
|
+
cmdDoc("session start --local", "clipy session start [--url <u>] [--source web|screen|chrome-for-clipy] --local [--out dir] [--force] [--max sec] [--json]", "Same lifecycle as session start (mark, chapter, stop, abort, run), but `session stop` builds the AREC on this machine instead of uploading; marks become narration and key moments. Works for headless web, --source screen on Linux, chrome-for-clipy, and --source screen or mac-screen on macOS, which drives Clipy Local (the open-source local edition of the Mac app) through its agent bridge: never the official Clipy app, no sign-in, marks and chapters become narration in its transcript and a key moment each, start --json returns {state, local:true, app:\"Clipy Local\", recordingId, arec, out, source, audio}, and stop waits up to 300 s for Clipy Local to finish processing and prints the Clipy Local result described under record --local (--out and --force do not apply). Refused for chrome-extension. Otherwise start checks the config, model provider and ffmpeg, and claims the output folder, so two sessions never share one. start --json adds {local:true, out}; stop prints the same result as record --local. `session stop --local` and `session status --local` exit 2 on a session started without --local (it would upload; discard it with session abort).", ["--local", "--out", "--force", "--url", "--source", "--max", "--json"]),
|
|
7370
|
+
cmdDoc("proof --local", "clipy proof (--frame <img>… [--caption t]… | --video <file>) --local [--out dir] [--force] [--json]", "Builds the proof video as usual and then the local AREC instead of uploading. Each frame (and its caption) becomes narration and a key moment framed mid-hold; --note values become narration. --for is refused (it links to a hosted recording).", ["--local", "--frame", "--caption", "--video", "--hold", "--note", "--title", "--out", "--force", "--json"]),
|
|
7371
|
+
cmdDoc("context import --local", "clipy context import <file|url> --local [--transcript <vtt|srt|json>] [--out dir] [--force] [--title t] [--json]", "A local video file: transcribes it on this machine (or with the configured key) unless --transcript is given, picks moments, extracts frames and writes the full local AREC folder; --language, --tag, --folder and --no-frames do not apply to a file and are refused. YouTube and Loom URLs with --local keep the usual transcript-only bundle in --out (fetched on this machine, nothing sent to Clipy); --sync is refused with --local.", ["--local", "--transcript", "--out", "--force", "--title", "--json"]),
|
|
7372
|
+
cmdDoc("local setup", "clipy local setup [--model-provider openrouter|openai|gemini|groq|ollama|lmstudio|custom|none] [--model-key -] [--model m] [--base-url u] [--transcribe local-english|local-multilingual|openai|groq|deepgram|assemblyai|elevenlabs|gemini|none] [--transcribe-key -] [--json]", "Saves local mode's settings (config file mode 0600; keys are never printed). The model provider reads the transcript to pick spoken references; no provider means rules only. Transcription defaults to the on-device english-fast model. Keys: prefer the CLIPY_MODEL_API_KEY and CLIPY_TRANSCRIBE_API_KEY env vars; `--model-key -` or `--transcribe-key -` reads the key from stdin (one line). A literal key still works but can stay in shell history and the process list, and a note says so. Env vars override the file: CLIPY_MODEL_PROVIDER, CLIPY_MODEL_BASE_URL, CLIPY_MODEL_API_KEY, CLIPY_MODEL, CLIPY_TRANSCRIBE, CLIPY_TRANSCRIBE_API_KEY, CLIPY_TRANSCRIBE_MODEL, CLIPY_TRANSCRIBE_BASE_URL, CLIPY_LOCAL_CONFIG.", ["--model-provider", "--model-key", "--model", "--base-url", "--transcribe", "--transcribe-key", "--json"]),
|
|
7373
|
+
cmdDoc("local status", "clipy local status [--json]", "Local mode at a glance: config file path, moment selection, transcription, which speech models are installed, whether the speech engine is installed, and whether screen capture is ready. Never fails.", ["--json"]),
|
|
7374
|
+
cmdDoc("models", "clipy models list | clipy models download <english-fast|multilingual> [--json]", "On-device speech models for local transcription: english-fast (NVIDIA Parakeet TDT-CTC 110M, CC-BY-4.0, about 104 MB) and multilingual (OpenAI Whisper base, MIT, about 161 MB), both run with sherpa-onnx (Apache-2.0). list shows each model's licence (--json: license, attribution). Downloaded only on request, checksum-verified, into the platform cache folder; Ctrl-C or SIGTERM cancels a download and removes the partial files. They run with the speech engine (clipy speech install); after a download it is offered, and installed with --yes.", ["--json"]),
|
|
7375
|
+
cmdDoc("speech", "clipy speech status | clipy speech install [--json]", "The on-device speech engine (sherpa-onnx-node 2.0.1, about 35 MB from npm) that runs the speech models. It is not installed with the CLI. The first local take that needs on-device transcription asks before downloading it into a Clipy folder in the user cache; with no terminal (agents, CI, --json) that take stops before recording with code speech_engine_required. Accept up front with clipy speech install, --yes on the take, or CLIPY_INSTALL_SPEECH_ENGINE=1. CLIPY_SPEECH_ENGINE_DIR moves the folder.", ["--json"]),
|
|
7376
|
+
cmdDoc("sources --local", "clipy sources --local [--source mac-screen] [--json]", "Screens and windows the local recorder (record --local) can capture, with ids for --display/--window. With --source mac-screen (or screen on macOS), the displays and windows Clipy Local can capture instead, in the same shape as clipy sources: the ids --window/--display take with --source mac-screen --local.", ["--local", "--source", "--json"]),
|
|
6538
7377
|
cmdDoc("guide", "clipy guide --json", "This manifest"),
|
|
6539
7378
|
cmdDoc("mcp", "clipy mcp", "Run the Clipy MCP server (wraps npx -y @clipy/mcp)"),
|
|
6540
7379
|
],
|
|
@@ -6745,6 +7584,15 @@ async function main() {
|
|
|
6745
7584
|
cursor: { type: "string" },
|
|
6746
7585
|
version: { type: "boolean", short: "v", default: false },
|
|
6747
7586
|
help: { type: "boolean", short: "h", default: false },
|
|
7587
|
+
// Local mode: build the AREC on this machine, upload nothing.
|
|
7588
|
+
local: { type: "boolean", default: false },
|
|
7589
|
+
force: { type: "boolean", default: false },
|
|
7590
|
+
"model-provider": { type: "string" },
|
|
7591
|
+
"model-key": { type: "string" },
|
|
7592
|
+
model: { type: "string" },
|
|
7593
|
+
"base-url": { type: "string" },
|
|
7594
|
+
transcribe: { type: "string" },
|
|
7595
|
+
"transcribe-key": { type: "string" },
|
|
6748
7596
|
},
|
|
6749
7597
|
});
|
|
6750
7598
|
const expectedResult = values.expected?.trim() || undefined;
|
|
@@ -6761,12 +7609,22 @@ async function main() {
|
|
|
6761
7609
|
apiKey: values.key || process.env.CLIPY_API_KEY || cfg.apiKey || null,
|
|
6762
7610
|
};
|
|
6763
7611
|
const [command, ...rest] = positionals;
|
|
7612
|
+
localAssumeYes = values.yes === true;
|
|
6764
7613
|
if (!command || values.help || command === "help") {
|
|
6765
7614
|
process.stdout.write(HELP);
|
|
6766
7615
|
if (!command && !values.help)
|
|
6767
7616
|
process.exitCode = 2;
|
|
6768
7617
|
return;
|
|
6769
7618
|
}
|
|
7619
|
+
// --local promises that nothing is uploaded, so a command that cannot keep
|
|
7620
|
+
// that promise refuses the flag instead of quietly ignoring it.
|
|
7621
|
+
if (values.local) {
|
|
7622
|
+
const localCapable = ["record", "session", "proof", "sources", "local", "models", "speech", "mark", "chapter", "guide", "doctor"].includes(command) ||
|
|
7623
|
+
(command === "context" && rest[0] === "import");
|
|
7624
|
+
if (!localCapable) {
|
|
7625
|
+
die(`--local does not apply to \`clipy ${command}${command === "context" && rest[0] ? ` ${rest[0]}` : ""}\`. It works with record, session, proof, context import and sources.`, 2);
|
|
7626
|
+
}
|
|
7627
|
+
}
|
|
6770
7628
|
const json = Boolean(values.json);
|
|
6771
7629
|
const num = (v, dflt) => {
|
|
6772
7630
|
const n = parseInt(String(v ?? ""), 10);
|
|
@@ -6913,14 +7771,42 @@ async function main() {
|
|
|
6913
7771
|
// by that name, which is why they can never be confused for one.
|
|
6914
7772
|
if (rest[0] === "import") {
|
|
6915
7773
|
if (!rest[1])
|
|
6916
|
-
die("usage: clipy context import <youtube-url|loom-url|local-file> [--transcript <f>] [--output <dir>] [--sync]", 2);
|
|
7774
|
+
die("usage: clipy context import <youtube-url|loom-url|local-file> [--transcript <f>] [--output <dir>] [--sync] [--local [--out <dir>]]", 2);
|
|
7775
|
+
if (values.local && values.sync) {
|
|
7776
|
+
die("--sync uploads to your Clipy library; it does not go with --local", 2);
|
|
7777
|
+
}
|
|
7778
|
+
const localOut = (values.out ?? values.output)?.trim() || undefined;
|
|
7779
|
+
if (values.local && existsSync(resolve(rest[1])) && statSync(resolve(rest[1])).isFile()) {
|
|
7780
|
+
// These shape a URL import or a library sync; a local file's take has
|
|
7781
|
+
// no use for them, so say so instead of dropping them silently.
|
|
7782
|
+
const ignored = [
|
|
7783
|
+
values.language !== undefined ? "--language" : null,
|
|
7784
|
+
values.tag !== undefined ? "--tag" : null,
|
|
7785
|
+
values.folder !== undefined ? "--folder" : null,
|
|
7786
|
+
values["no-frames"] ? "--no-frames" : null,
|
|
7787
|
+
].filter((flag) => flag !== null);
|
|
7788
|
+
if (ignored.length > 0) {
|
|
7789
|
+
die(`${ignored.join(", ")} ${ignored.length === 1 ? "does" : "do"} not apply to context import <file> --local: transcription follows clipy local setup, and every key moment gets a frame. Drop ${ignored.length === 1 ? "it" : "them"}.`, 2);
|
|
7790
|
+
}
|
|
7791
|
+
await cmdContextImportLocal(rest[1], {
|
|
7792
|
+
transcriptPath: values.transcript,
|
|
7793
|
+
out: localOut,
|
|
7794
|
+
force: Boolean(values.force),
|
|
7795
|
+
title: values.title?.trim() || undefined,
|
|
7796
|
+
json,
|
|
7797
|
+
});
|
|
7798
|
+
return;
|
|
7799
|
+
}
|
|
7800
|
+
// A YouTube or Loom URL with --local: the import already builds its
|
|
7801
|
+
// bundle on this machine and never calls Clipy without --sync.
|
|
6917
7802
|
try {
|
|
6918
7803
|
await cmdContextImport(rest[1], {
|
|
6919
7804
|
apiUrl: ctx.apiUrl,
|
|
6920
7805
|
apiKey: ctx.apiKey,
|
|
6921
7806
|
cliVersion: VERSION,
|
|
6922
7807
|
transcriptPath: values.transcript,
|
|
6923
|
-
|
|
7808
|
+
// --local takes --out like every local command; --output still works.
|
|
7809
|
+
outputDir: values.local ? localOut : values.output,
|
|
6924
7810
|
language: values.language,
|
|
6925
7811
|
title: values.title,
|
|
6926
7812
|
tags: values.tag ?? [],
|
|
@@ -7139,8 +8025,53 @@ async function main() {
|
|
|
7139
8025
|
cmdMcp();
|
|
7140
8026
|
return;
|
|
7141
8027
|
case "doctor":
|
|
7142
|
-
await cmdDoctor(ctx, json);
|
|
8028
|
+
await cmdDoctor(ctx, json, Boolean(values.local));
|
|
8029
|
+
return;
|
|
8030
|
+
case "local": {
|
|
8031
|
+
const sub = rest[0] ?? "status";
|
|
8032
|
+
const { mod, env } = await localMode();
|
|
8033
|
+
if (sub === "setup") {
|
|
8034
|
+
const str = (k) => (typeof values[k] === "string" ? values[k] : undefined);
|
|
8035
|
+
// `--model-key -` / `--transcribe-key -` read the key from stdin, so it
|
|
8036
|
+
// never sits in argv, shell history or an agent's command log.
|
|
8037
|
+
let keys;
|
|
8038
|
+
try {
|
|
8039
|
+
keys = await mod.resolveKeyFlags({ modelKey: str("model-key"), transcribeKey: str("transcribe-key") }, () => mod.readStdinLine());
|
|
8040
|
+
}
|
|
8041
|
+
catch (error) {
|
|
8042
|
+
mod.printLocalError(error, json, env.io);
|
|
8043
|
+
process.exitCode = error instanceof mod.UsageError ? 2 : 1;
|
|
8044
|
+
return;
|
|
8045
|
+
}
|
|
8046
|
+
process.exitCode = mod.cmdLocalSetup({
|
|
8047
|
+
modelProvider: str("model-provider"),
|
|
8048
|
+
modelKey: keys.modelKey,
|
|
8049
|
+
model: str("model"),
|
|
8050
|
+
baseUrl: str("base-url"),
|
|
8051
|
+
transcribe: str("transcribe"),
|
|
8052
|
+
transcribeKey: keys.transcribeKey,
|
|
8053
|
+
}, json, env);
|
|
8054
|
+
if (keys.literal.length > 0 && process.exitCode === 0)
|
|
8055
|
+
process.stderr.write(`${mod.LITERAL_KEY_NOTE}\n`);
|
|
8056
|
+
return;
|
|
8057
|
+
}
|
|
8058
|
+
if (sub === "status") {
|
|
8059
|
+
process.exitCode = await mod.cmdLocalStatus(json, env);
|
|
8060
|
+
return;
|
|
8061
|
+
}
|
|
8062
|
+
die("usage: clipy local setup [--model-provider <p> --model-key - --model <m> --base-url <u>] [--transcribe <engine> --transcribe-key -] | clipy local status", 2);
|
|
8063
|
+
return;
|
|
8064
|
+
}
|
|
8065
|
+
case "models": {
|
|
8066
|
+
const { mod, env } = await localMode();
|
|
8067
|
+
process.exitCode = await mod.cmdModels(rest, json, env);
|
|
8068
|
+
return;
|
|
8069
|
+
}
|
|
8070
|
+
case "speech": {
|
|
8071
|
+
const { mod, env } = await localMode();
|
|
8072
|
+
process.exitCode = await mod.cmdSpeech(rest, json, env);
|
|
7143
8073
|
return;
|
|
8074
|
+
}
|
|
7144
8075
|
case "playwright-path":
|
|
7145
8076
|
await cmdPlaywrightPath(json);
|
|
7146
8077
|
return;
|
|
@@ -7157,6 +8088,20 @@ async function main() {
|
|
|
7157
8088
|
cmdGuide(json);
|
|
7158
8089
|
return;
|
|
7159
8090
|
case "sources": {
|
|
8091
|
+
// Clipy Local's own ids: the ones --window/--display resolve against for
|
|
8092
|
+
// --source mac-screen --local (not the CLI recorder's ffmpeg ids).
|
|
8093
|
+
if (values.local && isLocalMacSource(values.source)) {
|
|
8094
|
+
if (!bridgeApplicable("local"))
|
|
8095
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
8096
|
+
const sources = await listSources(readLocalBridgeOrDie()).catch((e) => die(e.message));
|
|
8097
|
+
printBridgeSources(sources, json, 'record one with: clipy record --local --source mac-screen --window "<title or id>"');
|
|
8098
|
+
return;
|
|
8099
|
+
}
|
|
8100
|
+
if (values.local) {
|
|
8101
|
+
const { mod, env } = await localMode();
|
|
8102
|
+
process.exitCode = await mod.localSources(json, env);
|
|
8103
|
+
return;
|
|
8104
|
+
}
|
|
7160
8105
|
// An explicit CLIPY_BRIDGE_FILE means "ask that Clipy app", on any OS.
|
|
7161
8106
|
if (process.platform === "linux" && !process.env.CLIPY_BRIDGE_FILE?.trim()) {
|
|
7162
8107
|
const xDisplay = values["x-display"]?.trim() || process.env.DISPLAY;
|
|
@@ -7171,26 +8116,7 @@ async function main() {
|
|
|
7171
8116
|
// Enumerate what the Mac app can capture, so --window/--display have ids.
|
|
7172
8117
|
try {
|
|
7173
8118
|
const sources = await listSources(readBridgeInfo());
|
|
7174
|
-
|
|
7175
|
-
// Each entry carries the SAME `source` descriptor shape that
|
|
7176
|
-
// `session start --json` / `record --json` report for the resolved
|
|
7177
|
-
// capture, so a caller can compare "what I picked" against "what the
|
|
7178
|
-
// camera reports" with a direct object comparison — no transforming.
|
|
7179
|
-
printJson({
|
|
7180
|
-
displays: sources.displays.map((d) => ({ ...d, source: describeDisplay(d) })),
|
|
7181
|
-
windows: sources.windows.map((w) => ({ ...w, source: describeWindow(w) })),
|
|
7182
|
-
});
|
|
7183
|
-
return;
|
|
7184
|
-
}
|
|
7185
|
-
process.stdout.write(`${c.bold("DISPLAYS")}\n`);
|
|
7186
|
-
for (const d of sources.displays) {
|
|
7187
|
-
process.stdout.write(` ${d.id}\t${d.name || "display"}\t${c.dim(`${d.width}×${d.height}`)}\n`);
|
|
7188
|
-
}
|
|
7189
|
-
process.stdout.write(`${c.bold("WINDOWS")}\n`);
|
|
7190
|
-
for (const w of sources.windows) {
|
|
7191
|
-
process.stdout.write(` ${w.id}\t${windowLabel(w)}\t${c.dim(`${w.width}×${w.height}`)}\n`);
|
|
7192
|
-
}
|
|
7193
|
-
process.stdout.write(`${c.dim('record one with: clipy record --source mac-screen --window "<title or id>"')}\n`);
|
|
8119
|
+
printBridgeSources(sources, json, 'record one with: clipy record --source mac-screen --window "<title or id>"');
|
|
7194
8120
|
}
|
|
7195
8121
|
catch (e) {
|
|
7196
8122
|
die(e.message);
|
|
@@ -7219,10 +8145,25 @@ async function main() {
|
|
|
7219
8145
|
wait: Boolean(values.wait),
|
|
7220
8146
|
json,
|
|
7221
8147
|
verificationFor: values.for?.trim() || undefined,
|
|
8148
|
+
...(values.local ? { local: { out: values.out?.trim() || undefined, force: Boolean(values.force) } } : {}),
|
|
7222
8149
|
});
|
|
7223
8150
|
return;
|
|
7224
8151
|
}
|
|
7225
8152
|
case "record": {
|
|
8153
|
+
if (values.local) {
|
|
8154
|
+
await cmdRecordLocalDispatch(ctx, values, rest, {
|
|
8155
|
+
json,
|
|
8156
|
+
expectedResult,
|
|
8157
|
+
num,
|
|
8158
|
+
authFlagsPresent,
|
|
8159
|
+
audioFlagsPresent,
|
|
8160
|
+
authCapture,
|
|
8161
|
+
userDataDir,
|
|
8162
|
+
profileDirectory,
|
|
8163
|
+
audioChoice,
|
|
8164
|
+
});
|
|
8165
|
+
return;
|
|
8166
|
+
}
|
|
7226
8167
|
const source = normalizeScreenSource(String(values.source ?? "web"));
|
|
7227
8168
|
if (source !== "web" && !isScreenSource(source)) {
|
|
7228
8169
|
die("--source must be web (headless browser) or screen (the real screen: the Clipy Mac app on macOS, the CLI's own recorder on Linux)", 2);
|
|
@@ -7263,6 +8204,8 @@ async function main() {
|
|
|
7263
8204
|
notes: (values.note ?? []).map(parseNoteFlag),
|
|
7264
8205
|
json,
|
|
7265
8206
|
}).catch((e) => die(e.message));
|
|
8207
|
+
if (!result)
|
|
8208
|
+
return; // only --local returns no upload, and it never reaches here
|
|
7266
8209
|
if (values.wait && result.publicId)
|
|
7267
8210
|
await waitForArtifacts(ctx, result.publicId).catch(() => { });
|
|
7268
8211
|
if (json) {
|
|
@@ -7355,7 +8298,17 @@ async function main() {
|
|
|
7355
8298
|
// cmdSessionStart opts. `positionalUrl` is rest[1] for `start` (session
|
|
7356
8299
|
// start <url>) — `run` has no positional url, only --url.
|
|
7357
8300
|
const buildStartOpts = (positionalUrl) => {
|
|
7358
|
-
const
|
|
8301
|
+
const localMac = Boolean(values.local) && isLocalMacSource(values.source);
|
|
8302
|
+
if (localMac && !bridgeApplicable("local"))
|
|
8303
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
8304
|
+
if (localMac && (values.out || values.force))
|
|
8305
|
+
die(LOCAL_MAC_OUT, 2);
|
|
8306
|
+
if (values.local && values.source === "screen" && process.platform === "win32") {
|
|
8307
|
+
die("clipy session --local cannot record the Windows screen yet; use clipy record --local (Enter or Ctrl-C to stop), --url, or --source chrome-for-clipy", 2);
|
|
8308
|
+
}
|
|
8309
|
+
if (values.local && values.source === "chrome-extension")
|
|
8310
|
+
die(LOCAL_EXTENSION_REFUSAL, 2);
|
|
8311
|
+
const source = localMac ? "mac-screen" : normalizeScreenSource(String(values.source ?? "web"));
|
|
7359
8312
|
if (source !== "web" && !isScreenSource(source) && source !== "chrome-for-clipy" && source !== "chrome-extension") {
|
|
7360
8313
|
die("--source must be web (headless browser), screen (the real screen: the Clipy Mac app on macOS, the CLI's own recorder on Linux), chrome-for-clipy (the persistent automation browser), or chrome-extension (the Clipy extension inside Chrome for Clipy)", 2);
|
|
7361
8314
|
}
|
|
@@ -7408,6 +8361,7 @@ async function main() {
|
|
|
7408
8361
|
profileDirectory: profileDirectory(),
|
|
7409
8362
|
audio: audioChoice(),
|
|
7410
8363
|
tabAudio: Boolean(values["tab-audio"]),
|
|
8364
|
+
...(values.local ? { local: { out: values.out?.trim() || undefined, force: Boolean(values.force) } } : {}),
|
|
7411
8365
|
};
|
|
7412
8366
|
};
|
|
7413
8367
|
if (sub === "start") {
|
|
@@ -7420,7 +8374,7 @@ async function main() {
|
|
|
7420
8374
|
return;
|
|
7421
8375
|
}
|
|
7422
8376
|
if (sub === "stop") {
|
|
7423
|
-
await cmdSessionStop(json);
|
|
8377
|
+
await cmdSessionStop(json, Boolean(values.local));
|
|
7424
8378
|
return;
|
|
7425
8379
|
}
|
|
7426
8380
|
if (sub === "abort") {
|
|
@@ -7428,7 +8382,7 @@ async function main() {
|
|
|
7428
8382
|
return;
|
|
7429
8383
|
}
|
|
7430
8384
|
if (sub === "status" || sub === undefined) {
|
|
7431
|
-
await cmdSessionStatus(json);
|
|
8385
|
+
await cmdSessionStatus(json, Boolean(values.local));
|
|
7432
8386
|
return;
|
|
7433
8387
|
}
|
|
7434
8388
|
die("usage: clipy session <start|run|stop|abort|status>", 2);
|