diff --git a/pkg/npm/api/hood/index.ts b/pkg/npm/api/hood/index.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/hood/index.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/hood/lib.ts b/pkg/npm/api/hood/lib.ts new file mode 100644 index 000000000..1d63ad673 --- /dev/null +++ b/pkg/npm/api/hood/lib.ts @@ -0,0 +1,38 @@ +import { Poke, Scry } from '../lib'; + +export const getVats: Scry = { + app: 'hood', + path: '/kiln/vats' +}; + +/** + * Install a foreign desk + */ +export function kilnInstall( + ship: string, + desk: string, + local?: string +): Poke { + return { + app: 'hood', + mark: 'kiln-install', + json: { + ship, + desk, + local: local || desk + } + }; +} + +/** + * Uninstall a desk + */ +export function kilnUninstall( + desk: string +): Poke { + return { + app: 'hood', + mark: 'kiln-uninstall', + json: desk + }; +} diff --git a/pkg/npm/api/hood/types.ts b/pkg/npm/api/hood/types.ts new file mode 100644 index 000000000..8fe659ef4 --- /dev/null +++ b/pkg/npm/api/hood/types.ts @@ -0,0 +1,154 @@ + +/** + * A pending commit, awaiting a future kelvin version + */ +interface Woof { + aeon: number; + weft: Weft; +} + +interface Rein { + /** + * Agents not in manifest that should be running + */ + add: string[]; + /** + * Agents in manifest that should not be running + */ + sub: string[]; +} + +/** + * A tracker of a foreign {@link Vat} + * + */ +export interface Arak { + /** + * Ship of foreign vat + */ + ship: string; + /** + * Desk of foreign vat + */ + desk: string; + /** + * Aeon (version number) that we currently have synced + */ + aeon: number; + next: Woof[]; + rein: Rein; +} + +/** + * A component's kelvin version + */ +export interface Weft { + /** + * Name of the component + * + * @remarks + * Usually %zuse, %hoon, or %lull + */ + name: string; + /** + * Kelvin version + * + */ + kelvin: number; +} + +export interface KilnDiffBlock { + block: { + desk: string; + arak: Arak; + weft: Weft; + blockers: string[]; + }; +} + +export interface KilnDiffReset { + reset: { + desk: string; + arak: Arak; + }; +} + +export interface KilnDiffMerge { + merge: { + desk: string; + arak: Arak; + }; +} + +export interface KilnDiffMergeSunk { + 'merge-sunk': { + desk: string; + arak: Arak; + tang: string; + }; +} + +export interface KilnDiffMergeFail { + 'merge-fail': { + desk: string; + arak: Arak; + tang: string; + }; +} + +export type KilnDiff = + | KilnDiffBlock + | KilnDiffReset + | KilnDiffMerge + | KilnDiffMergeSunk + | KilnDiffMergeFail; + +/** + * Cases for revision + * + */ +interface Cass { + /** + * Revision number + */ + ud: number; + /** + * Timestamp of revision, as unix timestamp + * + * @remarks + * If \@da is outside valid positive unix timestamp, value will be zero + */ + da: string; +} + +/** + * A local desk installation + */ +export interface Vat { + /** + * Desk that this Vat describes + */ + desk: string; + /** + * Hash of the desk, rendered as `@uv` + * + * @remarks + * Equivalent to + * ```hoon + * .^(@uv %cz /=desk=) + * ``` + */ + hash: string; + /** + * Current revision + */ + cass: Cass; + /** + * Foreign sync + */ + arak: Arak; +} + +export interface Vats { + [desk: string]: Vat; +} diff --git a/pkg/npm/api/index.ts b/pkg/npm/api/index.ts index 7d108981e..85a10df8c 100644 --- a/pkg/npm/api/index.ts +++ b/pkg/npm/api/index.ts @@ -15,4 +15,6 @@ export * as settings from './settings'; export * from './s3'; export * as s3 from './s3'; export * from './lib'; -export * from './lib/BigIntOrderedMap'; \ No newline at end of file +export * from './lib/BigIntOrderedMap'; +export * as hood from './hood'; +export * from './hood';