@fnndsc/brasa 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.
- package/dist/builtins/debug.d.ts +8 -0
- package/dist/builtins/debug.js +39 -0
- package/dist/builtins/debug.js.map +1 -0
- package/dist/builtins/executable.d.ts +22 -0
- package/dist/builtins/executable.js +115 -0
- package/dist/builtins/executable.js.map +1 -0
- package/dist/builtins/fs/cat.d.ts +16 -0
- package/dist/builtins/fs/cat.js +266 -0
- package/dist/builtins/fs/cat.js.map +1 -0
- package/dist/builtins/fs/cd.d.ts +42 -0
- package/dist/builtins/fs/cd.js +193 -0
- package/dist/builtins/fs/cd.js.map +1 -0
- package/dist/builtins/fs/cp.d.ts +10 -0
- package/dist/builtins/fs/cp.js +86 -0
- package/dist/builtins/fs/cp.js.map +1 -0
- package/dist/builtins/fs/download.d.ts +6 -0
- package/dist/builtins/fs/download.js +45 -0
- package/dist/builtins/fs/download.js.map +1 -0
- package/dist/builtins/fs/du.d.ts +58 -0
- package/dist/builtins/fs/du.js +210 -0
- package/dist/builtins/fs/du.js.map +1 -0
- package/dist/builtins/fs/edit.d.ts +7 -0
- package/dist/builtins/fs/edit.js +104 -0
- package/dist/builtins/fs/edit.js.map +1 -0
- package/dist/builtins/fs/ls.d.ts +8 -0
- package/dist/builtins/fs/ls.js +68 -0
- package/dist/builtins/fs/ls.js.map +1 -0
- package/dist/builtins/fs/mkdir.d.ts +9 -0
- package/dist/builtins/fs/mkdir.js +52 -0
- package/dist/builtins/fs/mkdir.js.map +1 -0
- package/dist/builtins/fs/mv.d.ts +10 -0
- package/dist/builtins/fs/mv.js +88 -0
- package/dist/builtins/fs/mv.js.map +1 -0
- package/dist/builtins/fs/pull.args.d.ts +22 -0
- package/dist/builtins/fs/pull.args.js +30 -0
- package/dist/builtins/fs/pull.args.js.map +1 -0
- package/dist/builtins/fs/pull.d.ts +26 -0
- package/dist/builtins/fs/pull.js +445 -0
- package/dist/builtins/fs/pull.js.map +1 -0
- package/dist/builtins/fs/pwd.d.ts +10 -0
- package/dist/builtins/fs/pwd.js +73 -0
- package/dist/builtins/fs/pwd.js.map +1 -0
- package/dist/builtins/fs/rm.d.ts +37 -0
- package/dist/builtins/fs/rm.js +197 -0
- package/dist/builtins/fs/rm.js.map +1 -0
- package/dist/builtins/fs/touch.d.ts +9 -0
- package/dist/builtins/fs/touch.js +76 -0
- package/dist/builtins/fs/touch.js.map +1 -0
- package/dist/builtins/fs/tree.d.ts +15 -0
- package/dist/builtins/fs/tree.js +84 -0
- package/dist/builtins/fs/tree.js.map +1 -0
- package/dist/builtins/fs/upload.d.ts +6 -0
- package/dist/builtins/fs/upload.js +48 -0
- package/dist/builtins/fs/upload.js.map +1 -0
- package/dist/builtins/help.d.ts +74 -0
- package/dist/builtins/help.js +1217 -0
- package/dist/builtins/help.js.map +1 -0
- package/dist/builtins/index.d.ts +45 -0
- package/dist/builtins/index.js +45 -0
- package/dist/builtins/index.js.map +1 -0
- package/dist/builtins/net/connect.d.ts +7 -0
- package/dist/builtins/net/connect.js +42 -0
- package/dist/builtins/net/connect.js.map +1 -0
- package/dist/builtins/net/cubepath.d.ts +18 -0
- package/dist/builtins/net/cubepath.js +102 -0
- package/dist/builtins/net/cubepath.js.map +1 -0
- package/dist/builtins/net/logout.d.ts +6 -0
- package/dist/builtins/net/logout.js +24 -0
- package/dist/builtins/net/logout.js.map +1 -0
- package/dist/builtins/net/pacs.d.ts +24 -0
- package/dist/builtins/net/pacs.js +121 -0
- package/dist/builtins/net/pacs.js.map +1 -0
- package/dist/builtins/net/pacsUtils.d.ts +85 -0
- package/dist/builtins/net/pacsUtils.js +184 -0
- package/dist/builtins/net/pacsUtils.js.map +1 -0
- package/dist/builtins/net/query.d.ts +60 -0
- package/dist/builtins/net/query.js +324 -0
- package/dist/builtins/net/query.js.map +1 -0
- package/dist/builtins/parametersofplugin.d.ts +13 -0
- package/dist/builtins/parametersofplugin.js +43 -0
- package/dist/builtins/parametersofplugin.js.map +1 -0
- package/dist/builtins/pluginExecute.d.ts +27 -0
- package/dist/builtins/pluginExecute.js +165 -0
- package/dist/builtins/pluginExecute.js.map +1 -0
- package/dist/builtins/proc.d.ts +6 -0
- package/dist/builtins/proc.helpers.d.ts +68 -0
- package/dist/builtins/proc.helpers.js +102 -0
- package/dist/builtins/proc.helpers.js.map +1 -0
- package/dist/builtins/proc.js +289 -0
- package/dist/builtins/proc.js.map +1 -0
- package/dist/builtins/res/compute.d.ts +6 -0
- package/dist/builtins/res/compute.js +55 -0
- package/dist/builtins/res/compute.js.map +1 -0
- package/dist/builtins/res/feed.d.ts +6 -0
- package/dist/builtins/res/feed.js +244 -0
- package/dist/builtins/res/feed.js.map +1 -0
- package/dist/builtins/res/feed.notes.d.ts +28 -0
- package/dist/builtins/res/feed.notes.js +24 -0
- package/dist/builtins/res/feed.notes.js.map +1 -0
- package/dist/builtins/res/files.d.ts +18 -0
- package/dist/builtins/res/files.js +85 -0
- package/dist/builtins/res/files.js.map +1 -0
- package/dist/builtins/res/group.d.ts +6 -0
- package/dist/builtins/res/group.js +54 -0
- package/dist/builtins/res/group.js.map +1 -0
- package/dist/builtins/res/pipeline.args.d.ts +22 -0
- package/dist/builtins/res/pipeline.args.js +28 -0
- package/dist/builtins/res/pipeline.args.js.map +1 -0
- package/dist/builtins/res/pipeline.d.ts +20 -0
- package/dist/builtins/res/pipeline.js +252 -0
- package/dist/builtins/res/pipeline.js.map +1 -0
- package/dist/builtins/res/plugin.d.ts +13 -0
- package/dist/builtins/res/plugin.js +140 -0
- package/dist/builtins/res/plugin.js.map +1 -0
- package/dist/builtins/res/plugininstance.d.ts +6 -0
- package/dist/builtins/res/plugininstance.js +53 -0
- package/dist/builtins/res/plugininstance.js.map +1 -0
- package/dist/builtins/res/pluginmeta.d.ts +6 -0
- package/dist/builtins/res/pluginmeta.js +53 -0
- package/dist/builtins/res/pluginmeta.js.map +1 -0
- package/dist/builtins/res/tag.d.ts +6 -0
- package/dist/builtins/res/tag.js +53 -0
- package/dist/builtins/res/tag.js.map +1 -0
- package/dist/builtins/res/workflow.d.ts +6 -0
- package/dist/builtins/res/workflow.js +53 -0
- package/dist/builtins/res/workflow.js.map +1 -0
- package/dist/builtins/store.d.ts +6 -0
- package/dist/builtins/store.js +107 -0
- package/dist/builtins/store.js.map +1 -0
- package/dist/builtins/sys/context.d.ts +6 -0
- package/dist/builtins/sys/context.js +50 -0
- package/dist/builtins/sys/context.js.map +1 -0
- package/dist/builtins/sys/physicalmode.d.ts +8 -0
- package/dist/builtins/sys/physicalmode.js +34 -0
- package/dist/builtins/sys/physicalmode.js.map +1 -0
- package/dist/builtins/sys/timing.d.ts +8 -0
- package/dist/builtins/sys/timing.js +34 -0
- package/dist/builtins/sys/timing.js.map +1 -0
- package/dist/builtins/sys/version.d.ts +15 -0
- package/dist/builtins/sys/version.js +23 -0
- package/dist/builtins/sys/version.js.map +1 -0
- package/dist/builtins/sys/whoami.d.ts +17 -0
- package/dist/builtins/sys/whoami.js +44 -0
- package/dist/builtins/sys/whoami.js.map +1 -0
- package/dist/builtins/utils.d.ts +55 -0
- package/dist/builtins/utils.js +145 -0
- package/dist/builtins/utils.js.map +1 -0
- package/dist/builtins/wildcard.d.ts +26 -0
- package/dist/builtins/wildcard.js +120 -0
- package/dist/builtins/wildcard.js.map +1 -0
- package/dist/command-keys.d.ts +8 -0
- package/dist/command-keys.js +32 -0
- package/dist/command-keys.js.map +1 -0
- package/dist/config/storeConfig.d.ts +57 -0
- package/dist/config/storeConfig.js +78 -0
- package/dist/config/storeConfig.js.map +1 -0
- package/dist/core/chiliDelegate.d.ts +21 -0
- package/dist/core/chiliDelegate.js +32 -0
- package/dist/core/chiliDelegate.js.map +1 -0
- package/dist/core/connect.d.ts +38 -0
- package/dist/core/connect.js +46 -0
- package/dist/core/connect.js.map +1 -0
- package/dist/core/dispatch.d.ts +95 -0
- package/dist/core/dispatch.js +618 -0
- package/dist/core/dispatch.js.map +1 -0
- package/dist/core/engine.d.ts +91 -0
- package/dist/core/engine.js +222 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/preprocess.d.ts +46 -0
- package/dist/core/preprocess.js +146 -0
- package/dist/core/preprocess.js.map +1 -0
- package/dist/core/progress.d.ts +50 -0
- package/dist/core/progress.js +21 -0
- package/dist/core/progress.js.map +1 -0
- package/dist/core/promptContext.d.ts +49 -0
- package/dist/core/promptContext.js +39 -0
- package/dist/core/promptContext.js.map +1 -0
- package/dist/core/question.d.ts +27 -0
- package/dist/core/question.js +33 -0
- package/dist/core/question.js.map +1 -0
- package/dist/core/sink.d.ts +207 -0
- package/dist/core/sink.js +329 -0
- package/dist/core/sink.js.map +1 -0
- package/dist/core/surface.d.ts +172 -0
- package/dist/core/surface.js +105 -0
- package/dist/core/surface.js.map +1 -0
- package/dist/core/version.d.ts +20 -0
- package/dist/core/version.js +82 -0
- package/dist/core/version.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/completer/index.d.ts +15 -0
- package/dist/lib/completer/index.js +212 -0
- package/dist/lib/completer/index.js.map +1 -0
- package/dist/lib/completer/pathComplete.helpers.d.ts +22 -0
- package/dist/lib/completer/pathComplete.helpers.js +49 -0
- package/dist/lib/completer/pathComplete.helpers.js.map +1 -0
- package/dist/lib/parser.d.ts +13 -0
- package/dist/lib/parser.js +52 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/pipe.d.ts +11 -0
- package/dist/lib/pipe.js +90 -0
- package/dist/lib/pipe.js.map +1 -0
- package/dist/lib/prefetch.d.ts +25 -0
- package/dist/lib/prefetch.js +64 -0
- package/dist/lib/prefetch.js.map +1 -0
- package/dist/lib/semicolonParser.d.ts +22 -0
- package/dist/lib/semicolonParser.js +53 -0
- package/dist/lib/semicolonParser.js.map +1 -0
- package/dist/lib/spinner.d.ts +23 -0
- package/dist/lib/spinner.js +71 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/vfs/providers/static.d.ts +65 -0
- package/dist/lib/vfs/providers/static.js +164 -0
- package/dist/lib/vfs/providers/static.js.map +1 -0
- package/dist/lib/vfs/providers/static_content.d.ts +27 -0
- package/dist/lib/vfs/providers/static_content.js +180 -0
- package/dist/lib/vfs/providers/static_content.js.map +1 -0
- package/dist/lib/vfs/vfs.d.ts +59 -0
- package/dist/lib/vfs/vfs.js +202 -0
- package/dist/lib/vfs/vfs.js.map +1 -0
- package/dist/session/index.d.ts +76 -0
- package/dist/session/index.js +120 -0
- package/dist/session/index.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Engine store configuration: which ChRIS peer store the engine targets.
|
|
3
|
+
*
|
|
4
|
+
* This is engine state, not a surface preference: the `store` builtin reads and
|
|
5
|
+
* mutates it. The value lives here, but where it is persisted is the host's
|
|
6
|
+
* concern — a CLI writes it to a settings file, a daemon may hold it per
|
|
7
|
+
* session, a headless host keeps it in memory. The host installs a persistence
|
|
8
|
+
* callback via {@link storeConfigPersist_install}; with none installed the
|
|
9
|
+
* value simply lives for the process, so the engine carries no file or path
|
|
10
|
+
* knowledge of its own.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** Built-in peer store used when the operator has set no override. */
|
|
15
|
+
export declare const DEFAULT_STORE_URL: string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the peer store URL in effect, falling back to the built-in default.
|
|
18
|
+
*
|
|
19
|
+
* @returns The store URL to use.
|
|
20
|
+
*/
|
|
21
|
+
export declare function storeUrl_get(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Reports whether the effective store URL is the built-in default.
|
|
24
|
+
*
|
|
25
|
+
* @returns True when no override is set.
|
|
26
|
+
*/
|
|
27
|
+
export declare function storeUrl_isDefault(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the operator's override without applying the default.
|
|
30
|
+
*
|
|
31
|
+
* The persistence layer uses this so it writes only an explicit override.
|
|
32
|
+
*
|
|
33
|
+
* @returns The override URL, or undefined when none is set.
|
|
34
|
+
*/
|
|
35
|
+
export declare function storeUrlOverride_get(): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the peer store override.
|
|
38
|
+
*
|
|
39
|
+
* @param url - The store URL to use.
|
|
40
|
+
*/
|
|
41
|
+
export declare function storeUrl_set(url: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Clears the peer store override, restoring the built-in default.
|
|
44
|
+
*/
|
|
45
|
+
export declare function storeUrl_clear(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Installs the host's persistence hook.
|
|
48
|
+
*
|
|
49
|
+
* @param fn - Callback invoked to persist the current store configuration.
|
|
50
|
+
*/
|
|
51
|
+
export declare function storeConfigPersist_install(fn: () => Promise<void>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Persists the current store configuration through the installed hook.
|
|
54
|
+
*
|
|
55
|
+
* @returns A promise resolving once persistence completes.
|
|
56
|
+
*/
|
|
57
|
+
export declare function storeConfig_persist(): Promise<void>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Engine store configuration: which ChRIS peer store the engine targets.
|
|
3
|
+
*
|
|
4
|
+
* This is engine state, not a surface preference: the `store` builtin reads and
|
|
5
|
+
* mutates it. The value lives here, but where it is persisted is the host's
|
|
6
|
+
* concern — a CLI writes it to a settings file, a daemon may hold it per
|
|
7
|
+
* session, a headless host keeps it in memory. The host installs a persistence
|
|
8
|
+
* callback via {@link storeConfigPersist_install}; with none installed the
|
|
9
|
+
* value simply lives for the process, so the engine carries no file or path
|
|
10
|
+
* knowledge of its own.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** Built-in peer store used when the operator has set no override. */
|
|
15
|
+
export const DEFAULT_STORE_URL = 'https://cube.chrisproject.org/api/v1/';
|
|
16
|
+
/** The operator's override, or undefined to use {@link DEFAULT_STORE_URL}. */
|
|
17
|
+
let storeUrl;
|
|
18
|
+
/** Host-installed persistence hook; the default keeps the value in memory. */
|
|
19
|
+
let persist = async () => {
|
|
20
|
+
// Headless default: the override lives for the process and is not persisted.
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Returns the peer store URL in effect, falling back to the built-in default.
|
|
24
|
+
*
|
|
25
|
+
* @returns The store URL to use.
|
|
26
|
+
*/
|
|
27
|
+
export function storeUrl_get() {
|
|
28
|
+
return storeUrl ?? DEFAULT_STORE_URL;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reports whether the effective store URL is the built-in default.
|
|
32
|
+
*
|
|
33
|
+
* @returns True when no override is set.
|
|
34
|
+
*/
|
|
35
|
+
export function storeUrl_isDefault() {
|
|
36
|
+
return storeUrl === undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the operator's override without applying the default.
|
|
40
|
+
*
|
|
41
|
+
* The persistence layer uses this so it writes only an explicit override.
|
|
42
|
+
*
|
|
43
|
+
* @returns The override URL, or undefined when none is set.
|
|
44
|
+
*/
|
|
45
|
+
export function storeUrlOverride_get() {
|
|
46
|
+
return storeUrl;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the peer store override.
|
|
50
|
+
*
|
|
51
|
+
* @param url - The store URL to use.
|
|
52
|
+
*/
|
|
53
|
+
export function storeUrl_set(url) {
|
|
54
|
+
storeUrl = url;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clears the peer store override, restoring the built-in default.
|
|
58
|
+
*/
|
|
59
|
+
export function storeUrl_clear() {
|
|
60
|
+
storeUrl = undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Installs the host's persistence hook.
|
|
64
|
+
*
|
|
65
|
+
* @param fn - Callback invoked to persist the current store configuration.
|
|
66
|
+
*/
|
|
67
|
+
export function storeConfigPersist_install(fn) {
|
|
68
|
+
persist = fn;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Persists the current store configuration through the installed hook.
|
|
72
|
+
*
|
|
73
|
+
* @returns A promise resolving once persistence completes.
|
|
74
|
+
*/
|
|
75
|
+
export async function storeConfig_persist() {
|
|
76
|
+
await persist();
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=storeConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storeConfig.js","sourceRoot":"","sources":["../../src/config/storeConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAW,uCAAuC,CAAC;AAEjF,8EAA8E;AAC9E,IAAI,QAA4B,CAAC;AAEjC,8EAA8E;AAC9E,IAAI,OAAO,GAAwB,KAAK,IAAmB,EAAE;IAC3D,6EAA6E;AAC/E,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,QAAQ,IAAI,iBAAiB,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,QAAQ,KAAK,SAAS,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,QAAQ,GAAG,GAAG,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAuB;IAChE,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,MAAM,OAAO,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Delegation to the chili command layer.
|
|
3
|
+
*
|
|
4
|
+
* Unknown commands and several resource builtins hand off to chili. This lives
|
|
5
|
+
* in its own leaf module so both the dispatcher and those builtins can call it
|
|
6
|
+
* without importing each other — dispatch imports the builtins, so routing the
|
|
7
|
+
* delegation through dispatch would close a cycle.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Runs a chili command in-process.
|
|
13
|
+
*
|
|
14
|
+
* chili shares this process's cumin connection and context, so there is no node
|
|
15
|
+
* subprocess to spawn and no per-command startup cost.
|
|
16
|
+
*
|
|
17
|
+
* @param command - The command to run (e.g., "feeds").
|
|
18
|
+
* @param args - The arguments to pass to the command.
|
|
19
|
+
* @returns A promise resolving when the command completes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function chiliCommand_run(command: string, args: string[]): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Delegation to the chili command layer.
|
|
3
|
+
*
|
|
4
|
+
* Unknown commands and several resource builtins hand off to chili. This lives
|
|
5
|
+
* in its own leaf module so both the dispatcher and those builtins can call it
|
|
6
|
+
* without importing each other — dispatch imports the builtins, so routing the
|
|
7
|
+
* delegation through dispatch would close a cycle.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { run as chiliRun } from '@fnndsc/chili/run.js';
|
|
13
|
+
/**
|
|
14
|
+
* Runs a chili command in-process.
|
|
15
|
+
*
|
|
16
|
+
* chili shares this process's cumin connection and context, so there is no node
|
|
17
|
+
* subprocess to spawn and no per-command startup cost.
|
|
18
|
+
*
|
|
19
|
+
* @param command - The command to run (e.g., "feeds").
|
|
20
|
+
* @param args - The arguments to pass to the command.
|
|
21
|
+
* @returns A promise resolving when the command completes.
|
|
22
|
+
*/
|
|
23
|
+
export async function chiliCommand_run(command, args) {
|
|
24
|
+
try {
|
|
25
|
+
await chiliRun([command, ...args]);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
29
|
+
console.error(chalk.red(`chili command '${command}' failed: ${message}`));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=chiliDelegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chiliDelegate.js","sourceRoot":"","sources":["../../src/core/chiliDelegate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAe,EAAE,IAAc;IACpE,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAW,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,OAAO,aAAa,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Headless session connect: restore a ChRIS connection from saved creds.
|
|
3
|
+
*
|
|
4
|
+
* This is the non-interactive half of establishing a session — load the saved
|
|
5
|
+
* context and validate its token against the server. It carries no terminal
|
|
6
|
+
* output of its own: it returns a status a frontend narrates (the CLI prints
|
|
7
|
+
* progress; a daemon logs or exits). Interactive login (prompting for a URL and
|
|
8
|
+
* password) is a frontend concern and lives with the CLI, not here.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { SingleContext } from '@fnndsc/cumin';
|
|
13
|
+
/**
|
|
14
|
+
* The outcome of a saved-session restore.
|
|
15
|
+
*
|
|
16
|
+
* - `restored` — a saved token validated against the server.
|
|
17
|
+
* - `no-context` — no saved user/URL to restore.
|
|
18
|
+
* - `no-token` — a saved context but no token; connect again to obtain one.
|
|
19
|
+
* - `no-client` — a token, but a client could not be created.
|
|
20
|
+
* - `invalid-token` — a token that the server rejected (expired/invalid).
|
|
21
|
+
*/
|
|
22
|
+
export type SavedSessionStatus = 'restored' | 'no-context' | 'no-token' | 'no-client' | 'invalid-token';
|
|
23
|
+
/** The result of {@link sessionConnect_fromSaved}. */
|
|
24
|
+
export interface SavedSessionResult {
|
|
25
|
+
status: SavedSessionStatus;
|
|
26
|
+
context: SingleContext;
|
|
27
|
+
/** The server error message when the status is `invalid-token`. */
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Restores a session from saved credentials, without any prompting.
|
|
32
|
+
*
|
|
33
|
+
* On any failure the session is put into offline mode. The caller narrates the
|
|
34
|
+
* outcome; a daemon treats anything but `restored` as "not connected".
|
|
35
|
+
*
|
|
36
|
+
* @returns The restore outcome and the resolved context.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sessionConnect_fromSaved(): Promise<SavedSessionResult>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Headless session connect: restore a ChRIS connection from saved creds.
|
|
3
|
+
*
|
|
4
|
+
* This is the non-interactive half of establishing a session — load the saved
|
|
5
|
+
* context and validate its token against the server. It carries no terminal
|
|
6
|
+
* output of its own: it returns a status a frontend narrates (the CLI prints
|
|
7
|
+
* progress; a daemon logs or exits). Interactive login (prompting for a URL and
|
|
8
|
+
* password) is a frontend concern and lives with the CLI, not here.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { session } from '../session/index.js';
|
|
13
|
+
import { context_getSingle } from '@fnndsc/salsa';
|
|
14
|
+
/**
|
|
15
|
+
* Restores a session from saved credentials, without any prompting.
|
|
16
|
+
*
|
|
17
|
+
* On any failure the session is put into offline mode. The caller narrates the
|
|
18
|
+
* outcome; a daemon treats anything but `restored` as "not connected".
|
|
19
|
+
*
|
|
20
|
+
* @returns The restore outcome and the resolved context.
|
|
21
|
+
*/
|
|
22
|
+
export async function sessionConnect_fromSaved() {
|
|
23
|
+
const context = await context_getSingle();
|
|
24
|
+
if (!context.user || !context.URL) {
|
|
25
|
+
return { status: 'no-context', context };
|
|
26
|
+
}
|
|
27
|
+
const token = await session.connection.authToken_get(true);
|
|
28
|
+
if (!token) {
|
|
29
|
+
session.offline = true;
|
|
30
|
+
return { status: 'no-token', context };
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const client = await session.connection.client_get();
|
|
34
|
+
if (!client) {
|
|
35
|
+
session.offline = true;
|
|
36
|
+
return { status: 'no-client', context };
|
|
37
|
+
}
|
|
38
|
+
await client.getUser();
|
|
39
|
+
return { status: 'restored', context };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
session.offline = true;
|
|
43
|
+
return { status: 'invalid-token', context, error: error instanceof Error ? error.message : String(error) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/core/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAsBlD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,MAAM,OAAO,GAAkB,MAAM,iBAAiB,EAAE,CAAC;IAEzD,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM,KAAK,GAAkB,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1E,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAkB,MAAM,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QACpE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;YACvB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QAC1C,CAAC;QACD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { CommandEnvelope } from '@fnndsc/cumin';
|
|
2
|
+
import { type RedirectInfo } from './preprocess.js';
|
|
3
|
+
import { chiliCommand_run } from './chiliDelegate.js';
|
|
4
|
+
export { chiliCommand_run };
|
|
5
|
+
/**
|
|
6
|
+
* Executes a shell command on the host system (shell escape with ! prefix).
|
|
7
|
+
*
|
|
8
|
+
* @param shellCommand - The command to execute on the host shell.
|
|
9
|
+
* @returns A Promise resolving to the command's exit code (1 on spawn failure).
|
|
10
|
+
*/
|
|
11
|
+
export declare function shellCommand_execute(shellCommand: string): Promise<number>;
|
|
12
|
+
type CommandHandler = (args: string[]) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Shape of a converted builtin: returns its outcome as an envelope instead
|
|
15
|
+
* of printing. The engine layer will consume these directly; the dispatch
|
|
16
|
+
* table below consumes them through {@link envelopeHandler_wrap}.
|
|
17
|
+
*/
|
|
18
|
+
type EnvelopeHandler = (args: string[]) => Promise<CommandEnvelope>;
|
|
19
|
+
export declare const ENVELOPE_HANDLERS: Record<string, EnvelopeHandler>;
|
|
20
|
+
export declare const COMMAND_HANDLERS: Record<string, CommandHandler>;
|
|
21
|
+
export { COMMAND_HANDLERS_KEYS } from '../command-keys.js';
|
|
22
|
+
/**
|
|
23
|
+
* Prints elapsed time since startTime if timing is enabled.
|
|
24
|
+
*
|
|
25
|
+
* @param startTime - Timestamp from `performance.now()` at command start.
|
|
26
|
+
* @param enabled - Whether timing display is active.
|
|
27
|
+
*/
|
|
28
|
+
export declare function command_timingMaybePrint(startTime: number, enabled: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Expands `$NAME` and `${NAME}` environment references in one token.
|
|
31
|
+
*
|
|
32
|
+
* Applied per token after parsing, so an expanded value can never inject
|
|
33
|
+
* command separators, pipes or redirects (the structural characters were
|
|
34
|
+
* already consumed). References to unset variables are left verbatim —
|
|
35
|
+
* kinder than the shell's silent empty string when a script forgets an
|
|
36
|
+
* export. Shell-escape lines (`!...`) never reach this point; bash does
|
|
37
|
+
* its own expansion there.
|
|
38
|
+
*
|
|
39
|
+
* @param token - A single parsed command token.
|
|
40
|
+
* @returns The token with set environment references substituted.
|
|
41
|
+
*/
|
|
42
|
+
export declare function envRefs_expand(token: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Dispatches a parsed command to its handler and returns its envelope, with
|
|
45
|
+
* any errors the command left on the stack drained into the envelope.
|
|
46
|
+
*
|
|
47
|
+
* @param command - The command name.
|
|
48
|
+
* @param args - Parsed arguments.
|
|
49
|
+
* @returns The envelope of the executed command.
|
|
50
|
+
*/
|
|
51
|
+
export declare function command_dispatchEnvelope(command: string, args: string[]): Promise<CommandEnvelope>;
|
|
52
|
+
/**
|
|
53
|
+
* Dispatches a parsed command to its handler.
|
|
54
|
+
*
|
|
55
|
+
* Compatibility shape over {@link command_dispatchEnvelope} for callers that
|
|
56
|
+
* do not consume envelopes.
|
|
57
|
+
*
|
|
58
|
+
* @param command - The command name.
|
|
59
|
+
* @param args - Parsed arguments.
|
|
60
|
+
* @returns A Promise that resolves once the command has been dispatched.
|
|
61
|
+
*/
|
|
62
|
+
export declare function command_dispatch(command: string, args: string[]): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Executes a redirected command (`>` / `>>`): captures the command's output
|
|
65
|
+
* and writes it to the target file.
|
|
66
|
+
*
|
|
67
|
+
* @param redirectInfo - The parsed redirection (command, operator, target).
|
|
68
|
+
* @returns An envelope recording the outcome; rendered text stays empty
|
|
69
|
+
* because the output went to the file, not the terminal.
|
|
70
|
+
*/
|
|
71
|
+
export declare function redirect_execute(redirectInfo: RedirectInfo): Promise<CommandEnvelope>;
|
|
72
|
+
/**
|
|
73
|
+
* Executes a pipe chain by running the first command in chell and piping
|
|
74
|
+
* through local tools, delivering the final output on the data channel.
|
|
75
|
+
*
|
|
76
|
+
* @param segments - Array of command segments separated by pipes.
|
|
77
|
+
* @returns An envelope whose rendered text is the chain's final output.
|
|
78
|
+
*/
|
|
79
|
+
export declare function pipe_execute(segments: string[]): Promise<CommandEnvelope>;
|
|
80
|
+
/**
|
|
81
|
+
* Executes one plain command line (no shell escape, batch, redirect or pipe)
|
|
82
|
+
* and returns its envelope.
|
|
83
|
+
*
|
|
84
|
+
* Mirrors the historical direct-execution order exactly: help flag
|
|
85
|
+
* short-circuit, wildcard expansion, simulated plugin execution, then table
|
|
86
|
+
* dispatch. Timing is printed at the same points the shell always printed
|
|
87
|
+
* it (after plugin execution or dispatch; never after help or a wildcard
|
|
88
|
+
* failure).
|
|
89
|
+
*
|
|
90
|
+
* @param trimmedLine - The trimmed command line.
|
|
91
|
+
* @param startTime - Timing reference from `performance.now()`.
|
|
92
|
+
* @param timingEnabled - Whether to print elapsed time after execution.
|
|
93
|
+
* @returns The command's envelope, or null when the line held no tokens.
|
|
94
|
+
*/
|
|
95
|
+
export declare function command_executeToEnvelope(trimmedLine: string, startTime: number, timingEnabled: boolean): Promise<CommandEnvelope | null>;
|