@happyvertical/smrt-cli 0.53.3 → 0.53.5
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/AGENTS.md +3 -0
- package/README.md +64 -0
- package/agents/app-commands.md +118 -0
- package/bin/smrt-web.mjs +19 -0
- package/bin/smrt.js +18 -12
- package/dist/{ApiKey-BZmbOTnL-DchyhIPA.js → ApiKey-BZmbOTnL-BbZupUZ3.js} +2 -2
- package/dist/ApiKeyCollection-Bfb_nw81-DYAZwx0O.js +87 -0
- package/dist/AuditLogCollection-B1YonCAP-Bkj2Ezon.js +193 -0
- package/dist/{NostrIdentity-n70E0vck-CLGPdJ1W.js → NostrIdentity-n70E0vck-Di3_eNCq.js} +4 -4
- package/dist/NostrIdentityCollection-Ca74dkaL-DvjOg9Xy.js +127 -0
- package/dist/{OidcIdentity-Cb1bxreM-DPBTZddF.js → OidcIdentity-Cb1bxreM-LXmC7uAf.js} +2 -2
- package/dist/OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js +86 -0
- package/dist/ProfileAssetCollection-B9hacUJa-CPuaWLk4.js +101 -0
- package/dist/{ProfileCollection-DuJT7Mum-BUYQQ9xZ.js → ProfileCollection-DuJT7Mum-nXbHrPpX.js} +31 -31
- package/dist/ProfileLinkCollection-4uNURz32-CbKZYmYm.js +233 -0
- package/dist/ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js +108 -0
- package/dist/ProfileMetafieldCollection-CoBuM_5G-CPjW3l5r.js +145 -0
- package/dist/ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js +161 -0
- package/dist/ProfileRelationshipTermCollection-DtA9OM23-BoGhQBSQ.js +107 -0
- package/dist/{ProfileRelationshipType-BRiRka6t-xzRfZRFG.js → ProfileRelationshipType-BRiRka6t-Dezjv5jP.js} +1 -1
- package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js +57 -0
- package/dist/app/cli.d.ts +51 -0
- package/dist/app/cli.d.ts.map +1 -0
- package/dist/app/errors.d.ts +55 -0
- package/dist/app/errors.d.ts.map +1 -0
- package/dist/app/identity.d.ts +24 -0
- package/dist/app/identity.d.ts.map +1 -0
- package/dist/app/index.d.ts +20 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/launchers.d.ts +51 -0
- package/dist/app/launchers.d.ts.map +1 -0
- package/dist/app/operations.d.ts +30 -0
- package/dist/app/operations.d.ts.map +1 -0
- package/dist/app/portability-assets.d.ts +151 -0
- package/dist/app/portability-assets.d.ts.map +1 -0
- package/dist/app/portability.d.ts +117 -0
- package/dist/app/portability.d.ts.map +1 -0
- package/dist/app/process-record.d.ts +54 -0
- package/dist/app/process-record.d.ts.map +1 -0
- package/dist/app/runtime.d.ts +98 -0
- package/dist/app/runtime.d.ts.map +1 -0
- package/dist/app/tokens.d.ts +21 -0
- package/dist/app/tokens.d.ts.map +1 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +4 -0
- package/dist/cli-OZsH5cdL.js +1602 -0
- package/dist/cli-generator.d.ts.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/utilities.d.ts.map +1 -1
- package/dist/{commands-B8N38deG.js → commands-UXK2F_0j.js} +49 -336
- package/dist/database-environment-D_Gk1Brf.js +20 -0
- package/dist/database-environment.d.ts +43 -0
- package/dist/database-environment.d.ts.map +1 -0
- package/dist/dist-BVjJWjT-.js +20 -0
- package/dist/{dist-B62O-xH6.js → dist-C87Ib9Vx.js} +2 -2
- package/dist/{dist-CL9KGm1j.js → dist-DLw_E34G.js} +1654 -1748
- package/dist/{dist-BBQyIRsO.js → dist-GIaWaUho.js} +4 -4
- package/dist/{dist-C8BOgli4.js → dist-RSE5hCY4.js} +3 -3
- package/dist/index.js +19 -9
- package/dist/mcp-apps-packaging-CixRnxz_.js +286 -0
- package/dist/{oidcProvisioningPrimitives-D9OYu5-F-l8afZs4F.js → oidcProvisioningPrimitives-D9OYu5-F-T9KkkDCd.js} +5 -5
- package/dist/portability-CES1YC2m.js +859 -0
- package/dist/resolveIdentity-B-PK6RwU-C9ogf8YG.js +269 -0
- package/package.json +19 -14
- package/dist/ApiKeyCollection-Bfb_nw81-DR5XF_SZ.js +0 -2
- package/dist/AuditLogCollection-B1YonCAP-PbzALncL.js +0 -2
- package/dist/NostrIdentityCollection-Ca74dkaL-C2r-uDlC.js +0 -2
- package/dist/OidcIdentityCollection-TV8VdK69-2fZROnih.js +0 -2
- package/dist/ProfileAssetCollection-B9hacUJa-D33sifgF.js +0 -2
- package/dist/ProfileLinkCollection-4uNURz32-CHDTinax.js +0 -2
- package/dist/ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js +0 -2
- package/dist/ProfileMetafieldCollection-CoBuM_5G-BXtoIP02.js +0 -2
- package/dist/ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js +0 -2
- package/dist/ProfileRelationshipTermCollection-DtA9OM23-DPOMtMr7.js +0 -2
- package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js +0 -2
- package/dist/resolveIdentity-B-PK6RwU-B306Ch1I.js +0 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logical application export/import (schemaVersion 2 bundles).
|
|
3
|
+
*
|
|
4
|
+
* Ported unchanged from the template's `scripts/smrt-portability.mjs`: the
|
|
5
|
+
* bundle shape, non-portable table/column rules, parent-first import plan,
|
|
6
|
+
* empty-target rule, and asset staging/recovery are a persisted contract.
|
|
7
|
+
*/
|
|
8
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
9
|
+
import { type AssetBundle, type PortableRow, type PortableTable } from './portability-assets.js';
|
|
10
|
+
/** Column definition fields the import planner reads from the manifest. */
|
|
11
|
+
export interface PortableColumnDefinition {
|
|
12
|
+
primaryKey?: boolean;
|
|
13
|
+
notNull?: boolean;
|
|
14
|
+
foreignKey?: {
|
|
15
|
+
table?: string;
|
|
16
|
+
};
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Manifest-derived application table. */
|
|
20
|
+
export interface ManifestTable {
|
|
21
|
+
name: string;
|
|
22
|
+
columns: string[];
|
|
23
|
+
columnDefinitions: Record<string, PortableColumnDefinition>;
|
|
24
|
+
foreignKeys: Array<{
|
|
25
|
+
column: string;
|
|
26
|
+
referencesTable: string;
|
|
27
|
+
}>;
|
|
28
|
+
primaryKeys: string[];
|
|
29
|
+
}
|
|
30
|
+
/** Planned import step; `deferredColumns` are filled by a later UPDATE. */
|
|
31
|
+
export interface PlannedImportTable extends ManifestTable {
|
|
32
|
+
deferredColumns: Set<string>;
|
|
33
|
+
}
|
|
34
|
+
/** A schemaVersion-2 logical bundle. */
|
|
35
|
+
export interface LogicalExportBundle {
|
|
36
|
+
schemaVersion: 2;
|
|
37
|
+
application: string;
|
|
38
|
+
profile: string;
|
|
39
|
+
exportedAt: string;
|
|
40
|
+
tables: PortableTable[];
|
|
41
|
+
assets: AssetBundle;
|
|
42
|
+
}
|
|
43
|
+
/** Runtime selection the adapter needs. */
|
|
44
|
+
export interface PortabilityRuntime {
|
|
45
|
+
profile: string;
|
|
46
|
+
providers: {
|
|
47
|
+
database: {
|
|
48
|
+
engine: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Context for {@link exportApplication} / {@link importApplication}. */
|
|
53
|
+
export interface PortabilityContext {
|
|
54
|
+
appId: string;
|
|
55
|
+
sourceRoot: string;
|
|
56
|
+
stateRoot: string;
|
|
57
|
+
runtime: PortabilityRuntime;
|
|
58
|
+
env: Record<string, string | undefined>;
|
|
59
|
+
paths: {
|
|
60
|
+
root: string;
|
|
61
|
+
assets: string;
|
|
62
|
+
} | null;
|
|
63
|
+
assetRoot: string | null;
|
|
64
|
+
path?: string;
|
|
65
|
+
/** Test seam: observe import phases (`assets-staged`, …). */
|
|
66
|
+
onImportPhase?: (phase: string) => Promise<void> | void;
|
|
67
|
+
/** Test seam: replace the database opener. */
|
|
68
|
+
openDatabase?: (options: Record<string, unknown>) => Promise<DatabaseInterface>;
|
|
69
|
+
}
|
|
70
|
+
/** Read the application tables from `<sourceRoot>/.smrt/manifest.json`. */
|
|
71
|
+
export declare function manifestTables(sourceRoot: string): ManifestTable[];
|
|
72
|
+
/** Parent-first insertion plan with nullable cycle edges deferred to updates. */
|
|
73
|
+
export declare function planImportTables(tables: ManifestTable[]): PlannedImportTable[];
|
|
74
|
+
/** Reject bundles that do not exactly match the generated schema. */
|
|
75
|
+
export declare function validateImportBundle(bundle: {
|
|
76
|
+
tables: unknown[];
|
|
77
|
+
}, expected: Map<string, Pick<ManifestTable, 'name' | 'columns'>>): void;
|
|
78
|
+
/** JSON cannot represent SQLite's lossless BigInt results; decimal strings do. */
|
|
79
|
+
export declare function serializeExportBundle(bundle: unknown): string;
|
|
80
|
+
/** Result reported by `smrt app export`. */
|
|
81
|
+
export interface ExportResult {
|
|
82
|
+
path: string;
|
|
83
|
+
tableCount: number;
|
|
84
|
+
assetsIncluded: true;
|
|
85
|
+
assetCount: number;
|
|
86
|
+
}
|
|
87
|
+
/** Write a logical export bundle without replacing an existing file. */
|
|
88
|
+
export declare function exportApplication(context: PortabilityContext): Promise<ExportResult>;
|
|
89
|
+
/** Minimal query surface the import plan needs (a transaction handle). */
|
|
90
|
+
export interface ImportExecutor {
|
|
91
|
+
query(sql: string, ...params: unknown[]): Promise<{
|
|
92
|
+
rows: Array<Record<string, unknown>>;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
/** Execute a prevalidated parent-first import against one database transaction. */
|
|
96
|
+
export declare function executeImportPlan(tx: ImportExecutor, plan: PlannedImportTable[], exportedByName: Map<string, {
|
|
97
|
+
rows: PortableRow[];
|
|
98
|
+
}>): Promise<number>;
|
|
99
|
+
/**
|
|
100
|
+
* True when every planned table holds exactly the bundle's rows (as a
|
|
101
|
+
* multiset over the bundle's columns). This is the evidence an interrupted
|
|
102
|
+
* import's recovery needs when no commit marker was recorded: matching
|
|
103
|
+
* per-table counts alone do not prove the rows are this bundle's.
|
|
104
|
+
*/
|
|
105
|
+
export declare function importedRowsMatchBundle(db: ImportExecutor, plan: PlannedImportTable[], exportedByName: Map<string, {
|
|
106
|
+
rows: PortableRow[];
|
|
107
|
+
}>): Promise<boolean>;
|
|
108
|
+
/** Result reported by `smrt app import`. */
|
|
109
|
+
export interface ImportResult {
|
|
110
|
+
path: string;
|
|
111
|
+
rowCount: number;
|
|
112
|
+
assetsIncluded: true;
|
|
113
|
+
assetCount: number;
|
|
114
|
+
}
|
|
115
|
+
/** Import a logical bundle into an empty application database. */
|
|
116
|
+
export declare function importApplication(context: PortabilityContext): Promise<ImportResult>;
|
|
117
|
+
//# sourceMappingURL=portability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portability.d.ts","sourceRoot":"","sources":["../../src/app/portability.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EACL,KAAK,WAAW,EAOhB,KAAK,WAAW,EAChB,KAAK,aAAa,EAQnB,MAAM,yBAAyB,CAAC;AAQjC,2EAA2E;AAC3E,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAC5D,WAAW,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;K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sB,uBAAuB,CAC3C,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,kBAAkB,EAAE,EAC1B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,GACnD,OAAO,CAAC,OAAO,CAAC,CAelB;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,kEAAkE;AAClE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAmJvB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed web-process record (`<state>/app.pid`).
|
|
3
|
+
*
|
|
4
|
+
* Ported from the template's `scripts/smrt-process.mjs`. A recorded pid is
|
|
5
|
+
* only trusted when the live process's command line proves it is the web
|
|
6
|
+
* launcher with this record's instance nonce, so a recycled pid is never
|
|
7
|
+
* signalled.
|
|
8
|
+
*/
|
|
9
|
+
/** Persisted web-process identity. */
|
|
10
|
+
export interface ApplicationProcessRecord {
|
|
11
|
+
pid: number;
|
|
12
|
+
instance: string;
|
|
13
|
+
}
|
|
14
|
+
/** File name of the web launcher; part of the process-identity proof. */
|
|
15
|
+
export declare const WEB_LAUNCHER_NAME = "smrt-web.mjs";
|
|
16
|
+
/** Write the private (mode 0600) process record. */
|
|
17
|
+
export declare function writeProcessRecord(path: string, record: ApplicationProcessRecord): void;
|
|
18
|
+
/**
|
|
19
|
+
* Send SIGTERM. Returns `false` when the process had already exited; any
|
|
20
|
+
* other failure (e.g. EPERM) is rethrown.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sendTerminationSignal(pid: number, killProcess?: (pid: number, signal: NodeJS.Signals) => unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* True when `command` is exactly the web launcher started with this record's
|
|
25
|
+
* nonce: the final argument is `--smrt-instance=<instance>` and the argument
|
|
26
|
+
* before it is a path whose basename is `smrt-web.mjs` (the CLI's
|
|
27
|
+
* `bin/smrt-web.mjs`, or the template's `scripts/smrt-web.mjs`). Substring
|
|
28
|
+
* matches such as `evil-smrt-web.mjs` or a nonce with a suffix are rejected.
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchesApplicationProcess(record: Pick<ApplicationProcessRecord, 'instance'>, command: unknown): boolean;
|
|
31
|
+
/** Result of re-checking a recorded web process. */
|
|
32
|
+
export type OwnedProcessState =
|
|
33
|
+
/** Live and provably the recorded launcher. */
|
|
34
|
+
'owned'
|
|
35
|
+
/** The pid no longer exists. */
|
|
36
|
+
| 'gone'
|
|
37
|
+
/** The pid is live but runs something else (recycled pid). */
|
|
38
|
+
| 'mismatched'
|
|
39
|
+
/** The pid is live but its command line could not be read. */
|
|
40
|
+
| 'unverifiable';
|
|
41
|
+
/**
|
|
42
|
+
* Re-check `record` against the live process table. Only `gone` and
|
|
43
|
+
* `mismatched` justify dropping the record; `unverifiable` (the process
|
|
44
|
+
* query failed or returned nothing) must keep it and must not signal.
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkOwnedProcess(record: ApplicationProcessRecord): OwnedProcessState;
|
|
47
|
+
/** True only when {@link checkOwnedProcess} proves the record still owned. */
|
|
48
|
+
export declare function verifyOwnedProcess(record: ApplicationProcessRecord): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Return the recorded web process when it is live and provably ours;
|
|
51
|
+
* otherwise remove the stale record and return `null`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readOwnedProcess(path: string): ApplicationProcessRecord | null;
|
|
54
|
+
//# sourceMappingURL=process-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-record.d.ts","sourceRoot":"","sources":["../../src/app/process-record.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,sCAAsC;AACtC,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAsBhD,oDAAoD;AACpD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,wBAAwB,GAC/B,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,WAAW,GAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,OAAsB,GAC3E,OAAO,CAQT;AAWD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAClD,OAAO,EAAE,OAAO,GACf,OAAO,CAST;AAED,oDAAoD;AACpD,MAAM,MAAM,iBAAiB;AAC3B,+CAA+C;AAC7C,OAAO;AACT,gCAAgC;GAC9B,MAAM;AACR,8DAA8D;GAC5D,YAAY;AACd,8DAA8D;GAC5D,cAAc,CAAC;AAYnB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,wBAAwB,GAC/B,iBAAiB,CAOnB;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAE5E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,GACX,wBAAwB,GAAG,IAAI,CAoCjC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared per-invocation context for the `smrt app` command group: source
|
|
3
|
+
* root, application identity, I/O, child-process runners, and the
|
|
4
|
+
* profile-aware runtime environment.
|
|
5
|
+
*/
|
|
6
|
+
import { type SpawnSyncReturns } from 'node:child_process';
|
|
7
|
+
import type * as AppRuntime from '@happyvertical/smrt-app-runtime';
|
|
8
|
+
import type { ResolvedApplicationRuntime } from '@happyvertical/smrt-config';
|
|
9
|
+
/** Output sinks. Each call receives complete text including the newline. */
|
|
10
|
+
export interface AppCommandIo {
|
|
11
|
+
stdout(text: string): void;
|
|
12
|
+
stderr(text: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Operator-only sink for secret material (the one-time onboarding URL).
|
|
15
|
+
* Present only when it reaches an interactive terminal; never a log, pipe,
|
|
16
|
+
* or file. Absent means the secret is not printed.
|
|
17
|
+
*/
|
|
18
|
+
operatorTerminal?(text: string): void;
|
|
19
|
+
}
|
|
20
|
+
/** Options for a child command run. */
|
|
21
|
+
export interface RunOptions {
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
/** Capture stdout/stderr instead of inheriting the terminal. */
|
|
24
|
+
capture?: boolean;
|
|
25
|
+
/** Return a failed result instead of throwing. */
|
|
26
|
+
allowFailure?: boolean;
|
|
27
|
+
/** Secret-free name used in the failure message. */
|
|
28
|
+
label?: string;
|
|
29
|
+
shell?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Child-process runner signature. */
|
|
32
|
+
export type CommandRunner = (args: string[], options?: RunOptions) => SpawnSyncReturns<string>;
|
|
33
|
+
/** Replaceable collaborators. Production values are filled in by default. */
|
|
34
|
+
export interface AppCommandDependencies {
|
|
35
|
+
/** `@happyvertical/smrt-app-runtime` entry points. */
|
|
36
|
+
runtime: Pick<typeof AppRuntime, 'initializeLocalApplicationRuntime' | 'initializeDeployedApplicationRuntime' | 'prepareLocalDatabaseStorage' | 'resolveLocalRuntimePaths' | 'validateLocalDatabaseStorage'> & Partial<Pick<typeof AppRuntime, 'openLocalMcpTokenStore'>>;
|
|
37
|
+
/** Resolve the configured runtime after (re)loading `smrt.config`. */
|
|
38
|
+
resolveRuntime(sourceRoot: string): Promise<ResolvedApplicationRuntime>;
|
|
39
|
+
/** Run the application's package manager (`pnpm <args>`). */
|
|
40
|
+
runPackageManager: CommandRunner;
|
|
41
|
+
/** Run this CLI (`smrt <args>`) as a child process. */
|
|
42
|
+
runSmrt: CommandRunner;
|
|
43
|
+
/** Open a URL in the operator's browser. */
|
|
44
|
+
openBrowser(url: string): void;
|
|
45
|
+
/** Health probe transport for `start`. */
|
|
46
|
+
fetch: typeof fetch;
|
|
47
|
+
/** Delay between readiness polls. */
|
|
48
|
+
sleep(milliseconds: number): Promise<void>;
|
|
49
|
+
/** Signal a process (`start` cleanup). */
|
|
50
|
+
signal(pid: number, signal: NodeJS.Signals): void;
|
|
51
|
+
}
|
|
52
|
+
/** Per-invocation context. */
|
|
53
|
+
export interface AppContext {
|
|
54
|
+
readonly sourceRoot: string;
|
|
55
|
+
readonly appId: string;
|
|
56
|
+
readonly io: AppCommandIo;
|
|
57
|
+
readonly deps: AppCommandDependencies;
|
|
58
|
+
}
|
|
59
|
+
/** Locate this package's root (`…/smrt-cli`) from the running module. */
|
|
60
|
+
export declare function cliPackageRoot(): string;
|
|
61
|
+
/** Absolute path of the `smrt` executable shipped with this package. */
|
|
62
|
+
export declare function cliExecutablePath(): string;
|
|
63
|
+
/** Absolute path of the web launcher `start` spawns. */
|
|
64
|
+
export declare function webLauncherPath(): string;
|
|
65
|
+
/** Load `<sourceRoot>/.env` without overriding the shell; a missing file is fine. */
|
|
66
|
+
export declare function loadSourceEnvironment(sourceRoot: string): void;
|
|
67
|
+
/** Default package-manager runner: honours a pnpm `npm_execpath`. */
|
|
68
|
+
export declare function createPackageManagerRunner(sourceRoot: string): CommandRunner;
|
|
69
|
+
/** Default self-runner: this package's own `smrt` executable. */
|
|
70
|
+
export declare function createSmrtRunner(sourceRoot: string): CommandRunner;
|
|
71
|
+
/** Default browser opener (`SMRT_OPEN_STUB` writes the URL to a file instead). */
|
|
72
|
+
export declare function createBrowserOpener(sourceRoot: string): (url: string) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Default runtime resolver: reload `smrt.config` without the cache.
|
|
75
|
+
*
|
|
76
|
+
* Profile selection is `resolveEffectiveApplicationRuntime()` from
|
|
77
|
+
* smrt-config — the rule the web process applies in app-runtime's SvelteKit
|
|
78
|
+
* entry — so the operator and the server it manages never disagree: no
|
|
79
|
+
* `runtime` block (or no config file) is the `local` profile, and a present
|
|
80
|
+
* value that is not a valid block (`null`, `false`, `0`, `''`, ...) fails
|
|
81
|
+
* closed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveConfiguredRuntime(sourceRoot: string): Promise<ResolvedApplicationRuntime>;
|
|
84
|
+
/** Build the default dependency set for `sourceRoot`. */
|
|
85
|
+
export declare function defaultDependencies(sourceRoot: string): Promise<AppCommandDependencies>;
|
|
86
|
+
/** Resolve the application id from `<sourceRoot>/package.json` and `SMRT_APP_ID`. */
|
|
87
|
+
export declare function resolveContextApplicationId(sourceRoot: string): string;
|
|
88
|
+
/** Create or verify the private state root for this invocation. */
|
|
89
|
+
export declare function preparedStateRoot(context: AppContext): string;
|
|
90
|
+
/** Profile-aware child environment, with local storage paths when local. */
|
|
91
|
+
export interface RuntimeEnvironment {
|
|
92
|
+
env: NodeJS.ProcessEnv;
|
|
93
|
+
paths: AppRuntime.LocalRuntimePaths | null;
|
|
94
|
+
assetRoot: string | null;
|
|
95
|
+
}
|
|
96
|
+
/** Compute the environment a web/migration child of this app runs with. */
|
|
97
|
+
export declare function runtimeEnvironment(context: AppContext, runtime: ResolvedApplicationRuntime): RuntimeEnvironment;
|
|
98
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/app/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAKtE,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAQ7E,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3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;AAED,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,KAAK,EAAE,UAAU,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,0BAA0B,GAClC,kBAAkB,CA4CpB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `smrt app token` — owner-minted bearer tokens for local MCP clients.
|
|
3
|
+
*
|
|
4
|
+
* ```
|
|
5
|
+
* smrt app token --scopes notes.read [--expires 30d] [--label "Claude Desktop"]
|
|
6
|
+
* smrt app token list
|
|
7
|
+
* smrt app token revoke <id>
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Local profile only. The token is printed once, in the `issued` JSON
|
|
11
|
+
* document on stdout, and is otherwise never written anywhere: the runtime
|
|
12
|
+
* stores only its HMAC. `list` and `revoke` output carries no token values.
|
|
13
|
+
*/
|
|
14
|
+
import { type AppContext } from './runtime.js';
|
|
15
|
+
/** Usage text for `smrt app token`. */
|
|
16
|
+
export declare const TOKEN_USAGE = "Usage: smrt app token [create] --scopes <scope[,scope...]> [--expires <n>s|m|h|d] [--label <text>] | token list | token revoke <id>";
|
|
17
|
+
/** Parse `30d`, `12h`, `90m`, `3600s` or bare seconds. */
|
|
18
|
+
export declare function parseTokenLifetime(value: string): number;
|
|
19
|
+
/** Run `smrt app token <args…>` and resolve to the exit code. */
|
|
20
|
+
export declare function runTokenOperation(context: AppContext, args: string[]): Promise<number>;
|
|
21
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/app/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,cAAc,CAAC;AAElE,uCAAuC;AACvC,eAAO,MAAM,WAAW,wIAC+G,CAAC;AAexI,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMxD;AAyCD,iEAAiE;AACjE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAqFjB"}
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './app/index.js';
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { A as assertExternalArtifactPath, C as prepareMigration, D as cliExecutablePath, E as validateMcpAppsIfPresent, F as AppCommandError, I as ApplicationStartError, M as resolveApplicationId, N as resolveApplicationStateRoot, O as runtimeEnvironment, P as runtimeConfigurationFingerprint, R as redactSecrets, S as launchVite, T as runWorker, _ as sendTerminationSignal, a as renderAppHelp, b as ViteLauncherError, c as parseTokenLifetime, d as START_OUTPUT_TAIL_BYTES, f as runApplicationOperation, g as readOwnedProcess, h as matchesApplicationProcess, i as errorEnvelope, j as prepareApplicationStateRoot, k as webLauncherPath, l as runTokenOperation, m as checkOwnedProcess, n as APP_RECOVERY, o as runAppCommand, p as WEB_LAUNCHER_NAME, s as TOKEN_USAGE, t as APP_COMMANDS, u as APP_OPERATIONS, v as verifyOwnedProcess, w as resolveViteEntry, x as devServerArguments, y as writeProcessRecord } from "./cli-OZsH5cdL.js";
|
|
2
|
+
import { C as publishFilesystemAssets, D as stageFilesystemAssets, E as rollbackFilesystemAssets, O as verifyFilesystemAssets, S as markFilesystemAssetsCommitted, T as recoverFilesystemAssets, _ as bundleContentDigest, a as manifestTables, b as finishFilesystemAssets, c as serializeExportBundle, d as AssetPortabilityError, f as MAX_ASSET_BYTES, g as assertAssetRoot, h as MAX_TOTAL_ASSET_BYTES, i as importedRowsMatchBundle, k as verifyPublishedFilesystemAssets, l as validateImportBundle, m as MAX_BUNDLE_BYTES, n as exportApplication, o as planImportTables, p as MAX_ASSET_COUNT, r as importApplication, t as executeImportPlan, u as ASSET_MANIFEST_SCHEMA_VERSION, v as collectFilesystemAssets, w as readSensitiveBundle, x as hasCommittedImportJournal, y as digestBytes } from "./portability-CES1YC2m.js";
|
|
3
|
+
import { PROVIDER_READINESS_SETTINGS, RECLAIM_MUTEX_FILE, acquireWriterLease, createProviderReadinessProbe, findInstalledPackage, isStaleOperationLock, lockOwnerPid, processExists, readActiveWriterLease, reclaimStaleRecord, resolveReadinessModule, withOperationLock } from "@happyvertical/smrt-app-runtime";
|
|
4
|
+
export { APP_COMMANDS, APP_OPERATIONS, APP_RECOVERY, ASSET_MANIFEST_SCHEMA_VERSION, AppCommandError, ApplicationStartError, AssetPortabilityError, MAX_ASSET_BYTES, MAX_ASSET_COUNT, MAX_BUNDLE_BYTES, MAX_TOTAL_ASSET_BYTES, PROVIDER_READINESS_SETTINGS, RECLAIM_MUTEX_FILE, START_OUTPUT_TAIL_BYTES, TOKEN_USAGE, ViteLauncherError, WEB_LAUNCHER_NAME, acquireWriterLease, assertAssetRoot, assertExternalArtifactPath, bundleContentDigest, checkOwnedProcess, cliExecutablePath, collectFilesystemAssets, createProviderReadinessProbe, devServerArguments, digestBytes, errorEnvelope, executeImportPlan, exportApplication, findInstalledPackage, finishFilesystemAssets, hasCommittedImportJournal, importApplication, importedRowsMatchBundle, isStaleOperationLock, launchVite, lockOwnerPid, manifestTables, markFilesystemAssetsCommitted, matchesApplicationProcess, parseTokenLifetime, planImportTables, prepareApplicationStateRoot, prepareMigration, processExists, publishFilesystemAssets, readActiveWriterLease, readOwnedProcess, readSensitiveBundle, reclaimStaleRecord, recoverFilesystemAssets, redactSecrets, renderAppHelp, resolveApplicationId, resolveApplicationStateRoot, resolveReadinessModule, resolveViteEntry, rollbackFilesystemAssets, runAppCommand, runApplicationOperation, runTokenOperation, runWorker, runtimeConfigurationFingerprint, runtimeEnvironment, sendTerminationSignal, serializeExportBundle, stageFilesystemAssets, validateImportBundle, validateMcpAppsIfPresent, verifyFilesystemAssets, verifyOwnedProcess, verifyPublishedFilesystemAssets, webLauncherPath, withOperationLock, writeProcessRecord };
|