Skip to main content
API referenceEntry points

Slate is one package with several import paths. Most code needs only the first: Camera and its types. The others are for a browser page that draws controls, a host that shares one camera between callers, an MCP server, raw protocol work, and the darkgrade command inside another executable.

import { Camera } from '@darkgrade/slate'
Import pathFor
@darkgrade/slateThe camera API: Camera, its option and result types, its errors, and the workflows built on it (a multi-camera video take, shot analysis, power assessment).
@darkgrade/slate/cliThe darkgrade command as a function, for an executable that embeds it.
@darkgrade/slate/controlsThe setting vocabulary and value conversions without any driver or USB code, for a browser page that draws controls.
@darkgrade/slate/protocolRaw PTP access, the vendor drivers, the registries of operations, properties and events, PTP/IP and wireless pairing.
@darkgrade/slate/runtimeWhat a host embeds to share one camera between several callers: CameraRuntime with its per-camera queue, the operation list the MCP tools and the CLI are generated from, and cross-process ownership (HardwareCoordinator).
@darkgrade/slate/runtime/browserThe runtime without any Node import: everything in ./runtime except cross-process ownership.
@darkgrade/slate/runtime/mcpThe MCP server: one camera_ tool per public Camera operation, generated from the same list.
@darkgrade/slate/runtime/ownershipCross-process camera ownership with leases and heartbeats, for a host with more than one process.
@darkgrade/slate/telemetryDiagnostics sharing for an application that embeds Slate: one shared queue per process.
@darkgrade/slate/telemetry/batchThe batch a client uploads, and its validation.
@darkgrade/slate/telemetry/installation-storeA file store for the installation state.
@darkgrade/slate/telemetry/protocolThe protocol evidence a diagnostic entry can carry, and its validation.
@darkgrade/slate/telemetry/schemaThe diagnostic entry schema, its limits and its validation.
@darkgrade/slate/telemetry/settingsWhere Node keeps the sharing preference and saved diagnostics, and the shared Node queue.
@darkgrade/slate/telemetry/serverThe collector.
@darkgrade/slate/telemetry/postgresThe collector's Postgres database.

Slate needs Node 22.18 or later. @modelcontextprotocol/server, zod and pg are optional peer dependencies, needed only by the entry points that name them below.

@darkgrade/slate

packages/slate/src/index.ts

The camera API: Camera, its option and result types, its errors, and the workflows built on it (a multi-camera video take, shot analysis, power assessment).

import { Camera } from '@darkgrade/slate'

Guide: Quickstart

Classes (14)

ExportWhat it is
CameraOne camera, the same on every body that supports an operation.
CameraClipNotFoundErrorThe camera confirmed it stopped recording, but no new finished clip appeared on the card in time.
CameraConfirmationErrorAn acknowledged request whose fresh camera observation did not confirm the requested state.
CameraOutcomeUnknownErrorThe command was sent but its result could not be confirmed.
CameraRefusedErrorThe camera said no, or the value is not one it offers now.
CameraUnsupportedErrorThis camera cannot do it right now; getCapabilities() says why.
PTPDecodeErrorA dataset arrived intact at the container level but could not be decoded.
PTPDisconnectedErrorThe transport is gone (cable pulled, camera powered off, socket closed).
PTPErrorThe base class of every protocol failure.
PTPProtocolErrorThe camera answered with bytes that break ISO 15740 container framing for this transaction.
PTPRecoveryRequiredErrorThe pipe may still contain an abandoned transaction and the automatic USB reset failed, or the transport has none (PTP/IP).
PTPResponseErrorThe camera answered a transaction with a response code the caller cannot continue from.
PTPTimeoutErrorA transport phase did not complete in time.
VideoTakeDevice-independent take lifecycle shared by applications and MCP.

Functions (25)

ExportWhat it is
analyseShot()Measures a picture's exposure, focus detail and colour, optionally with a vision-model review of the subject, as a ShotAnalysis.
assessCameraPower()Whether the battery lasts a planned recording with a reserve (5 minutes unless given), from the camera's own runtime estimate, never from the percentage.
cameraControlContract()Each qualification setting from one read of the controls: whether it is present and writable, its value and its choices.
chooseIso()The ISO among the values the camera offers that best corrects the analysed exposure; undefined when none applies or it is already set.
chooseShutterSpeed()Choose the closest advertised shutter to a 180-degree shutter angle.
configureSlateTelemetry()Sets the diagnostics client Slate reports to, or clears it with undefined. A browser application supplies its own persistent store this way.
describeShot()Reads ShotMetrics as words: exposure balanced, bright or dark; focus detail-visible or soft; colour neutral, cast or unknown.
exifIso()Read standard EXIF ISO, so locking Auto ISO preserves the camera's metered exposure.
exposureSeconds()An exposure time in seconds. An angle needs context.framesPerSecond; a named value such as Bulb gives undefined.
identifyCamera()Resolves USB identity without opening a device or starting any service.
isValidatedModel()Whether a model name is in validatedCameraModels, ignoring case and extra spaces.
isVerifiedFeature()Whether a vendor feature is confirmed on that model in verifiedFeatureModels.
matchExposureTime()Match an actual advertised value; do not round to a nearby camera setting.
measureShot()Measures RGB pixels (three bytes each, width by height) into ShotMetrics.
normalizeCameraPower()Normalize documented units; preserve unsupported/sentinel values as raw evidence.
observeCameraEvents()Counts the events a protocol session delivers during an operation, by code and name.
optimiseShot()Sets a shot up from a picture within a time budget: chooses among the values the camera offers, applies them through your callback and reports each change as a ShotSetupReport.
parseExposureTime()Reads text such as 1/250, 0.5", 180° or bulb, or an ExposureTime object, into an ExposureTime. Throws on input it cannot read.
qualifyCameraSetting()Writes one setting to a value the camera offers, reads it back and restores the original, also after a failed or ambiguous write. The caller owns the camera throughout.
readCameraPower()Reuse an owned camera session for battery telemetry over USB or Sony SDK Wi-Fi.
readStandardCameraPower()Read one standard battery descriptor on an already-owned PTP session.
recordFirstContact()Bodies outside the validated list get one bounded, read-only inventory (identity, every advertised property descriptor, storage IDs) recorded as a first-contact profile.
resolveCameraControl()The setting id for a name or alias, ignoring case, spaces, hyphens and underscores; undefined when none matches.
runBenchmark()Reads a connected, idle camera's full advertised inventory and a bounded number of numeric property descriptors, and reports each check.
subjectFocusVerified()Whether focus on the subject is verified: the camera confirmed focus, or a confident scene review saw the subject sharp. Edge contrast alone never counts.

Constants (6)

ExportWhat it is
cameraControlDefinitionsCanonical application vocabulary: ids, labels and search aliases (a vendor's own word is only an alias).
DEFAULT_TRANSACTION_POLICYThe TransactionPolicy a camera uses unless told otherwise: 30 s per phase, up to 6 DeviceBusy retries within 2 s.
defaultLoggerConfigInert by default: a logger takes over the console or draws in the terminal only when asked.
qualificationSettingsPortable, deliberately small control contracts.
validatedCameraModelsThe single source of truth for which bodies Darkgrade has run on its physical test benches, keyed by the exact DeviceInfo model string.
verifiedFeatureModelsVendor features physically confirmed on specific bodies; anywhere else they are attempted, unverified.

Types (105)

ExportWhat it is
ApertureAn aperture in Slate's one spelling: f/ and the f-number without trailing zeros (f/4, f/2.8).
AspectRatioThe shape of the photo, or a crop of the sensor.
AudioRecordingMovie sound, Canon only for now: On, Off or On (manual level).
BatteryWhat the camera reports about its power now.
BenchmarkCheckOne check of runBenchmark and how it went.
BenchmarkOptionsWhat runBenchmark takes.
CameraCapabilitiesWhat getCapabilities resolves to: every setting, the lens, and which operations work now.
CameraControlIdA setting id, such as iso or shutterSpeed.
CameraControlInputsWhat setControl accepts as a value, by setting id: an ExposureTimeInput for shutterSpeed, a number for colorTemperature and audioLevel, and a string for every other setting.
CameraControlSessionThe same control contract on an already-connected native PTP or vendor SDK session, including one typed getter and setter per typed setting (getShutterSpeed, setShutterSpeed, ...).
CameraControlStateOne setting as the camera reports it now: its value, the values it offers, and whether it can be written.
CameraEventHandlerA handler for on: called with no arguments each time the event fires.
CameraEventNameThe events on delivers: settingsChanged and mediaAdded.
CameraIdentificationWhat identifyCamera makes of a USB vendor and product ID, without opening the device.
CameraIdentityCandidateA camera line and model aliases that a cited source associates with one USB vendor/product ID.
CameraInfoWhat the body reports about itself.
CameraLensThe attached lens as the camera reports it.
CameraOptionsWhat new Camera() takes.
CameraPowerA camera's battery and power reading, as readCameraPower returns it.
CameraPowerAssessmentWhat assessCameraPower concludes for a planned recording.
CameraRecordingStateWhat getRecordingState resolves to.
CameraRecoveryOptionsLimits for recover.
CameraRecoveryReportWhat recover did: each software step, whether the camera answered afterwards, and whether only power or hub cycling is left.
CameraRecoveryStepOne step of a recovery and how it went.
CardPhotoA photo confirmed on the card.
CardStatusOne card slot as the camera reports it now.
ClipA finished movie file the camera wrote to its card during one recording.
ColorTemperatureA colour temperature in kelvin.
ComputerPhotoA photo whose bytes reached this computer.
ConnectOptionsHow Camera.connect opens the camera.
ContinuousAutofocusWhether the camera keeps focusing before a half-press (Canon Continuous AF): On or Off.
DetectionSubjectWhat subject detection looks for: People, Animals, Birds, ...
DeviceDescriptorWhich device to open: a USB filter, or a host on the network.
DigitalZoomHow far zoom reaches past the optics: Off is optical only.
DiscoveredCameraOne attached camera found by Camera.discover(), without opening a session.
DriveModeA drive mode in Slate's one spelling ('Single', 'Continuous high', 'Self-timer 10 s', ...).
EventParamsThe parameters of a raw event, by name.
ExposureCompensationExposure compensation in stops with one decimal and a sign: +0.7, -1.0, 0.0.
ExposureContextThe frame rate that converting between a shutter angle and a duration needs.
ExposureModeWho picks the exposure: you (Manual), the camera (Program, Auto), or the two of you (aperture or shutter priority).
ExposureModeAliasThe short forms setExposureMode also accepts: the mode-dial letters, and Canon's Av, Tv and Fv.
ExposureTimeA shutter speed as a duration in seconds, an angle in degrees, or a named mode (bulb, time, flash-sync, auto).
ExposureTimeInputAn ExposureTime, or text that parseExposureTime reads, such as 1/250, 0.5" or 180°.
EyeSelectionWhich eye subject detection focuses on: Auto, Right or Left; Off where a body can turn eye detection off (Canon).
FlashModeWhether and how the flash fires.
FocusAreaWide, Zone, Spot M, Tracking Spot M, ...; Sony's Flexible Spot is Spot, Lock-on AF is Tracking.
FocusDirectionWhich way nudgeFocus moves focus: near towards the camera, far away from it.
FocusFrameA frame the camera draws over its picture: its focus area, a detected face or a tracked subject.
FocusModeAF-S, AF-C or MF, and the other modes a body offers (AF-A, DMF, AF-F, ...).
FocusNudgeWhat a focus nudge did.
FocusResultWhether autofocus confirmed focus: acquired, not-acquired or unknown.
FocusStepSizeA small, medium or large manual-focus step, like the < << <<< buttons in vendor remote apps.
FrameRateA frame rate: 24p, 23.98p, 60p, 50i.
IsoAn ISO sensitivity: ISO 800, Auto, and the Sony labels that are distinct settings rather than spellings (an extended sensitivity, the Multi Frame NR sensitivities).
JpegQualityHow much a JPEG is compressed: finer keeps more detail in a bigger file.
LiveViewFrameWhat getLiveViewFrame resolves to: one picture and the frames the camera draws over it.
LiveViewFrameOptionsWhat getLiveViewFrame takes.
LiveViewOverlayThe camera's own on-screen info (menus, dialogs, shooting info), drawn to lay over the picture.
LiveViewQualityThe live-view picture's quality: High is sharper, Low lighter on the connection.
LoggerConfigWhat the logger option of new Camera() takes.
MediaDownloadOptionsProgress and cancel for downloadMedia.
MediaItemOne file on the card, as listMedia lists it.
MediaPreviewSizeThe sizes getMediaPreview returns: thumbnail is the small one, preview a larger one.
MeteringModeWhich part of the frame the camera measures light from.
ObjectInfoA file's PTP ObjectInfo dataset, as the camera sent it.
OperationAvailabilityOne operation's availability now: an unsupported one says why, in words a user can act on.
OperationParamsThe parameters of a raw operation, by name, as protocolSession(camera).send takes them.
OperationResponseWhat a raw operation resolves to: the response code and parameters, with data when the operation returns any.
PhotoWhat takePhoto resolves to: a CardPhoto for the destination card, a ComputerPhoto for computer and computerOnly.
PhotoDestinationWhere a photo goes: the camera's card; the card and this computer (its bytes come back); or this computer only, never saved to the card (computerOnly).
PhotoFormatA photo format, in each vendor codec's own spelling: 'RAW', 'RAW+JPEG', 'JPEG' on current Sony bodies; format and quality together ('RAW+JPEG Fine', 'HEIF Standard') on Sony bodies with one combined setting; Canon's format with its size ('RAW', 'cRAW+L', 'M').
PhotoSizeA photo size: Sony's codec names ('Large', 'Medium', 'Small'), or the pixel dimensions a standard body lists.
PhotoVideoModeWhether the camera is set up to take photos or record video.
PictureProfileA Sony Picture Profile ('Off', 'PP1' to 'PP11', 'PP LUT 1' to 'PP LUT 4').
PictureStyleA look in Slate's one spelling: Canon Picture Style, Nikon Picture Control and Sony Creative Look or Creative Style ('Standard', 'Portrait', 'Monochrome', ...).
PTPProtocolViolationHow a reply broke PTP container framing, on PTPProtocolError.violation.
QualificationCameraThe camera qualifyCameraSetting drives: one read of its controls and one write of a setting.
QualificationSettingThe settings qualifyCameraSetting can exercise.
RawCompressionA NEF compression the body names; a raw number it reports without a name is not a value to write.
RecoveryReportWhat Camera.recover() did: each software step, whether the camera answered GetDeviceInfo afterwards, and whether only power or hub cycling is left.
SettingInputWhat the typed setter of a setting accepts.
SettingValueWhat the typed getter of a setting returns, and its setter resolves to.
ShotAnalysisWhat analyseShot measured in a picture, and how it reads the exposure, focus and colour.
ShotMetricsThe numbers measureShot takes from the middle of a picture, leaving a 15% border out.
ShotPropertyA setting as optimiseShot reads it: the fields of a CameraControlState it needs.
ShotSetupReportWhat optimiseShot changed, and whether the result was verified.
ShutterSpeedA shutter speed in Slate's one spelling, whatever the vendor calls it: '1/250', '30"', '0.3"', '180°', 'Bulb'.
SubjectDetectionWhether the camera looks for faces, eyes and other subjects to focus on.
TakeCameraWhat VideoTake needs from each camera: the five steps of a take, which you implement over a Camera.
TakeCameraStateOne camera's part in a take: its state, when it started and stopped, and its clips.
TakeMediaOne clip of a take.
TakePhotoOptionsWhat takePhoto takes.
TransactionPolicyHow long and how often Slate waits for a camera before giving up on a transaction.
TransportInterfaceWhat a transport implements to carry PTP for a Camera.
TypedSettingIdThe settings with a typed getter and setter.
TypedSettingMethodsOne getter and one setter per typed setting, declared once over setControl: setShutterSpeed is setControl('shutterSpeed', …) and resolves to the value the camera read back; the getter reads the current value.
UnrecognizedValuesRaw values the camera reported that Slate has no name for.
VerifiedFeatureA vendor feature confirmed on specific bodies on Darkgrade's benches, for isVerifiedFeature.
VideoFormatA video format: Sony's codec names (XAVC S 4K), Nikon's file type (H.265 10-bit (MOV)) or Canon's complete movie record.
VideoQualityA video quality (bit rate, sampling and depth), as the vendor codecs name it: 150M 4:2:0 10-bit.
VideoTakeStateA take on several cameras as VideoTake publishes it: its stage and each camera's state.
WhiteBalanceA white balance in Slate's one spelling, whatever the vendor calls it: Nikon's "Sunny" is 'Daylight', Canon's kebab-case codes are 'Auto', 'Shade', 'Color Temperature' and so on.
ZoomDirectionWhich way startZoom zooms: in towards the long end of the lens, out towards the wide end.
ZoomOptionsWhat startZoom takes.
ZoomSpeedHow fast startZoom moves the lens.

@darkgrade/slate/cli

packages/slate/src/cli/index.ts

The darkgrade command as a function, for an executable that embeds it.

import { runDarkgradeCli } from '@darkgrade/slate/cli'

const exitCode = await runDarkgradeCli(process.argv.slice(2))

Guide: CLI

Functions

ExportWhat it is
runDarkgradeCli()Terminal command behavior shared by the thin darkgrade executable and other Node hosts.

Types

ExportWhat it is
DarkgradeCliHostWhat the embedding executable knows and Slate does not.

@darkgrade/slate/controls

packages/slate/src/controls.ts

The setting vocabulary and value conversions without any driver or USB code, for a browser page that draws controls.

import { parseExposureTime } from '@darkgrade/slate/controls'

Guide: Settings and values

Classes (5)

ExportWhat it is
CameraClipNotFoundErrorThe camera confirmed it stopped recording, but no new finished clip appeared on the card in time.
CameraConfirmationErrorAn acknowledged request whose fresh camera observation did not confirm the requested state.
CameraOutcomeUnknownErrorThe command was sent but its result could not be confirmed.
CameraRefusedErrorThe camera said no, or the value is not one it offers now.
CameraUnsupportedErrorThis camera cannot do it right now; getCapabilities() says why.

Functions (6)

ExportWhat it is
exposureSeconds()An exposure time in seconds. An angle needs context.framesPerSecond; a named value such as Bulb gives undefined.
formatShutterSpeed()The canonical spelling of an observed exposure; the camera's label is used only to keep a ratio.
matchExposureTime()Match an actual advertised value; do not round to a nearby camera setting.
parseExposureTime()Reads text such as 1/250, 0.5", 180° or bulb, or an ExposureTime object, into an ExposureTime. Throws on input it cannot read.
resolveCameraControl()The setting id for a name or alias, ignoring case, spaces, hyphens and underscores; undefined when none matches.
unrecognizedValueLabel()Hexadecimal for integers (0x1234), verbatim for text.

Constants (3)

ExportWhat it is
cameraControlDefinitionsCanonical application vocabulary: ids, labels and search aliases (a vendor's own word is only an alias).
exposureModesThe exposure modes, as words.
meteringModesThe metering modes, as words.

Types (37)

ExportWhat it is
ApertureAn aperture in Slate's one spelling: f/ and the f-number without trailing zeros (f/4, f/2.8).
CameraCapabilitiesWhat getCapabilities resolves to: every setting, the lens, and which operations work now.
CameraControlIdA setting id, such as iso or shutterSpeed.
CameraControlInputsWhat setControl accepts as a value, by setting id: an ExposureTimeInput for shutterSpeed, a number for colorTemperature and audioLevel, and a string for every other setting.
CameraControlSessionThe same control contract on an already-connected native PTP or vendor SDK session, including one typed getter and setter per typed setting (getShutterSpeed, setShutterSpeed, ...).
CameraControlStateOne setting as the camera reports it now: its value, the values it offers, and whether it can be written.
CameraLensThe attached lens as the camera reports it.
CameraRecordingStateWhat getRecordingState resolves to.
ColorTemperatureA colour temperature in kelvin.
ContinuousAutofocusWhether the camera keeps focusing before a half-press (Canon Continuous AF): On or Off.
DetectionSubjectWhat subject detection looks for: People, Animals, Birds, ...
DigitalZoomHow far zoom reaches past the optics: Off is optical only.
DriveModeA drive mode in Slate's one spelling ('Single', 'Continuous high', 'Self-timer 10 s', ...).
ExposureCompensationExposure compensation in stops with one decimal and a sign: +0.7, -1.0, 0.0.
ExposureContextThe frame rate that converting between a shutter angle and a duration needs.
ExposureModeWho picks the exposure: you (Manual), the camera (Program, Auto), or the two of you (aperture or shutter priority).
ExposureModeAliasThe short forms setExposureMode also accepts: the mode-dial letters, and Canon's Av, Tv and Fv.
ExposureTimeA shutter speed as a duration in seconds, an angle in degrees, or a named mode (bulb, time, flash-sync, auto).
ExposureTimeInputAn ExposureTime, or text that parseExposureTime reads, such as 1/250, 0.5" or 180°.
EyeSelectionWhich eye subject detection focuses on: Auto, Right or Left; Off where a body can turn eye detection off (Canon).
FocusAreaWide, Zone, Spot M, Tracking Spot M, ...; Sony's Flexible Spot is Spot, Lock-on AF is Tracking.
FocusModeAF-S, AF-C or MF, and the other modes a body offers (AF-A, DMF, AF-F, ...).
IsoAn ISO sensitivity: ISO 800, Auto, and the Sony labels that are distinct settings rather than spellings (an extended sensitivity, the Multi Frame NR sensitivities).
LiveViewQualityThe live-view picture's quality: High is sharper, Low lighter on the connection.
MeteringModeWhich part of the frame the camera measures light from.
OperationAvailabilityOne operation's availability now: an unsupported one says why, in words a user can act on.
PhotoVideoModeWhether the camera is set up to take photos or record video.
PictureProfileA Sony Picture Profile ('Off', 'PP1' to 'PP11', 'PP LUT 1' to 'PP LUT 4').
PictureStyleA look in Slate's one spelling: Canon Picture Style, Nikon Picture Control and Sony Creative Look or Creative Style ('Standard', 'Portrait', 'Monochrome', ...).
SettingInputWhat the typed setter of a setting accepts.
SettingValueWhat the typed getter of a setting returns, and its setter resolves to.
ShutterSpeedA shutter speed in Slate's one spelling, whatever the vendor calls it: '1/250', '30"', '0.3"', '180°', 'Bulb'.
SubjectDetectionWhether the camera looks for faces, eyes and other subjects to focus on.
TypedSettingIdThe settings with a typed getter and setter.
TypedSettingMethodsOne getter and one setter per typed setting, declared once over setControl: setShutterSpeed is setControl('shutterSpeed', …) and resolves to the value the camera read back; the getter reads the current value.
UnrecognizedValuesRaw values the camera reported that Slate has no name for.
WhiteBalanceA white balance in Slate's one spelling, whatever the vendor calls it: Nikon's "Sunny" is 'Daylight', Canon's kebab-case codes are 'Auto', 'Shade', 'Color Temperature' and so on.

@darkgrade/slate/protocol

packages/slate/src/protocol.ts

Raw PTP access, the vendor drivers, the registries of operations, properties and events, PTP/IP and wireless pairing. Unsupported: names follow each vendor's own protocol, and nothing here is confirmed the way Camera operations are.

import { protocolSession } from '@darkgrade/slate/protocol'

Guides: Raw protocol access · Wi-Fi with PTP/IP

Classes (14)

ExportWhat it is
CanonCameraCanon publishes its PTP implementation only under NDA.
NikonAccessoryControllerOne persistent Nikon PTP session.
NikonEventDataCodecZ6III SDK command reference rev 2, section 6.2.2.13: UINT32 record count, then UINT16 event code, UINT16 parameter count and UINT32 parameters per record.
NikonMenuControllerNavigation on the physically validated Z6III firmware only.
NikonShotControlsMovie controls on one caller-owned persistent session.
OpenEnumCodecAn enumeration whose wire values differ between bodies (a property one specification names and another body uses differently): a value with no name decodes as that raw value instead of failing, so a read keeps what the camera said.
PTPIPTransactionCancelledErrorA wire Cancel is a cancelled transaction, never an invented PTP response code.
SonyBluetoothRemoteA bonded Bluetooth remote.
SonyPtpVideoRecordingNative Sony PTP only: observed movie state, card identity and bounded-memory transfer.
SonyRemoteSdkTransportTransport adapter for an authenticated Sony Camera Remote SDK session.
SonyVideoRecordingCamera-card take over the same official Sony SDK connection on USB or Wi-Fi.
SonyWifiCameraA camera session over Sony's Camera Remote SDK, authenticated over Wi-Fi only (never USB): the CameraSession operations it can serve, under the same names and results as the native driver.
UsbVideoRecordingPersistent PTP movie recording, final-file discovery and bounded-memory transfer.
VendorExtensionCameraA camera from a vendor whose darkgrade support is limited to cited vendor operation definitions (Fujifilm, Panasonic, OM System/Olympus, Leica, Sigma).

Functions (21)

ExportWhat it is
compareSonyModels()SDK feature contracts are comparison evidence, never a replacement for runtime advertisement.
connectNikonWifiCamera()Connect an already paired, active Nikon Camera Control profile.
createEnumCodec()An EnumCodec whose names are inferred from its values.
createOpenEnumCodec()An OpenEnumCodec whose names are inferred from its values.
createSonySdkBridge()Spawn an operator-installed official-SDK bridge; no SDK binaries are bundled.
decodeNikonPairingCode()Decode the Nikon 952B digit dataset; digits are numeric bytes, not ASCII.
decodeSonyMonitoringFormat()Decode the public SDK's packed CrMonitoringFormat without losing uint64 bits.
discoverNikonWifiCameras()One bounded, read-only mDNS browse on the chosen IPv4 network interface.
encodeNikonAccessoryInfo()Optional accessory metadata.
encodeNikonAccessoryKey()Five-byte accessory button state; the last two dial bytes remain neutral.
isMovableFocusArea()A focus area whose position can be moved: any spot, in Sony's words (Flexible Spot) or Slate's (Spot).
pairNikonWifiProfile()Pair an already selected Nikon Camera Control network profile over PTP/IP.
prepareNikonManualExposure()Enable remote Manual exposure on an owned idle Nikon session.
protocolSession()The protocol session of a Camera, the same object on every call.
readNikonRecordingStatus()Fresh read on an owned Nikon session, including bodies omitting this descriptor from DeviceInfo.
readNikonWirelessStatus()Read-only Nikon WTU capabilities; a USB profile bank is not proof of an active Wi-Fi connection.
recordFullTransport()Wrap before constructing the camera.
requestNikonWifi()Authenticate an existing smart-device registration and request its private WPA network.
sonyMovieSlots()Read the movie destination without changing the camera's recording-media selection.
sonyWifiKeyboardCharacter()Plan printable ASCII input without including input values in error messages.
typeSonyWifiKeyboard()Enter text in an empty Sony Wi-Fi SSID/password keyboard, then select OK.

Constants (6)

ExportWhat it is
ExternalDCInZ6 III command specification 2.00, section 6.5.14.1.
MovieShutterModeZ6 III command specification 2.00, sections 6.5.4.51 and 6.5.12.3.
nikonOperationRegistry0x90ef DeleteWirelessProfile was observed, but its request layout was not captured.
OBJECT_SIZE_UNREPORTEDObjectCompressedSize when the object is 4 GiB or larger: its real size needs a 64-bit query.
SONY_BLUETOOTH_REMOTE_SERVICEPublished RMT-P1BT protocol.
SONY_CAMERA_BUTTONSUpper 16 bits of the CameraButtonFunction payload (Camera Remote SDK CrCameraButtonFunction).

Types (12)

ExportWhat it is
EventDataAn event emitter for Node.js and browsers.
NikonQueuedEventNikon GetEventEx records carry a count for each event's UINT32 parameter words.
NikonWifiAdvertisementNikon Royalmile advertises PTP endpoints through Bonjour.
ObjectInfoA file's PTP ObjectInfo dataset, as the camera sent it.
ProtocolSessionRaw protocol access to one Camera, for bench diagnostics.
SonyContentFileSony's ContentInfoList (Camera Control PTP 3 reference, "ContentInfoList"): the card's contents as the camera indexes them in Remote Control with Transfer Mode.
SonyFrameKindSony's FocalFrameInfo (Camera Control PTP 3 reference, "FocalFrameInfo"): the frames the camera draws over live view (its focus area, detected faces and tracked subjects), carried in every live-view dataset.
SonyKeyboardControlsEach button press must finish by refreshing image().
SonyKeyboardImageDecoded 640 × 480 Sony OSD frame; the caller supplies PNG decoding.
SonyRemoteSdkChannelThe wire channel opened by Sony Camera Remote SDK after SSH authentication.
SonyWifiCameraModelAny Sony body name is attempted; the bench-verified bodies stay named for completion.
SonyWirelessConnectionverified is false when the named body (or an unnamed one) has not been confirmed on a bench.

Also exported (124)

ArrayCodec BaseCodecRegistry baseCodecs BaseCodecType BitfieldCodec BitfieldFlag CameraDriverInstance CanonExtendedDeviceInfo CanonLiveViewFrame CanonLiveViewMagnification CanonNetworkState CanonPropertyState CanonRawEvent CanonUnknownPropertyState CodecBuilder CodecDefinition CodecInstance CodecType createBaseCodecs() CustomCodec CustomCodecType DataDirection DatatypeCode DatatypeDefinition DeviceInfo DeviceInfoCodec DevicePropCode EnumCodec EnumValue EventCode EventDefinition EventEmitter EventParameter formatRegistry GenericCamera genericEventRegistry genericOperationRegistry genericPropertyRegistry getDatatypeByCode() Int16Codec Int32Codec Int64Codec Int8Codec IPTransport IPTransportOptions LiveViewPanDirection MovieShutterAngle NIKON_BLUETOOTH_REMOTE_COMMAND NIKON_BLUETOOTH_REMOTE_SERVICE NikonAccessoryInfo NikonAccessoryKey NikonAccessorySoftwareConfirmationOptions NikonAccessoryState NikonBluetoothChannel NikonBluetoothKey NikonBluetoothRemote NikonCamera NikonFocusPointResult NikonFocusResult NikonLiveViewMetadata NikonMenuKey NikonMenuRunOptions NikonSmartDeviceChannel NikonWifiConnectionOptions NikonWifiPairingOptions ObjectInfoCodec OperationCode OperationDefinition ParameterDefinition parseSonyContentInfoList() parseSonyFocalFrameInfo() PropertyAccess PropertyDefinition PTPRegistry RangeCodec RangeSpec ResponseCode ResponseDefinition responseRegistry SONY_BLUETOOTH_REMOTE_COMMAND SONY_BLUETOOTH_REMOTE_NOTIFICATION SONY_SDK_PROPERTY_CODES SonyBluetoothChannel SonyBluetoothDirectAuthentication SonyBluetoothDirection SonyCamera SonyCameraButton SonyContent SonyContentInfoList sonyEventRegistry SonyFocalFrame SonyFocalFrameInfo sonyFormatRegistry sonyModelContracts SonyMonitoringFormat sonyMovieCard() sonyOperationRegistry SonyOsdImage sonyPreviewCapabilities() sonyPropertyRegistry SonyPropertyState sonyPtpMovieCard() SonyRemoteSdkChannelFactory SonyRemoteSdkConnectionOptions sonyResponseRegistry SonySdkBridge SonySdkBridgeOptions SonySdkProperty SonyWifiAuthentication StandardPropertyState StorageInfo StorageInfoCodec StringCodec TransportFactory TransportRecordingEntry TransportRecordingOptions TransportType Uint16Codec Uint32Codec Uint64Codec Uint8Codec USBTransport validateSonyWifiAuthentication() VendorIDs

@darkgrade/slate/runtime

packages/slate/src/runtime/index.ts

What a host embeds to share one camera between several callers: CameraRuntime with its per-camera queue, the operation list the MCP tools and the CLI are generated from, and cross-process ownership (HardwareCoordinator). In a browser bundle this path resolves to the browser entry.

A bundler that honours the browser condition gets runtime/browser instead, the same as @darkgrade/slate/runtime/browser.

import { CameraRuntime } from '@darkgrade/slate/runtime'

Guide: Host cameras for other processes

Classes

ExportWhat it is
CameraRuntimeOne runtime per session-owning host.
HardwareBusyErrorAnother operation or process holds the camera. Carries status (409), code (HARDWARE_BUSY) and retryAfterMilliseconds.
HardwareCoordinatorCross-process camera ownership, with reentrant nested calls on the same operation.
HttpCameraClientConnect to the existing owning host.
OperationInputErrorA call's inputs do not match the operation's parameters; nothing was sent to a camera.

Functions

ExportWhat it is
killMacCameraDaemons()Stops the macOS camera daemons that are running and returns the ones it stopped.
readOperationInput()Checks one call's inputs against the operation's parameters and converts them: numbers from numeric text, time to a Date.
runOperation()Runs one public operation on a Camera with inputs already read by readOperationInput.
surfaceOperations()Every public operation with its MCP and CLI names, in Camera's declaration order.

Types

ExportWhat it is
CameraClientWhat MCP and other remote frontends call: the public operations, by their library name.
CameraOperationDescriptionOne public Camera method as the generator read it.
CameraProviderPlatform hosts supply the connected Camera and physical services, never a second MCP-owned session.
OperationFileA file an operation returned: a live-view frame, a preview, a photo's or a download's bytes.
OperationInputOne call's inputs by parameter name, as an MCP client or the command line gave them.
OperationOutcomeAn operation's result, as Slate returned it, with its bytes moved out into files.
OperationParameterOne input of an operation, the same on every surface: a named MCP argument, and on the CLI a positional argument when required, otherwise a flag.
OperationReplyAn operation's result as it crosses a process: JSON, with any bytes the host saved by path.
OwnershipStoreThe store a HardwareCoordinator keeps its leases in, shared by every process that might open the same camera.
SurfaceOperationOne public Camera operation with its MCP tool and CLI command names, as surfaceOperations() lists it.

Also exported: surfaceOperation()

@darkgrade/slate/runtime/browser

packages/slate/src/runtime/browser.ts

The runtime without any Node import: everything in ./runtime except cross-process ownership.

import { HttpCameraClient } from '@darkgrade/slate/runtime/browser'

Classes

ExportWhat it is
CameraRuntimeOne runtime per session-owning host.
HardwareBusyErrorAnother operation or process holds the camera. Carries status (409), code (HARDWARE_BUSY) and retryAfterMilliseconds.
HttpCameraClientConnect to the existing owning host.
OperationInputErrorA call's inputs do not match the operation's parameters; nothing was sent to a camera.

Functions

ExportWhat it is
readOperationInput()Checks one call's inputs against the operation's parameters and converts them: numbers from numeric text, time to a Date.
runOperation()Runs one public operation on a Camera with inputs already read by readOperationInput.
surfaceOperations()Every public operation with its MCP and CLI names, in Camera's declaration order.

Types

ExportWhat it is
CameraClientWhat MCP and other remote frontends call: the public operations, by their library name.
CameraOperationDescriptionOne public Camera method as the generator read it.
CameraProviderPlatform hosts supply the connected Camera and physical services, never a second MCP-owned session.
OperationFileA file an operation returned: a live-view frame, a preview, a photo's or a download's bytes.
OperationInputOne call's inputs by parameter name, as an MCP client or the command line gave them.
OperationOutcomeAn operation's result, as Slate returned it, with its bytes moved out into files.
OperationParameterOne input of an operation, the same on every surface: a named MCP argument, and on the CLI a positional argument when required, otherwise a flag.
OperationReplyAn operation's result as it crosses a process: JSON, with any bytes the host saved by path.
SurfaceOperationOne public Camera operation with its MCP tool and CLI command names, as surfaceOperations() lists it.

Also exported: surfaceOperation()

@darkgrade/slate/runtime/mcp

packages/slate/src/runtime/mcp.ts

The MCP server: one camera_ tool per public Camera operation, generated from the same list. Needs the optional peer dependencies @modelcontextprotocol/server and zod.

import { serveStdio } from '@modelcontextprotocol/server/stdio'
import { HttpCameraClient } from '@darkgrade/slate/runtime'
import { createCameraMcpServer } from '@darkgrade/slate/runtime/mcp'

// Tools run on the cameras a host already holds.
const client = new HttpCameraClient(hostUrl)
await serveStdio(() => createCameraMcpServer(client))

Guide: MCP

Functions

ExportWhat it is
cameraToolDefinitions()One tool per public Camera operation, named and described from Camera itself: camera_ + the method in snake_case, with the method's inputs.
registerCameraTools()Registers the generated camera tools, plus camera_run_benchmark where the host offers it.
toolError()An MCP tool's error result; a busy camera keeps its code and retry hint for the client.

Constants

ExportWhat it is
slateToolMetaThe _meta key on every tool Slate generates, with the Camera operation it runs.

Types

ExportWhat it is
CameraToolDefinitionOne generated camera tool: its MCP name, schema and annotations, and the operation it runs.
CameraToolOptionsHow a host that holds one camera serves the tools.

Also exported: createCameraMcpServer()

@darkgrade/slate/runtime/ownership

packages/slate/src/runtime/ownership.ts

Cross-process camera ownership with leases and heartbeats, for a host with more than one process.

import { HardwareCoordinator } from '@darkgrade/slate/runtime/ownership'

Classes

ExportWhat it is
HardwareCoordinatorCross-process camera ownership, with reentrant nested calls on the same operation.

Constants

ExportWhat it is
OWNERSHIP_LEASE_MILLISECONDSHow long a claim lasts without a heartbeat, how often a held claim is renewed, and how often a waiting call retries.

Types

ExportWhat it is
OwnershipStoreThe store a HardwareCoordinator keeps its leases in, shared by every process that might open the same camera.

Also exported: OWNERSHIP_HEARTBEAT_MILLISECONDS

@darkgrade/slate/telemetry

packages/slate/src/contribute/application.ts

Diagnostics sharing for an application that embeds Slate: one shared queue per process.

Also importable as @darkgrade/slate/telemetry/application.

import { createApplicationDiagnostics } from '@darkgrade/slate/telemetry'

Guide: Telemetry

Functions

ExportWhat it is
createApplicationDiagnostics()Create once per application process and observe every camera through this shared queue.

Also exported: ApplicationDiagnosticsOptions InstallationState InstallationStore validateInstallationState()

@darkgrade/slate/telemetry/batch

packages/slate/src/contribute/batch.ts

The batch a client uploads, and its validation.

import { validateBatch } from '@darkgrade/slate/telemetry/batch'

Also exported: BATCH_SCHEMA DiagnosticBatch DIAGNOSTICS_NOTICE MAXIMUM_BATCH_CAMERAS NOTICE_VERSION validateBatch()

@darkgrade/slate/telemetry/installation-store

packages/slate/src/contribute/installation-store.ts

A file store for the installation state. The application supplies how it is protected.

import {
    installationFileStore,
} from '@darkgrade/slate/telemetry/installation-store'

Functions

ExportWhat it is
installationFileStore()One owner per application.

Also exported: CredentialProtection

@darkgrade/slate/telemetry/protocol

packages/slate/src/contribute/protocol.ts

The protocol evidence a diagnostic entry can carry, and its validation.

import { isSafeProtocolProperty } from '@darkgrade/slate/telemetry/protocol'

Functions

ExportWhat it is
validateProtocol()Explicit numeric fields only.

Also exported: isSafeProtocolProperty() ObservedSetting ProtocolCategory ProtocolEvidence ProtocolNumber StatePhase

@darkgrade/slate/telemetry/schema

packages/slate/src/contribute/schema.ts

The diagnostic entry schema, its limits and its validation.

import {
    cameraHardwareFingerprint,
} from '@darkgrade/slate/telemetry/schema'

Functions

ExportWhat it is
cameraHardwareFingerprint()Stable across reconnects, firmware updates and installations; absent when no reliable body serial exists.
redactMessage()Removes paths, addresses and long identifiers (serials, object ids) from an error message.
validateContribution()Reject extra fields instead of silently accepting images, serials, paths or free-form logs.

Constants

ExportWhat it is
CONTACT_CONFIRMATION_HOURSThe same, in hours, for help and messages.
CONTACT_CONFIRMATION_MILLISECONDSHow long an emailed confirmation link works.
isLegacyArgumentText()Argument text as a collector from before 2026-12-02 accepts it.
isSafeArgumentText()A setting value as Slate spells it (1/250, F2.8, IPB (Standard), Nikon's Fine★, a Canon movie record's label), never a path.

Types

ExportWhat it is
ApiCallA public Camera operation as the caller asked for it: the operation table's name (setShutterSpeed) with its MCP tool and CLI command, where it came from, and how it ended.
ApiCallArgumentOne input of a public call.
ApiCallErrorA failed call's typed error.

Also exported (14)

API_CALL_OUTCOMES API_CALL_SURFACES CameraContext Contribution DiagnosticEntry DISCLOSURE INSTALLATION_KEY installationIdOf() installationKey() isContributionId() MAXIMUM_BODY_BYTES MAXIMUM_ENTRIES Repeated SCHEMA

@darkgrade/slate/telemetry/settings

packages/slate/src/contribute/settings.ts

Where Node keeps the sharing preference and saved diagnostics, and the shared Node queue.

import { closeNodeDiagnostics } from '@darkgrade/slate/telemetry/settings'

Functions

ExportWhat it is
flushNodeDiagnostics()Bounded final delivery for process owners; never used on the camera-operation path.
knownCameras()Remembers, per USB identity a host asked for, the manufacturer and model the camera reported when it last answered there.
localDiagnostics()Per-process rotation avoids cross-process append/rotation races.
nodeDiagnostics()One queue and identity shared by all Slate cameras in this process; Studio and the CLI use the same file.
reportedFacts()Remembers, across processes, which unchanging protocol facts this installation already shared, so each camera connection does not upload the same inventory again.

Constants

ExportWhat it is
sharedKnownCameras()The installation's single record of which camera each USB identity last reported itself as.
sharedReportedFacts()The installation's single memory of protocol facts it has already shared.
telemetryEndpoint()An override changes the destination; opting out uses the saved preference or opt-out environment flags.

Also exported: closeNodeDiagnostics() DEFAULT_TELEMETRY_URL saveDiagnosticProfile() settingsDirectory() sharedSettings()

@darkgrade/slate/telemetry/server

packages/slate/src/telemetry/server/index.ts

The collector. Importing it connects no database and starts no service.

import { createTelemetry } from '@darkgrade/slate/telemetry/server'

Classes

ExportWhat it is
InvalidMatrixCursorA page of the Matrix export was asked for with a cursor the collector cannot read.
MatrixExportChangedThe Matrix export changed or expired between pages: restart the synchronisation from its first page.
TelemetryErrorThe collector refuses a request: status is the HTTP status to answer with, retryAfterSeconds when to try again.

Functions

ExportWhat it is
createTelemetry()A single service stores diagnostics and consent state in Postgres.
diagnosticPattern()Deterministic validated diagnostics; a review label is independent of import eligibility.
exportMatrixPage()Import all validated diagnostics.
exportReviewedPatterns()Replace a downstream snapshot wholesale.
operatorApi()Server-to-server operator API.
saveProtocolFinding()Findings belong to original evidence.
withdrawInstallation()The operator route must authenticate separately before omitting the installation key hash.

Constants

ExportWhat it is
CONTACT_CONFIRMATION_MILLISECONDSHow long an emailed confirmation link works.

Also exported (14)

cleanupInstallation() cleanupWithdrawals() ContactMessage DAILY_BATCH_LIMIT Database investigate() MatrixSource ProtocolFinding resendContactSender() RETENTION_DAYS reviewDiagnostic() Row TelemetryOptions Transaction

@darkgrade/slate/telemetry/postgres

packages/slate/src/telemetry/server/postgres.ts

The collector's Postgres database. Needs the optional peer dependency pg.

import { postgresDatabase } from '@darkgrade/slate/telemetry/postgres'

Functions

ExportWhat it is
postgresDatabase()Private operational state, flat diagnostic events, and per-session summaries kept current at ingest.

Constants

ExportWhat it is
unidentifiedPurgesOne-time removal requested on 2026-11-14: events recorded with no camera identity before Slate learned to read it (the first commands of every connection that could not be matched to a session identity, and whole native Sony sessions).

Also exported: unidentifiedPurge

⌘I