@hasna/machines 0.0.48 → 0.0.49
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/README.md +19 -0
- package/dist/agent/index.js +34 -12
- package/dist/cli/index.js +504 -387
- package/dist/commands/mutation-approval.d.ts +11 -0
- package/dist/commands/runtime.d.ts +1 -0
- package/dist/consumer.js +0 -81
- package/dist/index.d.ts +57 -29
- package/dist/index.js +9202 -25314
- package/dist/mcp/index.js +120 -22
- package/dist/remote-storage.d.ts +5 -1
- package/dist/sdk-mutations.d.ts +54 -0
- package/dist/storage.d.ts +18 -3
- package/dist/storage.js +392 -92
- package/dist/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -21,6 +21,15 @@ export interface MutationApprovalOptions extends MutationApprovalScope {
|
|
|
21
21
|
env?: Env;
|
|
22
22
|
now?: number | Date;
|
|
23
23
|
}
|
|
24
|
+
export interface SdkMutationApprovalOptions {
|
|
25
|
+
approvalToken?: string;
|
|
26
|
+
trustedLocalMutation?: TrustedSdkMutationApproval;
|
|
27
|
+
callerId?: string;
|
|
28
|
+
runId?: string;
|
|
29
|
+
}
|
|
30
|
+
export type TrustedSdkMutationApproval = Readonly<{
|
|
31
|
+
__trustedSdkMutationApproval?: never;
|
|
32
|
+
}>;
|
|
24
33
|
export interface MutationApprovalClaims extends MutationApprovalScope {
|
|
25
34
|
version: 1;
|
|
26
35
|
issuedAt: number;
|
|
@@ -40,6 +49,7 @@ export interface MutationApprovalDecision {
|
|
|
40
49
|
reason?: string;
|
|
41
50
|
claims?: MutationApprovalClaims;
|
|
42
51
|
}
|
|
52
|
+
export declare function createTrustedSdkMutationApproval(): TrustedSdkMutationApproval;
|
|
43
53
|
export declare function canonicalMutationArgs(value: unknown): string;
|
|
44
54
|
export declare function mutationArgsSha256(value: unknown): string;
|
|
45
55
|
export declare function mutationPlanDigest(plan: unknown): string;
|
|
@@ -51,4 +61,5 @@ export declare function createMutationApprovalToken(scope: MutationApprovalScope
|
|
|
51
61
|
export declare function verifyMutationApprovalToken(options: MutationApprovalOptions): MutationApprovalDecision;
|
|
52
62
|
export declare function isMutationApproved(options?: Partial<MutationApprovalOptions>): boolean;
|
|
53
63
|
export declare function assertMutationApproved(options: MutationApprovalOptions): void;
|
|
64
|
+
export declare function assertSdkMutationApproved(scope: Omit<MutationApprovalScope, "surface" | "transport" | "callerId" | "runId">, options?: SdkMutationApprovalOptions): void;
|
|
54
65
|
export {};
|
|
@@ -35,6 +35,7 @@ export interface TmuxPaneDiedHookPlan {
|
|
|
35
35
|
deliver: boolean;
|
|
36
36
|
trustedLocalMutation: boolean;
|
|
37
37
|
}
|
|
38
|
+
export declare function assertMachinesCommandSafe(command: string): void;
|
|
38
39
|
export declare function buildTmuxPaneDiedHookPlan(options?: {
|
|
39
40
|
tmuxCommand?: string;
|
|
40
41
|
machinesCommand?: string;
|
package/dist/consumer.js
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
2
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
function __accessProp(key) {
|
|
8
|
-
return this[key];
|
|
9
|
-
}
|
|
10
|
-
var __toESMCache_node;
|
|
11
|
-
var __toESMCache_esm;
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
-
var canCache = mod != null && typeof mod === "object";
|
|
14
|
-
if (canCache) {
|
|
15
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
-
var cached = cache.get(mod);
|
|
17
|
-
if (cached)
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
for (let key of __getOwnPropNames(mod))
|
|
23
|
-
if (!__hasOwnProp.call(to, key))
|
|
24
|
-
__defProp(to, key, {
|
|
25
|
-
get: __accessProp.bind(mod, key),
|
|
26
|
-
enumerable: true
|
|
27
|
-
});
|
|
28
|
-
if (canCache)
|
|
29
|
-
cache.set(mod, to);
|
|
30
|
-
return to;
|
|
31
|
-
};
|
|
32
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
3
|
var __returnValue = (v) => v;
|
|
34
4
|
function __exportSetter(name, newValue) {
|
|
35
5
|
this[name] = __returnValue.bind(null, newValue);
|
|
@@ -211,51 +181,6 @@ function getAdapter(path = getDbPath()) {
|
|
|
211
181
|
function getDb(path = getDbPath()) {
|
|
212
182
|
return getAdapter(path).raw;
|
|
213
183
|
}
|
|
214
|
-
function closeDb() {
|
|
215
|
-
if (adapter) {
|
|
216
|
-
adapter.close();
|
|
217
|
-
adapter = null;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function upsertHeartbeat(machineId, pid = process.pid, status = "online", metadata = {}) {
|
|
221
|
-
const db = getDb();
|
|
222
|
-
db.query(`INSERT INTO agent_heartbeats (
|
|
223
|
-
machine_id,
|
|
224
|
-
pid,
|
|
225
|
-
status,
|
|
226
|
-
updated_at,
|
|
227
|
-
daemon_version,
|
|
228
|
-
agent_mode,
|
|
229
|
-
platform,
|
|
230
|
-
os_version,
|
|
231
|
-
os_build,
|
|
232
|
-
arch,
|
|
233
|
-
uptime_seconds,
|
|
234
|
-
tool_versions_json,
|
|
235
|
-
tailscale_json,
|
|
236
|
-
storage_sync_status,
|
|
237
|
-
storage_sync_last_error,
|
|
238
|
-
doctor_summary_json,
|
|
239
|
-
private_metadata
|
|
240
|
-
)
|
|
241
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
242
|
-
ON CONFLICT(machine_id, pid) DO UPDATE SET
|
|
243
|
-
status = excluded.status,
|
|
244
|
-
updated_at = excluded.updated_at,
|
|
245
|
-
daemon_version = excluded.daemon_version,
|
|
246
|
-
agent_mode = excluded.agent_mode,
|
|
247
|
-
platform = excluded.platform,
|
|
248
|
-
os_version = excluded.os_version,
|
|
249
|
-
os_build = excluded.os_build,
|
|
250
|
-
arch = excluded.arch,
|
|
251
|
-
uptime_seconds = excluded.uptime_seconds,
|
|
252
|
-
tool_versions_json = excluded.tool_versions_json,
|
|
253
|
-
tailscale_json = excluded.tailscale_json,
|
|
254
|
-
storage_sync_status = excluded.storage_sync_status,
|
|
255
|
-
storage_sync_last_error = excluded.storage_sync_last_error,
|
|
256
|
-
doctor_summary_json = excluded.doctor_summary_json,
|
|
257
|
-
private_metadata = excluded.private_metadata`).run(machineId, pid, status, new Date().toISOString(), metadata.daemonVersion ?? null, metadata.agentMode ?? null, metadata.platform ?? null, metadata.osVersion ?? null, metadata.osBuild ?? null, metadata.arch ?? null, metadata.uptimeSeconds == null ? null : Math.max(0, Math.floor(metadata.uptimeSeconds)), metadata.toolVersions ? JSON.stringify(metadata.toolVersions) : null, metadata.tailscale ? JSON.stringify(metadata.tailscale) : null, metadata.storageSyncStatus ?? null, metadata.storageSyncLastError ?? null, metadata.doctorSummary ? JSON.stringify(metadata.doctorSummary) : null, metadata.privateMetadata ? 1 : 0);
|
|
258
|
-
}
|
|
259
184
|
function getLocalMachineId() {
|
|
260
185
|
return process.env["HASNA_MACHINES_MACHINE_ID"] || hostname();
|
|
261
186
|
}
|
|
@@ -285,12 +210,6 @@ function countRuns(table) {
|
|
|
285
210
|
const row = db.query(`SELECT COUNT(*) as count FROM ${table}`).get();
|
|
286
211
|
return row.count;
|
|
287
212
|
}
|
|
288
|
-
function setHeartbeatStatus(machineId, pid, status) {
|
|
289
|
-
const db = getDb();
|
|
290
|
-
db.query(`UPDATE agent_heartbeats
|
|
291
|
-
SET status = ?, updated_at = ?
|
|
292
|
-
WHERE machine_id = ? AND pid = ?`).run(status, new Date().toISOString(), machineId, pid);
|
|
293
|
-
}
|
|
294
213
|
function recordSetupRun(machineId, status, details) {
|
|
295
214
|
const db = getDb();
|
|
296
215
|
const now = new Date().toISOString();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,63 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
2
|
export * from "./cross-project-types.js";
|
|
3
|
-
export * from "./paths.js";
|
|
4
|
-
export * from "./db.js";
|
|
5
|
-
export * from "./manifests.js";
|
|
6
3
|
export * from "./redaction.js";
|
|
7
4
|
export * from "./topology.js";
|
|
8
5
|
export * from "./compatibility.js";
|
|
9
|
-
export * from "./agent/runtime.js";
|
|
10
|
-
export * from "./commands/backup.js";
|
|
11
|
-
export * from "./commands/apps.js";
|
|
12
|
-
export * from "./commands/cert.js";
|
|
13
|
-
export * from "./commands/dns.js";
|
|
14
|
-
export * from "./commands/daemon.js";
|
|
15
|
-
export * from "./commands/doctor.js";
|
|
16
|
-
export * from "./commands/manifest.js";
|
|
17
|
-
export * from "./commands/mutation-approval.js";
|
|
18
|
-
export * from "./commands/diff.js";
|
|
19
|
-
export * from "./commands/install-claude.js";
|
|
20
|
-
export * from "./commands/install-tailscale.js";
|
|
21
|
-
export { addNotificationChannel, dispatchNotificationEvent, getDefaultNotificationConfig, listNotificationChannels, readNotificationConfig, removeNotificationChannel, testNotificationChannel, writeNotificationConfig, } from "./commands/notifications.js";
|
|
22
|
-
export * from "./commands/ports.js";
|
|
23
|
-
export * from "./commands/runtime.js";
|
|
24
|
-
export * from "./commands/self-test.js";
|
|
25
|
-
export * from "./commands/serve.js";
|
|
26
|
-
export * from "./commands/setup.js";
|
|
27
|
-
export * from "./commands/ssh.js";
|
|
28
|
-
export * from "./commands/screen.js";
|
|
29
|
-
export * from "./commands/sync.js";
|
|
30
|
-
export * from "./commands/status.js";
|
|
31
|
-
export * from "./commands/workspace.js";
|
|
32
|
-
export * from "./mcp/server.js";
|
|
33
|
-
export { MACHINES_STORAGE_ENV, MACHINES_STORAGE_FALLBACK_ENV, MACHINES_STORAGE_MODE_ENV, MACHINES_STORAGE_MODE_FALLBACK_ENV, MACHINES_STORAGE_TABLES, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, STORAGE_TABLES, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, getStorageMode, getStoragePg, getStorageStatus, getSyncMetaAll, parseStorageTables, resolveTables, runStorageMigrations, storagePull, storagePush, storageSync, } from "./storage.js";
|
|
34
|
-
export type { StorageEnv, StorageMode, StorageStatus, SyncMeta, SyncResult as StorageSyncResult } from "./storage.js";
|
|
35
6
|
export * from "./version.js";
|
|
7
|
+
export { MACHINES_STORAGE_ENV, MACHINES_STORAGE_FALLBACK_ENV, MACHINES_STORAGE_MODE_ENV, MACHINES_STORAGE_MODE_FALLBACK_ENV, MACHINES_STORAGE_TABLES, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, STORAGE_TABLES, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, getStorageMode, getStorageStatus, getSyncMetaAll, parseStorageTables, resolveTables, runStorageMigrations, storagePull, storagePush, storageSync, PG_MIGRATIONS, } from "./storage.js";
|
|
8
|
+
export type { StorageEnv, StorageMigrationAdapter, StorageMode, StorageMutationOptions, StorageStatus, SyncMeta, SyncResult as StorageSyncResult, } from "./storage.js";
|
|
9
|
+
export { getDataDir, getDbPath, getManifestPath, getNotificationsPath, getClipboardKeyPath, getClipboardHistoryPath, ensureDataDir, } from "./paths.js";
|
|
10
|
+
export { PRIVATE_MANIFEST_BACKEND_ENV, PRIVATE_MANIFEST_REF_ENV, fleetSchema, machineSchema, detectCurrentMachineManifest, getDefaultManifest, getManifestMachine, getManifestSourceRef, readManifest, readManifestWithSource, validateManifest, } from "./manifests.js";
|
|
11
|
+
export type { ManifestSourceAdapter, ReadManifestWithSourceOptions } from "./manifests.js";
|
|
12
|
+
export { manifestAdd, manifestBootstrapCurrentMachine, manifestInit, manifestRemove, } from "./sdk-mutations.js";
|
|
13
|
+
export { manifestGet, manifestList, manifestValidate, } from "./commands/manifest.js";
|
|
14
|
+
export { LEGACY_MUTATION_APPROVAL_FLAG_ENV, MUTATION_APPROVAL_CALLER_ENV, MUTATION_APPROVAL_FLAG_ENV, MUTATION_APPROVAL_REPLAY_PATH_ENV, MUTATION_APPROVAL_RUN_ENV, MUTATION_APPROVAL_TOKEN_ENV, assertMutationApproved, assertMutationPlanDigest, assertSdkMutationApproved, attachMutationPlanDigest, canonicalMutationArgs, createMutationApprovalToken, isMutationApproved, mutationArgsSha256, mutationPlanDigest, verifyMutationApprovalToken, } from "./commands/mutation-approval.js";
|
|
15
|
+
export type { CreateMutationApprovalTokenOptions, MutationApprovalClaims, MutationApprovalDecision, MutationApprovalOptions, MutationApprovalScope, SdkMutationApprovalOptions, } from "./commands/mutation-approval.js";
|
|
16
|
+
export { buildBackupPlan, resolveBackupTarget, MACHINES_BACKUP_BUCKET_ENV, MACHINES_BACKUP_BUCKET_FALLBACK_ENV, MACHINES_BACKUP_PREFIX_ENV, MACHINES_BACKUP_PREFIX_FALLBACK_ENV, DEFAULT_BACKUP_PREFIX, } from "./commands/backup.js";
|
|
17
|
+
export type { BackupTarget } from "./commands/backup.js";
|
|
18
|
+
export { runBackup } from "./sdk-mutations.js";
|
|
19
|
+
export { buildAppsPlan, diffApps, getAppsStatus, listApps, } from "./commands/apps.js";
|
|
20
|
+
export type { RunAppsInstallOptions } from "./commands/apps.js";
|
|
21
|
+
export { runAppsInstall, runAppsPlan, } from "./sdk-mutations.js";
|
|
22
|
+
export { buildCertPlan } from "./commands/cert.js";
|
|
23
|
+
export { runCertPlan } from "./sdk-mutations.js";
|
|
24
|
+
export { listDomainMappings, renderDomainMapping, } from "./commands/dns.js";
|
|
25
|
+
export type { DomainMapping } from "./commands/dns.js";
|
|
26
|
+
export { addDomainMapping } from "./sdk-mutations.js";
|
|
27
|
+
export { buildDaemonInstallPlan, buildDaemonLogsPlan, buildDaemonRestartPlan, buildDaemonServicePlan, buildDaemonStatusPlan, buildDaemonUninstallPlan, renderLaunchdPlist, renderSystemdUnit, } from "./commands/daemon.js";
|
|
28
|
+
export type { DaemonServiceAction, DaemonServiceCommand, DaemonServiceCommandResult, DaemonServiceFile, DaemonServiceMode, DaemonServiceOptions, DaemonServicePlan, DaemonServicePlatform, DaemonServiceRunOptions, DaemonServiceRunResult, } from "./commands/daemon.js";
|
|
29
|
+
export { runDaemonServicePlan } from "./sdk-mutations.js";
|
|
30
|
+
export { runDoctor, DOCTOR_OPTIONAL_ADAPTER_DOMAINS } from "./commands/doctor.js";
|
|
31
|
+
export type { DoctorAdapter, DoctorAdapterContext, DoctorAdapterHook, DoctorOptions, DoctorOptionalAdapterDomain } from "./commands/doctor.js";
|
|
32
|
+
export { diffMachines } from "./commands/diff.js";
|
|
33
|
+
export { buildClaudeInstallPlan, diffClaudeCli, getClaudeCliStatus, } from "./commands/install-claude.js";
|
|
34
|
+
export type { AiCliTool, RunClaudeInstallOptions } from "./commands/install-claude.js";
|
|
35
|
+
export { runClaudeInstall, runClaudeInstallPlan, } from "./sdk-mutations.js";
|
|
36
|
+
export { buildTailscaleInstallPlan } from "./commands/install-tailscale.js";
|
|
37
|
+
export type { RunTailscaleInstallOptions } from "./commands/install-tailscale.js";
|
|
38
|
+
export { runTailscaleInstall, runTailscaleInstallPlan, } from "./sdk-mutations.js";
|
|
39
|
+
export { createTrustedNotificationApproval, getDefaultNotificationConfig, listNotificationChannels, readNotificationConfig, } from "./commands/notifications.js";
|
|
40
|
+
export type { TrustedNotificationApproval } from "./commands/notifications.js";
|
|
41
|
+
export { addNotificationChannel, dispatchNotificationEvent, removeNotificationChannel, testNotificationChannel, writeNotificationConfig, } from "./sdk-mutations.js";
|
|
42
|
+
export { listPorts, parsePortOutput } from "./commands/ports.js";
|
|
43
|
+
export type { ListeningPort, PortsResult } from "./commands/ports.js";
|
|
44
|
+
export { buildTmuxPaneDiedHookPlan, probeTmuxPane, } from "./commands/runtime.js";
|
|
45
|
+
export type { TmuxPaneDiedHookPlan, TmuxPaneProbeResult, TmuxWatchOptions, TmuxWatchResult } from "./commands/runtime.js";
|
|
46
|
+
export { buildSetupPlan } from "./commands/setup.js";
|
|
47
|
+
export type { RunSetupOptions } from "./commands/setup.js";
|
|
48
|
+
export { runSetup, runSetupPlan, } from "./sdk-mutations.js";
|
|
49
|
+
export { buildScreenCommand, buildScreenEnableCommand, buildScreenEnableRemoteCommand, buildScreenEnableRemoteCommandFromStdin, defaultScreenPasswordSecretKey, resolveScreenCredentials, resolveScreenTarget, DEFAULT_SCREEN_SECRET_NAMESPACE, SCREEN_SECRET_NAMESPACE_ENV, } from "./commands/screen.js";
|
|
50
|
+
export type { ResolvedScreenTarget, ScreenCredentialOptions, ScreenCredentialResolution, ScreenEnableCommandOptions, ScreenEnableCommandPlan } from "./commands/screen.js";
|
|
51
|
+
export { buildSshCommand, buildSshCommandArgs, buildSshCommandPlan, resolveSshTarget, validateSshTarget, } from "./commands/ssh.js";
|
|
52
|
+
export type { ResolvedSshTarget, SshCommandPlan } from "./commands/ssh.js";
|
|
53
|
+
export { buildSyncPlan } from "./commands/sync.js";
|
|
54
|
+
export type { RunSyncOptions } from "./commands/sync.js";
|
|
55
|
+
export { runSync, runSyncPlan, } from "./sdk-mutations.js";
|
|
56
|
+
export { getStatus } from "./commands/status.js";
|
|
57
|
+
export type { FleetStatusOptions } from "./commands/status.js";
|
|
58
|
+
export { runSelfTest } from "./commands/self-test.js";
|
|
59
|
+
export { getServeInfo, renderDashboardHtml, } from "./commands/serve.js";
|
|
60
|
+
export type { ServeInfo, ServeOptions } from "./commands/serve.js";
|
|
61
|
+
export { getAgentStatus, sanitizePublicString, } from "./agent/runtime.js";
|
|
62
|
+
export type { AgentRuntimeOptions, AgentRuntimeStatus, AgentStatusOptions, AgentTickOptions } from "./agent/runtime.js";
|
|
63
|
+
export { MACHINES_CONSUMER_SCHEMA_BUNDLE } from "./consumer-schema.js";
|