@ours.network/cli 0.1.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,267 @@
1
+ import type { OursClient } from '@ours.network/sdk/client';
2
+ type FieldKind = 'string' | 'boolean' | 'integer' | 'string[]' | 'integer[]' | 'cursor';
3
+ interface FieldSpec {
4
+ kind: FieldKind;
5
+ required?: boolean;
6
+ values?: readonly string[];
7
+ positive?: boolean;
8
+ }
9
+ export declare const OPERATION_SPECS: {
10
+ readonly 'create-identity': {
11
+ readonly method: "createIdentity";
12
+ readonly fields: {
13
+ readonly name: FieldSpec;
14
+ readonly bio: FieldSpec;
15
+ readonly exposeLocal: FieldSpec;
16
+ readonly localAutoAccept: FieldSpec;
17
+ };
18
+ };
19
+ readonly 'create-temporary-identity': {
20
+ readonly method: "createTemporaryIdentity";
21
+ readonly fields: {
22
+ readonly name: FieldSpec;
23
+ readonly bio: FieldSpec;
24
+ readonly exposeLocal: FieldSpec;
25
+ readonly localAutoAccept: FieldSpec;
26
+ };
27
+ };
28
+ readonly 'close-temporary-identity': {
29
+ readonly method: "closeTemporaryIdentityOp";
30
+ readonly fields: {
31
+ readonly name: FieldSpec;
32
+ };
33
+ };
34
+ readonly 'create-root-identity': {
35
+ readonly method: "createRootIdentity";
36
+ readonly fields: {
37
+ readonly name: FieldSpec;
38
+ readonly bio: FieldSpec;
39
+ readonly exposeLocal: FieldSpec;
40
+ readonly localAutoAccept: FieldSpec;
41
+ readonly skipIfRootExists: FieldSpec;
42
+ };
43
+ };
44
+ readonly 'define-local-identity-file': {
45
+ readonly method: "defineLocalIdentityFile";
46
+ readonly fields: {
47
+ readonly name: FieldSpec;
48
+ readonly path: FieldSpec;
49
+ readonly force: FieldSpec;
50
+ readonly exposeLocal: FieldSpec;
51
+ readonly localAutoAccept: FieldSpec;
52
+ readonly overwrite: FieldSpec;
53
+ };
54
+ };
55
+ readonly 'choose-identity': {
56
+ readonly method: "chooseIdentity";
57
+ readonly fields: {
58
+ readonly name: FieldSpec;
59
+ readonly force: FieldSpec;
60
+ };
61
+ };
62
+ readonly 'list-identities': {
63
+ readonly method: "listIdentities";
64
+ readonly fields: {};
65
+ };
66
+ readonly 'current-identity': {
67
+ readonly method: "currentIdentity";
68
+ readonly fields: {};
69
+ };
70
+ readonly 'remove-identity': {
71
+ readonly method: "removeIdentity";
72
+ readonly fields: {
73
+ readonly name: FieldSpec;
74
+ };
75
+ };
76
+ readonly 'release-lease': {
77
+ readonly method: "releaseLease";
78
+ readonly fields: {};
79
+ };
80
+ readonly 'generate-invite': {
81
+ readonly method: "generateInvite";
82
+ readonly fields: {
83
+ readonly name: FieldSpec;
84
+ readonly mode: FieldSpec;
85
+ };
86
+ };
87
+ readonly 'list-invites': {
88
+ readonly method: "listInvites";
89
+ readonly fields: {};
90
+ };
91
+ readonly 'revoke-invite': {
92
+ readonly method: "revokeInvite";
93
+ readonly fields: {
94
+ readonly invite_id: FieldSpec;
95
+ };
96
+ };
97
+ readonly 'add-contact': {
98
+ readonly method: "addContact";
99
+ readonly fields: {
100
+ readonly invite: FieldSpec;
101
+ readonly name: FieldSpec;
102
+ };
103
+ };
104
+ readonly 'list-contacts': {
105
+ readonly method: "listContacts";
106
+ readonly fields: {};
107
+ };
108
+ readonly 'list-local-contact-book': {
109
+ readonly method: "listLocalContactBook";
110
+ readonly fields: {};
111
+ };
112
+ readonly 'set-local-book-policy': {
113
+ readonly method: "setLocalBookPolicy";
114
+ readonly fields: {
115
+ readonly expose: FieldSpec;
116
+ readonly auto_accept: FieldSpec;
117
+ };
118
+ readonly refine: (a: Record<string, unknown>) => void;
119
+ };
120
+ readonly 'remove-contact': {
121
+ readonly method: "removeContact";
122
+ readonly fields: {
123
+ readonly contact: FieldSpec;
124
+ };
125
+ };
126
+ readonly 'rename-contact': {
127
+ readonly method: "renameContact";
128
+ readonly fields: {
129
+ readonly contact: FieldSpec;
130
+ readonly name: FieldSpec;
131
+ };
132
+ };
133
+ readonly 'respond-to-introduction': {
134
+ readonly method: "respondToIntroduction";
135
+ readonly fields: {
136
+ readonly contact: FieldSpec;
137
+ readonly action: FieldSpec;
138
+ };
139
+ };
140
+ readonly 'set-bio': {
141
+ readonly method: "setBio";
142
+ readonly fields: {
143
+ readonly bio: FieldSpec;
144
+ };
145
+ };
146
+ readonly 'set-persona': {
147
+ readonly method: "setPersona";
148
+ readonly fields: {
149
+ readonly persona: FieldSpec;
150
+ };
151
+ };
152
+ readonly 'send-message': {
153
+ readonly method: "sendMessage";
154
+ readonly fields: {
155
+ readonly contact: FieldSpec;
156
+ readonly text: FieldSpec;
157
+ readonly reply_to_wire_id: FieldSpec;
158
+ readonly reply_to_sentence: FieldSpec;
159
+ };
160
+ };
161
+ readonly 'send-file': {
162
+ readonly method: "sendFile";
163
+ readonly fields: {
164
+ readonly contact: FieldSpec;
165
+ readonly path: FieldSpec;
166
+ readonly data_base64: FieldSpec;
167
+ readonly filename: FieldSpec;
168
+ readonly mime: FieldSpec;
169
+ readonly reply_to_wire_id: FieldSpec;
170
+ readonly reply_to_sentence: FieldSpec;
171
+ };
172
+ readonly refine: (a: Record<string, unknown>) => void;
173
+ };
174
+ readonly 'list-incoming-messages': {
175
+ readonly method: "listIncomingMessages";
176
+ readonly fields: {};
177
+ };
178
+ readonly 'get-messages': {
179
+ readonly method: "getMessages";
180
+ readonly fields: {};
181
+ };
182
+ readonly 'defer-messages': {
183
+ readonly method: "deferMessages";
184
+ readonly fields: {
185
+ readonly msg_ids: FieldSpec;
186
+ };
187
+ };
188
+ readonly 'defer-files': {
189
+ readonly method: "deferFiles";
190
+ readonly fields: {
191
+ readonly file_ids: FieldSpec;
192
+ };
193
+ };
194
+ readonly 'get-conversation': {
195
+ readonly method: "getConversation";
196
+ readonly fields: {
197
+ readonly contact: FieldSpec;
198
+ };
199
+ };
200
+ readonly 'get-receipts': {
201
+ readonly method: "getReceipts";
202
+ readonly fields: {
203
+ readonly contact: FieldSpec;
204
+ };
205
+ };
206
+ readonly 'mark-read': {
207
+ readonly method: "markRead";
208
+ readonly fields: {
209
+ readonly contact: FieldSpec;
210
+ };
211
+ };
212
+ readonly 'set-conversation-policy': {
213
+ readonly method: "setConversationPolicy";
214
+ readonly fields: {
215
+ readonly keep_history: FieldSpec;
216
+ };
217
+ };
218
+ readonly 'list-incoming-files': {
219
+ readonly method: "listIncomingFiles";
220
+ readonly fields: {};
221
+ };
222
+ readonly 'get-files': {
223
+ readonly method: "getFiles";
224
+ readonly fields: {
225
+ readonly wire_ids: FieldSpec;
226
+ };
227
+ };
228
+ readonly version: {
229
+ readonly method: "version";
230
+ readonly fields: {};
231
+ };
232
+ readonly 'state-dir': {
233
+ readonly method: "stateDir";
234
+ readonly fields: {};
235
+ };
236
+ readonly identities: {
237
+ readonly method: "identities";
238
+ readonly fields: {};
239
+ };
240
+ readonly unread: {
241
+ readonly method: "unread";
242
+ readonly fields: {};
243
+ };
244
+ readonly 'watch-notifications': {
245
+ readonly method: "watchNotifications";
246
+ readonly fields: {
247
+ readonly identity: FieldSpec;
248
+ readonly since: {
249
+ readonly kind: "cursor";
250
+ };
251
+ };
252
+ };
253
+ readonly 'fetch-file': {
254
+ readonly method: "fetchFile";
255
+ readonly fields: {
256
+ readonly wire_id: FieldSpec;
257
+ };
258
+ };
259
+ };
260
+ export type OperationName = keyof typeof OPERATION_SPECS;
261
+ export declare const operationNames: () => OperationName[];
262
+ export declare const isOperationName: (value: string) => value is OperationName;
263
+ export declare function parseOperationJson(raw: string | undefined, operation: OperationName): Record<string, unknown>;
264
+ export declare function operationValueFlags(operation: OperationName): Set<string>;
265
+ export declare function operationInputFromFlags(operation: OperationName, values: Record<string, string>, defaults?: Record<string, unknown>): Record<string, unknown>;
266
+ export declare function invokeOperation(client: OursClient, operation: OperationName, input: Record<string, unknown>): Promise<unknown>;
267
+ export {};
@@ -0,0 +1,19 @@
1
+ import {
2
+ OPERATION_SPECS,
3
+ invokeOperation,
4
+ isOperationName,
5
+ operationInputFromFlags,
6
+ operationNames,
7
+ operationValueFlags,
8
+ parseOperationJson
9
+ } from "./chunk-IUZOQT4D.js";
10
+ import "./chunk-AXXFFER2.js";
11
+ export {
12
+ OPERATION_SPECS,
13
+ invokeOperation,
14
+ isOperationName,
15
+ operationInputFromFlags,
16
+ operationNames,
17
+ operationValueFlags,
18
+ parseOperationJson
19
+ };
@@ -0,0 +1,7 @@
1
+ export interface CliIo {
2
+ stdout(text: string): void;
3
+ stderr(text: string): void;
4
+ }
5
+ export declare const processIo: CliIo;
6
+ export declare function writeResult(io: CliIo, result: unknown, json: boolean, label?: string): void;
7
+ export declare function writeError(io: CliIo, error: unknown, json: boolean): void;
package/dist/output.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ processIo,
3
+ writeError,
4
+ writeResult
5
+ } from "./chunk-YC7QBGVC.js";
6
+ export {
7
+ processIo,
8
+ writeError,
9
+ writeResult
10
+ };
@@ -0,0 +1,26 @@
1
+ export declare const SERVICE_NAME = "ours.service";
2
+ export interface ServicePlan {
3
+ adapter: string;
4
+ action: 'install' | 'uninstall';
5
+ serviceFile: string;
6
+ commands: string[][];
7
+ changed: boolean;
8
+ dryRun: boolean;
9
+ }
10
+ export interface ServiceContext {
11
+ cliPath: string;
12
+ configPath?: string;
13
+ homeDir?: string;
14
+ dryRun?: boolean;
15
+ force?: boolean;
16
+ }
17
+ export interface ServiceDeps {
18
+ platform: NodeJS.Platform;
19
+ run(command: string, args: string[]): Promise<void>;
20
+ }
21
+ export interface ServiceAdapter {
22
+ readonly name: string;
23
+ install(context: ServiceContext): Promise<ServicePlan>;
24
+ uninstall(context: ServiceContext): Promise<ServicePlan>;
25
+ }
26
+ export declare function createLinuxUserSystemdAdapter(deps?: ServiceDeps): ServiceAdapter;
@@ -0,0 +1,8 @@
1
+ import {
2
+ SERVICE_NAME,
3
+ createLinuxUserSystemdAdapter
4
+ } from "./chunk-67BC2E5U.js";
5
+ export {
6
+ SERVICE_NAME,
7
+ createLinuxUserSystemdAdapter
8
+ };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@ours.network/cli",
3
+ "version": "0.1.0",
4
+ "description": "Transport-neutral operator CLI for the ours shared daemon",
5
+ "type": "module",
6
+ "license": "FSL-1.1-Apache-2.0",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "bin": {
11
+ "ours": "./dist/cli.js"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "LICENSE",
16
+ "README.md"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "node build.mjs",
23
+ "typecheck": "tsc -p tsconfig.json --noEmit"
24
+ },
25
+ "dependencies": {
26
+ "@ours.network/sdk": "^1.0.2"
27
+ }
28
+ }