@minion-stack/shared 0.5.0 → 0.7.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.
@@ -0,0 +1,22 @@
1
+ export type CacheInvalidateSource = 'hub' | 'gateway' | 'paperclip' | 'browser' | 'site';
2
+ export interface CacheInvalidatePayload {
3
+ /** Tag names whose entries should be busted. Always present (may be empty if `keys` covers the bust). */
4
+ tags: string[];
5
+ /** Optional surgical key list — busted in addition to tag-matched keys. */
6
+ keys?: string[];
7
+ /** Runtime that originated the mutation. */
8
+ source: CacheInvalidateSource;
9
+ /** Per-process unique id so emitters can dedupe their own busts. */
10
+ sourceId: string;
11
+ /** Tenant scope — subscribers may gate on this. Empty string means global/no-tenant. */
12
+ tenantId: string;
13
+ /** Emission timestamp, ms since epoch. */
14
+ ts: number;
15
+ }
16
+ export interface CacheInvalidateEvent {
17
+ type: 'event';
18
+ event: 'cache.invalidate';
19
+ payload: CacheInvalidatePayload;
20
+ }
21
+ export declare function isCacheInvalidateEvent(value: unknown): value is CacheInvalidateEvent;
22
+ //# sourceMappingURL=cache-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-events.d.ts","sourceRoot":"","sources":["../../src/gateway/cache-events.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzF,MAAM,WAAW,sBAAsB;IACrC,yGAAyG;IACzG,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,4CAA4C;IAC5C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAapF"}
@@ -0,0 +1,21 @@
1
+ // Cache invalidation gateway event frame.
2
+ //
3
+ // Convention follows existing EventFrame in ./types.ts:
4
+ // { type: 'event', event: '<name>', payload: {...} }
5
+ // (No `v: 3` discriminator — the gateway WS protocol does not version frames.)
6
+ export function isCacheInvalidateEvent(value) {
7
+ if (typeof value !== 'object' || value === null)
8
+ return false;
9
+ const v = value;
10
+ if (v.type !== 'event' || v.event !== 'cache.invalidate')
11
+ return false;
12
+ if (typeof v.payload !== 'object' || v.payload === null)
13
+ return false;
14
+ const p = v.payload;
15
+ return (Array.isArray(p.tags) &&
16
+ typeof p.source === 'string' &&
17
+ typeof p.sourceId === 'string' &&
18
+ typeof p.tenantId === 'string' &&
19
+ typeof p.ts === 'number');
20
+ }
21
+ //# sourceMappingURL=cache-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-events.js","sourceRoot":"","sources":["../../src/gateway/cache-events.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,wDAAwD;AACxD,uDAAuD;AACvD,+EAA+E;AAyB/E,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,KAAK,KAAK,kBAAkB;QAAE,OAAO,KAAK,CAAC;IACvE,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAkC,CAAC;IAC/C,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACrB,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ;QAC5B,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache-events.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-events.test.d.ts","sourceRoot":"","sources":["../../src/gateway/cache-events.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { isCacheInvalidateEvent } from './cache-events.js';
3
+ describe('CacheInvalidateEvent', () => {
4
+ it('isCacheInvalidateEvent returns true for a valid event', () => {
5
+ const evt = {
6
+ type: 'event',
7
+ event: 'cache.invalidate',
8
+ payload: {
9
+ tags: ['t:abc:agent-groups'],
10
+ keys: [],
11
+ source: 'hub',
12
+ sourceId: 'vercel-fn-1',
13
+ tenantId: 'ten_abc',
14
+ ts: 1715500000000,
15
+ },
16
+ };
17
+ expect(isCacheInvalidateEvent(evt)).toBe(true);
18
+ });
19
+ it('isCacheInvalidateEvent returns false for the wrong name', () => {
20
+ const evt = {
21
+ type: 'event',
22
+ event: 'chat.message',
23
+ payload: { tags: [], keys: [], source: 'hub', sourceId: 'x', tenantId: 't', ts: 0 },
24
+ };
25
+ expect(isCacheInvalidateEvent(evt)).toBe(false);
26
+ });
27
+ it('isCacheInvalidateEvent returns false for non-objects', () => {
28
+ expect(isCacheInvalidateEvent(null)).toBe(false);
29
+ expect(isCacheInvalidateEvent('event')).toBe(false);
30
+ expect(isCacheInvalidateEvent({})).toBe(false);
31
+ });
32
+ it('isCacheInvalidateEvent allows missing optional keys', () => {
33
+ const evt = {
34
+ type: 'event',
35
+ event: 'cache.invalidate',
36
+ payload: {
37
+ tags: ['t:abc'],
38
+ source: 'gateway',
39
+ sourceId: 'gw-1',
40
+ tenantId: 'ten_abc',
41
+ ts: 0,
42
+ },
43
+ };
44
+ expect(isCacheInvalidateEvent(evt)).toBe(true);
45
+ });
46
+ });
47
+ //# sourceMappingURL=cache-events.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-events.test.js","sourceRoot":"","sources":["../../src/gateway/cache-events.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAA6B,MAAM,mBAAmB,CAAC;AAEtF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,GAAG,GAAyB;YAChC,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,oBAAoB,CAAC;gBAC5B,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,aAAa;gBACvB,QAAQ,EAAE,SAAS;gBACnB,EAAE,EAAE,aAAa;aAClB;SACF,CAAC;QACF,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;SACpF,CAAC;QACF,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,OAAO,CAAC;gBACf,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE,MAAM;gBAChB,QAAQ,EAAE,SAAS;gBACnB,EAAE,EAAE,CAAC;aACN;SACF,CAAC;QACF,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -2,4 +2,7 @@ export * from './types.js';
2
2
  export * from './protocol.js';
3
3
  export * from './connection.js';
4
4
  export * from './client.js';
5
+ export * from './cache-events.js';
6
+ export * from './secrets.js';
7
+ export * from './shells.js';
5
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -2,4 +2,7 @@ export * from './types.js';
2
2
  export * from './protocol.js';
3
3
  export * from './connection.js';
4
4
  export * from './client.js';
5
+ export * from './cache-events.js';
6
+ export * from './secrets.js';
7
+ export * from './shells.js';
5
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,85 @@
1
+ export declare const SECRETS_METHODS: {
2
+ readonly list: "secrets.list";
3
+ readonly set: "secrets.set";
4
+ readonly clear: "secrets.clear";
5
+ readonly probe: "secrets.probe";
6
+ readonly setScoped: "secrets.set_scoped";
7
+ readonly clearScoped: "secrets.clear_scoped";
8
+ readonly probeScoped: "secrets.probe_scoped";
9
+ };
10
+ export type SecretsProbeStatus = "ok" | "invalid" | "unknown" | "missing";
11
+ export type SecretsKind = "static" | "dynamic";
12
+ /** One entry in the secrets.list response payload. NEVER contains plaintext. */
13
+ export interface SecretsSummary {
14
+ rowKey: string;
15
+ groupKey: string;
16
+ instanceId: string | null;
17
+ kind: SecretsKind;
18
+ ownerPlugin: string;
19
+ label: string;
20
+ description?: string;
21
+ probe: string;
22
+ configured: boolean;
23
+ probeStatus: SecretsProbeStatus;
24
+ probeMessage: string | null;
25
+ lastProbeAt: number | null;
26
+ updatedAt: number;
27
+ }
28
+ export interface SecretsListParams {
29
+ }
30
+ export interface SecretsListResult {
31
+ secrets: SecretsSummary[];
32
+ }
33
+ export interface SecretsSetParams {
34
+ key: string;
35
+ value: string;
36
+ }
37
+ export interface SecretsSetResult {
38
+ key: string;
39
+ probeStatus: SecretsProbeStatus;
40
+ probeMessage: string;
41
+ }
42
+ export interface SecretsClearParams {
43
+ key: string;
44
+ }
45
+ export interface SecretsClearResult {
46
+ key: string;
47
+ }
48
+ export interface SecretsProbeParams {
49
+ key: string;
50
+ }
51
+ export interface SecretsProbeResult {
52
+ key: string;
53
+ probeStatus: SecretsProbeStatus;
54
+ probeMessage: string;
55
+ }
56
+ export interface SecretsSetScopedParams {
57
+ groupKey: string;
58
+ instanceId: string;
59
+ value: string;
60
+ }
61
+ export interface SecretsSetScopedResult {
62
+ groupKey: string;
63
+ instanceId: string;
64
+ probeStatus: SecretsProbeStatus;
65
+ probeMessage: string;
66
+ }
67
+ export interface SecretsClearScopedParams {
68
+ groupKey: string;
69
+ instanceId: string;
70
+ }
71
+ export interface SecretsClearScopedResult {
72
+ groupKey: string;
73
+ instanceId: string;
74
+ }
75
+ export interface SecretsProbeScopedParams {
76
+ groupKey: string;
77
+ instanceId: string;
78
+ }
79
+ export interface SecretsProbeScopedResult {
80
+ groupKey: string;
81
+ instanceId: string;
82
+ probeStatus: SecretsProbeStatus;
83
+ probeMessage: string;
84
+ }
85
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/gateway/secrets.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe;;;;;;;;CAQl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EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,kBAAkB,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,kBAAkB,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,11 @@
1
+ // RPC method name constants (use these on both client and server)
2
+ export const SECRETS_METHODS = {
3
+ list: "secrets.list",
4
+ set: "secrets.set",
5
+ clear: "secrets.clear",
6
+ probe: "secrets.probe",
7
+ setScoped: "secrets.set_scoped",
8
+ clearScoped: "secrets.clear_scoped",
9
+ probeScoped: "secrets.probe_scoped",
10
+ };
11
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/gateway/secrets.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,oBAAoB;IAC/B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,sBAAsB;CAC3B,CAAC"}
@@ -0,0 +1,346 @@
1
+ export declare const SHELLS_METHODS: {
2
+ readonly list: "shells.list";
3
+ readonly get: "shells.get";
4
+ readonly quota: "shells.quota";
5
+ readonly provision: "shells.provision";
6
+ readonly invoke: "shells.invoke";
7
+ readonly cancel: "shells.cancel";
8
+ readonly archive: "shells.archive";
9
+ readonly wake: "shells.wake";
10
+ readonly restart: "shells.restart";
11
+ readonly destroy: "shells.destroy";
12
+ readonly backupNow: "shells.backup_now";
13
+ readonly listBackups: "shells.list_backups";
14
+ readonly update: "shells.update";
15
+ readonly register: "shells.register";
16
+ readonly heartbeat: "shells.heartbeat";
17
+ readonly fatal: "shells.fatal";
18
+ };
19
+ export declare const SHELLS_EVENTS: {
20
+ readonly online: "shell.online";
21
+ readonly archived: "shell.archived";
22
+ readonly errored: "shell.error";
23
+ readonly delta: "shell.delta";
24
+ readonly final: "shell.final";
25
+ readonly backupDone: "shell.backup_done";
26
+ readonly quotaChanged: "shells.quota_changed";
27
+ };
28
+ /** Identifier of a harness baked into an exe.dev image. */
29
+ export type ShellHarness = 'hermes' | 'claude-code' | 'codex' | (string & {});
30
+ /** Lifecycle state. */
31
+ export type ShellStatus = 'provisioning' | 'online' | 'archived' | 'error';
32
+ /** Reason qualifier accompanying status="error". */
33
+ export type ShellErrorReason = 'provision_failed' | 'bridge_unreachable' | 'backup_stuck' | 'restore_failed' | 'exedev_outage' | 'unknown';
34
+ /** Backup cadence. `manual` means no automatic backups; user triggers via shells.backup_now. */
35
+ export type ShellBackupCadence = 'hourly' | 'daily' | 'weekly' | 'manual';
36
+ /** One shell row as returned by shells.list / shells.get. Never contains secrets. */
37
+ export interface ShellSummary {
38
+ shellId: string;
39
+ vmName: string;
40
+ displayName: string;
41
+ harness: ShellHarness;
42
+ image: string;
43
+ region: string;
44
+ status: ShellStatus;
45
+ errorReason?: ShellErrorReason;
46
+ errorMessage?: string;
47
+ diskGB: number;
48
+ memoryMB: number;
49
+ /** Null = always-on (auto-archive disabled). */
50
+ archiveIdleMs: number | null;
51
+ backupCadence: ShellBackupCadence;
52
+ backupTarget: string;
53
+ lastInvokeAt: number | null;
54
+ lastBackupAt: number | null;
55
+ lastBackupBytes: number | null;
56
+ createdAt: number;
57
+ updatedAt: number;
58
+ }
59
+ /** Quota snapshot returned by shells.quota. */
60
+ export interface ShellsQuota {
61
+ shells: {
62
+ used: number;
63
+ limit: number;
64
+ };
65
+ diskGB: {
66
+ used: number;
67
+ limit: number;
68
+ };
69
+ memoryMB: {
70
+ used: number;
71
+ limit: number;
72
+ };
73
+ shelleyUSD: {
74
+ used: number;
75
+ limit: number;
76
+ };
77
+ egressGB: {
78
+ used: number;
79
+ limit: number;
80
+ };
81
+ /** Soft headroom — used by the provisioner to refuse new shells before the hard cap. */
82
+ headroom: {
83
+ diskGB: number;
84
+ };
85
+ }
86
+ /** shells.list — no params. Returns ShellSummary[]. */
87
+ export interface ShellsListResponse {
88
+ shells: ShellSummary[];
89
+ }
90
+ /** shells.get */
91
+ export interface ShellsGetParams {
92
+ shellId: string;
93
+ }
94
+ export type ShellsGetResponse = ShellSummary;
95
+ /** shells.quota — no params. */
96
+ export type ShellsQuotaResponse = ShellsQuota;
97
+ /** shells.provision */
98
+ export interface ShellsProvisionParams {
99
+ displayName: string;
100
+ harness: ShellHarness;
101
+ image?: string;
102
+ region?: string;
103
+ diskGB?: number;
104
+ memoryMB?: number;
105
+ archiveIdleMs?: number | null;
106
+ backupCadence?: ShellBackupCadence;
107
+ /** Optional initial prompt forwarded to the harness on first boot. */
108
+ initialPrompt?: string;
109
+ }
110
+ export interface ShellsProvisionResponse {
111
+ shellId: string;
112
+ vmName: string;
113
+ status: ShellStatus;
114
+ deviceToken: string;
115
+ }
116
+ /** shells.invoke — forwards to the bridge, which translates to ACP `session/prompt`. */
117
+ export interface ShellsInvokeParams {
118
+ shellId: string;
119
+ sessionId: string;
120
+ input: {
121
+ kind: 'text';
122
+ text: string;
123
+ } | {
124
+ kind: 'multimodal';
125
+ parts: Array<{
126
+ type: string;
127
+ [k: string]: unknown;
128
+ }>;
129
+ };
130
+ /** Force-wake if archived. Default true. */
131
+ wakeIfArchived?: boolean;
132
+ }
133
+ export interface ShellsInvokeResponse {
134
+ runId: string;
135
+ startedAt: number;
136
+ }
137
+ /** shells.cancel — forwards to ACP `session/cancel`. */
138
+ export interface ShellsCancelParams {
139
+ shellId: string;
140
+ runId: string;
141
+ }
142
+ export interface ShellsCancelResponse {
143
+ cancelled: boolean;
144
+ }
145
+ /** shells.archive — backup + ssh exe.dev rm. Idempotent on already-archived. */
146
+ export interface ShellsArchiveParams {
147
+ shellId: string;
148
+ /** If true, skip backup (data-loss). Default false. */
149
+ skipBackup?: boolean;
150
+ }
151
+ export interface ShellsArchiveResponse {
152
+ shellId: string;
153
+ status: ShellStatus;
154
+ backupId?: string;
155
+ backupBytes?: number;
156
+ }
157
+ /** shells.wake — provision fresh VM + restore from latest backup. */
158
+ export interface ShellsWakeParams {
159
+ shellId: string;
160
+ /** Backup to restore from. Default: latest. */
161
+ backupId?: string;
162
+ }
163
+ export interface ShellsWakeResponse {
164
+ shellId: string;
165
+ status: ShellStatus;
166
+ restoringFromBackupId: string;
167
+ }
168
+ /** shells.restart — `ssh exe.dev restart`. Online shells only. */
169
+ export interface ShellsRestartParams {
170
+ shellId: string;
171
+ }
172
+ export interface ShellsRestartResponse {
173
+ shellId: string;
174
+ status: ShellStatus;
175
+ }
176
+ /** shells.destroy — permanent. `ssh exe.dev rm` + drop B2 backups (opt-out). */
177
+ export interface ShellsDestroyParams {
178
+ shellId: string;
179
+ keepBackups?: boolean;
180
+ }
181
+ export interface ShellsDestroyResponse {
182
+ shellId: string;
183
+ removedBackups: number;
184
+ }
185
+ /** shells.backup_now — manual backup trigger. Returns when upload completes. */
186
+ export interface ShellsBackupNowParams {
187
+ shellId: string;
188
+ }
189
+ export interface ShellsBackupNowResponse {
190
+ backupId: string;
191
+ bytes: number;
192
+ uploadMs: number;
193
+ }
194
+ /** shells.list_backups */
195
+ export interface ShellsListBackupsParams {
196
+ shellId: string;
197
+ limit?: number;
198
+ }
199
+ export interface ShellBackupEntry {
200
+ backupId: string;
201
+ shellId: string;
202
+ bytes: number;
203
+ createdAt: number;
204
+ restoredAt: number | null;
205
+ }
206
+ export interface ShellsListBackupsResponse {
207
+ backups: ShellBackupEntry[];
208
+ }
209
+ /** shells.update — partial. Server validates which fields are mutable per status. */
210
+ export interface ShellsUpdateParams {
211
+ shellId: string;
212
+ patch: Partial<Pick<ShellSummary, 'displayName' | 'archiveIdleMs' | 'backupCadence' | 'backupTarget'>>;
213
+ }
214
+ export type ShellsUpdateResponse = ShellSummary;
215
+ /** shells.register — bridge claims its shellId after connecting. */
216
+ export interface ShellsRegisterParams {
217
+ shellId: string;
218
+ deviceToken: string;
219
+ harness: ShellHarness;
220
+ harnessVersion: string;
221
+ bridgeVersion: string;
222
+ capabilities: ShellCapabilities;
223
+ }
224
+ export interface ShellCapabilities {
225
+ /** ACP methods this harness supports. Gateway uses to reject unsupported invokes early. */
226
+ acpMethods: string[];
227
+ /** True if the harness can stream `session/update` events. */
228
+ streaming: boolean;
229
+ /** Backup mechanism the bridge uses ('tar+b2', 'rclone', …). */
230
+ backupKind: string;
231
+ /** Max concurrent runs supported (1 for single-threaded harnesses). */
232
+ maxConcurrentRuns: number;
233
+ }
234
+ export interface ShellsRegisterResponse {
235
+ shellId: string;
236
+ /** Server-issued heartbeat cadence (ms). Bridge calls shells.heartbeat every N ms. */
237
+ heartbeatMs: number;
238
+ }
239
+ /** shells.heartbeat — bridge liveness ping. */
240
+ export interface ShellsHeartbeatParams {
241
+ shellId: string;
242
+ activeRunIds: string[];
243
+ diskUsedMB: number;
244
+ memoryUsedMB: number;
245
+ }
246
+ export type ShellsHeartbeatResponse = {
247
+ ts: number;
248
+ };
249
+ /** shells.fatal — bridge reports unrecoverable error before exiting. */
250
+ export interface ShellsFatalParams {
251
+ shellId: string;
252
+ reason: ShellErrorReason;
253
+ message: string;
254
+ }
255
+ export type ShellsFatalResponse = {
256
+ acknowledged: true;
257
+ };
258
+ /** shell.online — emitted when bridge registers (after provision OR after wake). */
259
+ export interface ShellOnlinePayload {
260
+ shellId: string;
261
+ harness: ShellHarness;
262
+ harnessVersion: string;
263
+ /** True if this transition was from 'archived' rather than 'provisioning'. */
264
+ resumedFromArchive: boolean;
265
+ }
266
+ /** shell.archived — emitted when archive completes successfully. */
267
+ export interface ShellArchivedPayload {
268
+ shellId: string;
269
+ backupId: string;
270
+ backupBytes: number;
271
+ }
272
+ /** shell.error — emitted on any transition into status='error'. */
273
+ export interface ShellErrorPayload {
274
+ shellId: string;
275
+ reason: ShellErrorReason;
276
+ message: string;
277
+ /** Suggested next user action: 'restart' | 'wake' | 'destroy' | 'wait' | null. */
278
+ remediation: 'restart' | 'wake' | 'destroy' | 'wait' | null;
279
+ }
280
+ /**
281
+ * shell.delta — streaming partial output from the harness.
282
+ * Mirrors ChatEvent shape so existing hub stream renderers can consume it
283
+ * with minimal adaptation.
284
+ */
285
+ export interface ShellDeltaPayload {
286
+ shellId: string;
287
+ runId: string;
288
+ sessionId: string;
289
+ seq: number;
290
+ /** Raw ACP `session/update` payload, passed through. */
291
+ acpUpdate: unknown;
292
+ }
293
+ /** shell.final — emitted once per runId on completion (success, abort, or harness error). */
294
+ export interface ShellFinalPayload {
295
+ shellId: string;
296
+ runId: string;
297
+ sessionId: string;
298
+ state: 'final' | 'aborted' | 'error';
299
+ stopReason?: string;
300
+ errorMessage?: string;
301
+ /** Total wall time in ms from invoke to final. */
302
+ durationMs: number;
303
+ /** Optional usage stats reported by the harness (token counts, etc.). */
304
+ usage?: unknown;
305
+ }
306
+ /** shell.backup_done — emitted when a backup (scheduled or manual) completes. */
307
+ export interface ShellBackupDonePayload {
308
+ shellId: string;
309
+ backupId: string;
310
+ bytes: number;
311
+ uploadMs: number;
312
+ trigger: 'scheduled' | 'manual' | 'pre_archive';
313
+ }
314
+ /** shells.quota_changed — emitted when any quota dimension crosses a threshold. */
315
+ export interface ShellsQuotaChangedPayload {
316
+ quota: ShellsQuota;
317
+ /** Dimensions that crossed their amber/red threshold in this update. */
318
+ alerted: Array<'shells' | 'diskGB' | 'memoryMB' | 'shelleyUSD' | 'egressGB'>;
319
+ }
320
+ export declare function isShellEvent(frame: {
321
+ type?: unknown;
322
+ event?: unknown;
323
+ }): frame is {
324
+ type: 'event';
325
+ event: string;
326
+ payload?: unknown;
327
+ };
328
+ export declare function isShellDelta(frame: {
329
+ type?: unknown;
330
+ event?: unknown;
331
+ payload?: unknown;
332
+ }): frame is {
333
+ type: 'event';
334
+ event: typeof SHELLS_EVENTS.delta;
335
+ payload: ShellDeltaPayload;
336
+ };
337
+ export declare function isShellFinal(frame: {
338
+ type?: unknown;
339
+ event?: unknown;
340
+ payload?: unknown;
341
+ }): frame is {
342
+ type: 'event';
343
+ event: typeof SHELLS_EVENTS.final;
344
+ payload: ShellFinalPayload;
345
+ };
346
+ //# sourceMappingURL=shells.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shells.d.ts","sourceRoot":"","sources":["../../src/gateway/shells.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;CAoBjB,CAAC;AAKX,eAAO,MAAM,aAAa;;;;;;;;CAQhB,CAAC;AAMX,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE9E,uBAAuB;AACvB,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,QAAQ,GACR,UAAU,GACV,OAAO,CAAC;AAEZ,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,SAAS,CAAC;AAEd,gGAAgG;AAChG,MAAM,MA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AE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5D,KAAK,IAAI;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,aAAa,CAAC,KAAK,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAE3F;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5D,KAAK,IAAI;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,aAAa,CAAC,KAAK,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAE3F"}
@@ -0,0 +1,65 @@
1
+ // Shells protocol — golden agents on exe.dev VMs.
2
+ //
3
+ // Spec: specs/2026-05-20-shells-golden-agents.md
4
+ //
5
+ // Wire shape follows the existing gateway frame protocol:
6
+ // - RPC : RequestFrame { type:'req', id, method:'shells.*', params } ⇄ ResponseFrame
7
+ // - Event: EventFrame { type:'event', event:'shell.*', payload }
8
+ //
9
+ // Two callers exist:
10
+ // 1. Hub / channel clients invoke the gateway as usual (shells.list, shells.provision,
11
+ // shells.invoke, shells.archive, …)
12
+ // 2. The in-VM `shells-bridge` process dials the gateway with a per-shell deviceToken,
13
+ // then calls shells.register to bind its WS connection to its shellId. Subsequent
14
+ // shells.invoke from other callers is forwarded by the gateway over this same
15
+ // connection.
16
+ // =============================================================================
17
+ // RPC method names — use these constants on both client and server.
18
+ // =============================================================================
19
+ export const SHELLS_METHODS = {
20
+ // Caller-side (hub / channel → gateway)
21
+ list: 'shells.list',
22
+ get: 'shells.get',
23
+ quota: 'shells.quota',
24
+ provision: 'shells.provision',
25
+ invoke: 'shells.invoke',
26
+ cancel: 'shells.cancel',
27
+ archive: 'shells.archive',
28
+ wake: 'shells.wake',
29
+ restart: 'shells.restart',
30
+ destroy: 'shells.destroy',
31
+ backupNow: 'shells.backup_now',
32
+ listBackups: 'shells.list_backups',
33
+ update: 'shells.update', // mutate name / archiveIdleMs / backupCadence / etc.
34
+ // Bridge-side (in-VM bridge → gateway)
35
+ register: 'shells.register',
36
+ heartbeat: 'shells.heartbeat',
37
+ fatal: 'shells.fatal',
38
+ };
39
+ // =============================================================================
40
+ // Event names emitted by the gateway.
41
+ // =============================================================================
42
+ export const SHELLS_EVENTS = {
43
+ online: 'shell.online',
44
+ archived: 'shell.archived',
45
+ errored: 'shell.error',
46
+ delta: 'shell.delta',
47
+ final: 'shell.final',
48
+ backupDone: 'shell.backup_done',
49
+ quotaChanged: 'shells.quota_changed',
50
+ };
51
+ // =============================================================================
52
+ // Type guards — convenience for hub stream handlers.
53
+ // =============================================================================
54
+ export function isShellEvent(frame) {
55
+ return (frame.type === 'event' &&
56
+ typeof frame.event === 'string' &&
57
+ (frame.event.startsWith('shell.') || frame.event.startsWith('shells.')));
58
+ }
59
+ export function isShellDelta(frame) {
60
+ return frame.type === 'event' && frame.event === SHELLS_EVENTS.delta;
61
+ }
62
+ export function isShellFinal(frame) {
63
+ return frame.type === 'event' && frame.event === SHELLS_EVENTS.final;
64
+ }
65
+ //# sourceMappingURL=shells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shells.js","sourceRoot":"","sources":["../../src/gateway/shells.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,0DAA0D;AAC1D,wFAAwF;AACxF,oEAAoE;AACpE,EAAE;AACF,qBAAqB;AACrB,yFAAyF;AACzF,yCAAyC;AACzC,yFAAyF;AACzF,uFAAuF;AACvF,mFAAmF;AACnF,mBAAmB;AAEnB,gFAAgF;AAChF,oEAAoE;AACpE,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,wCAAwC;IAC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7D,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC;AACvE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minion-stack/shared",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared gateway protocol types and utilities for the Minion platform.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,10 +46,10 @@
46
46
  ],
47
47
  "devDependencies": {
48
48
  "@types/ws": "^8.18.1",
49
- "oxlint": ">=0.15.0",
49
+ "oxlint": "^1.66.0",
50
50
  "typescript": "^5.7.0",
51
51
  "vitest": "^2.1.9",
52
- "ws": "^8.19.0",
52
+ "ws": "^8.21.0",
53
53
  "@minion-stack/tsconfig": "0.1.0"
54
54
  },
55
55
  "scripts": {