@smarthome.exchange/sdk
⚡ TypeScript automation authoring SDK for smarthome.exchange.
The SDK is the tiny, testable layer automation authors import. It lets automation files register typed triggers with on, ask device proxies to create tool plans, ask agent proxies for decisions, and run the same automation logic with or without a live hub executor attached.
Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit 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/ account to submit Pull Requests directly.
Install
pnpm add @smarthome.exchange/sdk
30-Second Automation
import { agents, devices, on } from '@smarthome.exchange/sdk';
on(
{
id: 'manual:evening-check',
kind: 'manual',
expression: 'evening-check',
},
async () => {
await devices.read('climate.office');
await agents.decide({
agentId: 'comfort',
goal: 'Prepare the office for an evening focus session.',
scopes: ['climate.read', 'climate.write', 'light.read', 'light.write'],
confidence: 0.72,
});
}
);
Custom Runtime Context
Use ShxAutomationContext when you want isolated tests, a custom caller id, or a hub-backed executor:
import { ShxAutomationContext } from '@smarthome.exchange/sdk';
const context = new ShxAutomationContext({
callerId: 'automation:morning-routine',
executePlan: async (planArg) => {
return hub.toolRegistry.executePlan(planArg);
},
});
context.on({ id: 'manual:morning', kind: 'manual', expression: 'morning' }, async () => {
await context.devices.read('energy.battery');
});
await context.runTrigger({
triggerId: 'manual:morning',
kind: 'manual',
payload: {},
});
If no executePlan function is provided, plans are returned with suggested results. That makes automation files safe to test without touching real devices.
Public API
| Export | Purpose |
|---|---|
ShxAutomationContext |
Owns automation registrations, trigger execution, caller id, device proxy, agent proxy, and optional plan executor. |
on |
Convenience registration function bound to the default automation context. |
devices |
Default DeviceProxy for building device tool plans. |
agents |
Default AgentProxy for building agent decision plans. |
DeviceProxy |
Exposes read(deviceId) and call(...) for device-oriented tool plans. |
AgentProxy |
Exposes decide(...) for agent decision tool plans. |
Trigger Matching
runTrigger invokes registrations when either the trigger id matches or the trigger kind matches. This lets you write exact manual automations and broader event-kind handlers with the same API.
Scripts
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 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.