Files

114 lines
5.1 KiB
Markdown
Raw Permalink Normal View History

2026-05-05 12:03:46 +00:00
# @smarthome.exchange/interfaces
2026-05-05 19:53:54 +00:00
📐 Shared TypeScript data interfaces and TypedRequest contracts for every smarthome.exchange package.
This package is the contract layer. It defines the durable shapes for homes, devices, rooms, agents, automations, tools, approvals, audit receipts, dashboards, and typed hub requests. It contains no runtime business logic, which makes it safe to import from hubs, CLIs, browser apps, automation files, tests, and integration packages.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Install
```bash
pnpm add @smarthome.exchange/interfaces
```
## Import Pattern
```ts
import type { data, request } from '@smarthome.exchange/interfaces';
const device: data.IDeviceDefinition = {
id: 'light.living.floor',
name: 'Living Floor Lamp',
protocol: 'hue',
online: true,
features: [
{
id: 'power',
capability: 'light',
name: 'Power',
readable: true,
writable: true,
},
],
state: [
{
featureId: 'power',
value: true,
updatedAt: new Date().toISOString(),
},
],
};
type SnapshotResponse = request.IReq_GetHomeSnapshot['response'];
```
## Public Surface
The package exports two namespaces from the root entry point:
| Namespace | What it contains |
| --- | --- |
| `data` | Durable domain objects such as `IDeviceDefinition`, `IAgentDefinition`, `IToolPlan`, `IApprovalRequest`, and `IHomeSnapshot`. |
| `request` | TypedRequest contracts such as `IReq_ListDevices`, `IReq_ExecuteToolPlan`, and `IReq_SubmitApproval`. |
## Data Contracts
Core groups include:
- Home state: `IHomeDefinition`, `IHomeMember`, `IHomeSnapshot`.
- Devices and rooms: `IDeviceDefinition`, `IDeviceFeature`, `IDeviceState`, `IRoomDefinition`.
- Agents: `IAgentDefinition`, `IAgentStatus`, `IAgentReasoningEvent`.
- Tools and approvals: `IToolDefinition`, `IToolCall`, `IToolPlan`, `IToolPlanResult`, `IApprovalRequest`.
- Automations: `IAutomationDefinition`, `IAutomationTrigger`, `IAutomationRun`.
- Dashboards and audit: `IDashboardDefinition`, `IDashboardWidget`, `IAuditReceipt`.
Device protocols are explicit string unions such as `matter`, `zigbee`, `thread`, `mqtt`, `homeassistant`, `hue`, `http`, `cloud`, and `virtual`. Tool scopes are equally explicit, including `device.read`, `device.write`, `light.write`, `climate.write`, `approval.write`, and `*.read`.
## TypedRequest Contracts
The request namespace defines the hub API boundary:
| Method | Contract | Purpose |
| --- | --- | --- |
| `getHomeSnapshot` | `IReq_GetHomeSnapshot` | Return the complete home snapshot. |
| `listDevices` | `IReq_ListDevices` | List devices, optionally filtered by room/capability/online state. |
| `listAgents` | `IReq_ListAgents` | List agents and runtime statuses. |
| `listTools` | `IReq_ListTools` | List available tools, optionally by owner. |
| `executeToolPlan` | `IReq_ExecuteToolPlan` | Execute, queue, or suggest a typed tool plan. |
| `listApprovals` | `IReq_ListApprovals` | Query approval requests by status. |
| `submitApproval` | `IReq_SubmitApproval` | Approve or reject a pending approval. |
Every request interface carries a literal `method`, a typed `request`, and a typed `response`, so API clients and hub handlers stay in lockstep.
## Scripts
```bash
pnpm test
pnpm build
pnpm buildDocs
```
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH\
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.