@agent-deck/shared 1.8.2 → 1.9.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/utils/agent-deck-home.d.ts +15 -0
- package/dist/utils/agent-deck-home.d.ts.map +1 -1
- package/dist/utils/agent-deck-home.js +70 -4
- package/dist/utils/agent-deck-home.js.map +1 -1
- package/package.json +1 -1
- package/dist/schemas/repo-deck.d.ts +0 -15
- package/dist/schemas/repo-deck.d.ts.map +0 -1
- package/dist/schemas/repo-deck.js +0 -11
- package/dist/schemas/repo-deck.js.map +0 -1
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
/** Dev monorepo / tsx — separate data dir from production `agent-deck start`. */
|
|
2
2
|
export declare function isAgentDeckDevMode(): boolean;
|
|
3
|
+
/** The user's real store root. Both this and its `dev/` subdir are real user data. */
|
|
4
|
+
export declare function realAgentDeckHome(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Exported for tests: is `target` the store root at `root`, or inside it?
|
|
7
|
+
*
|
|
8
|
+
* Compares lexically first, then again through `realpathSync`, because this store root
|
|
9
|
+
* is routinely a symlink into a git-synced tree (and so are its children). A
|
|
10
|
+
* lexical-only check lets `AGENT_DECK_HOME=<realpath of ~/.agent-deck>`, or a link
|
|
11
|
+
* pointing back at it, write to the real store while looking isolated.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isUnderStoreRoot(target: string, root: string): boolean;
|
|
3
14
|
/**
|
|
4
15
|
* Agent Deck data root: SQLite, credential yaml metadata, dev secret files.
|
|
5
16
|
* Production CLI → ~/.agent-deck
|
|
6
17
|
* Monorepo dev (AGENT_DECK_DEV=1) → ~/.agent-deck/dev
|
|
18
|
+
*
|
|
19
|
+
* Under a test runner this throws rather than hand back the real store, so a test
|
|
20
|
+
* that forgets to isolate `AGENT_DECK_HOME` fails loudly instead of writing stray
|
|
21
|
+
* decks and services into the developer's (often git-synced) store.
|
|
7
22
|
*/
|
|
8
23
|
export declare function resolveAgentDeckHome(): string;
|
|
9
24
|
//# sourceMappingURL=agent-deck-home.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-deck-home.d.ts","sourceRoot":"","sources":["../../src/utils/agent-deck-home.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-deck-home.d.ts","sourceRoot":"","sources":["../../src/utils/agent-deck-home.ts"],"names":[],"mappings":"AAUA,iFAAiF;AACjF,wBAAgB,kBAAkB,IAAI,OAAO,CAS5C;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAwBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKtE;AAeD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAkB7C"}
|
|
@@ -4,9 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isAgentDeckDevMode = isAgentDeckDevMode;
|
|
7
|
+
exports.realAgentDeckHome = realAgentDeckHome;
|
|
8
|
+
exports.isUnderStoreRoot = isUnderStoreRoot;
|
|
7
9
|
exports.resolveAgentDeckHome = resolveAgentDeckHome;
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
11
|
const node_os_1 = __importDefault(require("node:os"));
|
|
9
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
/**
|
|
14
|
+
* Escape hatch for the test guard below. Only for tests that assert default path
|
|
15
|
+
* resolution and never write — never for tests that touch the store.
|
|
16
|
+
*/
|
|
17
|
+
const ALLOW_REAL_HOME_IN_TESTS_ENV = 'AGENT_DECK_ALLOW_REAL_HOME_IN_TESTS';
|
|
10
18
|
/** Dev monorepo / tsx — separate data dir from production `agent-deck start`. */
|
|
11
19
|
function isAgentDeckDevMode() {
|
|
12
20
|
const flag = process.env.AGENT_DECK_DEV?.trim().toLowerCase();
|
|
@@ -18,16 +26,74 @@ function isAgentDeckDevMode() {
|
|
|
18
26
|
}
|
|
19
27
|
return process.env.NODE_ENV === 'development';
|
|
20
28
|
}
|
|
29
|
+
/** The user's real store root. Both this and its `dev/` subdir are real user data. */
|
|
30
|
+
function realAgentDeckHome() {
|
|
31
|
+
return node_path_1.default.join(node_os_1.default.homedir(), '.agent-deck');
|
|
32
|
+
}
|
|
33
|
+
/** Vitest sets VITEST=true and NODE_ENV=test; either marks a test process. */
|
|
34
|
+
function isTestRunnerProcess() {
|
|
35
|
+
const vitest = process.env.VITEST?.trim().toLowerCase();
|
|
36
|
+
return vitest === '1' || vitest === 'true' || process.env.NODE_ENV === 'test';
|
|
37
|
+
}
|
|
38
|
+
function containsOrEquals(root, target) {
|
|
39
|
+
return target === root || target.startsWith(`${root}${node_path_1.default.sep}`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `realpathSync` throws on a path that does not exist yet; the literal path is then
|
|
43
|
+
* all there is to compare, and the lexical pass has already used it.
|
|
44
|
+
*/
|
|
45
|
+
function realpathOrSelf(target) {
|
|
46
|
+
try {
|
|
47
|
+
return node_fs_1.default.realpathSync(target);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Exported for tests: is `target` the store root at `root`, or inside it?
|
|
55
|
+
*
|
|
56
|
+
* Compares lexically first, then again through `realpathSync`, because this store root
|
|
57
|
+
* is routinely a symlink into a git-synced tree (and so are its children). A
|
|
58
|
+
* lexical-only check lets `AGENT_DECK_HOME=<realpath of ~/.agent-deck>`, or a link
|
|
59
|
+
* pointing back at it, write to the real store while looking isolated.
|
|
60
|
+
*/
|
|
61
|
+
function isUnderStoreRoot(target, root) {
|
|
62
|
+
if (containsOrEquals(root, target)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return containsOrEquals(realpathOrSelf(root), realpathOrSelf(target));
|
|
66
|
+
}
|
|
67
|
+
function isRealAgentDeckHome(target) {
|
|
68
|
+
return isUnderStoreRoot(target, realAgentDeckHome());
|
|
69
|
+
}
|
|
70
|
+
function agentDeckHomeFromEnv() {
|
|
71
|
+
if (process.env.AGENT_DECK_HOME?.trim()) {
|
|
72
|
+
return node_path_1.default.resolve(process.env.AGENT_DECK_HOME.trim());
|
|
73
|
+
}
|
|
74
|
+
const base = realAgentDeckHome();
|
|
75
|
+
return isAgentDeckDevMode() ? node_path_1.default.join(base, 'dev') : base;
|
|
76
|
+
}
|
|
21
77
|
/**
|
|
22
78
|
* Agent Deck data root: SQLite, credential yaml metadata, dev secret files.
|
|
23
79
|
* Production CLI → ~/.agent-deck
|
|
24
80
|
* Monorepo dev (AGENT_DECK_DEV=1) → ~/.agent-deck/dev
|
|
81
|
+
*
|
|
82
|
+
* Under a test runner this throws rather than hand back the real store, so a test
|
|
83
|
+
* that forgets to isolate `AGENT_DECK_HOME` fails loudly instead of writing stray
|
|
84
|
+
* decks and services into the developer's (often git-synced) store.
|
|
25
85
|
*/
|
|
26
86
|
function resolveAgentDeckHome() {
|
|
27
|
-
|
|
28
|
-
|
|
87
|
+
const home = agentDeckHomeFromEnv();
|
|
88
|
+
// Test-runner check first: production never pays for the realpath syscalls.
|
|
89
|
+
if (isTestRunnerProcess() &&
|
|
90
|
+
process.env[ALLOW_REAL_HOME_IN_TESTS_ENV]?.trim() !== '1' &&
|
|
91
|
+
isRealAgentDeckHome(home)) {
|
|
92
|
+
throw new Error(`Refusing to use the real Agent Deck store (${home}) from a test process. ` +
|
|
93
|
+
'Set AGENT_DECK_HOME to a temp dir for this test — each package vitest config ' +
|
|
94
|
+
'already points the whole run at one. If the test only asserts default path ' +
|
|
95
|
+
`resolution and writes nothing, set ${ALLOW_REAL_HOME_IN_TESTS_ENV}=1.`);
|
|
29
96
|
}
|
|
30
|
-
|
|
31
|
-
return isAgentDeckDevMode() ? node_path_1.default.join(base, 'dev') : base;
|
|
97
|
+
return home;
|
|
32
98
|
}
|
|
33
99
|
//# sourceMappingURL=agent-deck-home.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-deck-home.js","sourceRoot":"","sources":["../../src/utils/agent-deck-home.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"agent-deck-home.js","sourceRoot":"","sources":["../../src/utils/agent-deck-home.ts"],"names":[],"mappings":";;;;;AAWA,gDASC;AAGD,8CAEC;AAgCD,4CAKC;AAwBD,oDAkBC;AAxGD,sDAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAE7B;;;GAGG;AACH,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AAE3E,iFAAiF;AACjF,SAAgB,kBAAkB;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9D,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAChD,CAAC;AAED,sFAAsF;AACtF,SAAgB,iBAAiB;IAC/B,OAAO,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC;AAED,8EAA8E;AAC9E,SAAS,mBAAmB;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxD,OAAO,MAAM,KAAK,GAAG,IAAI,MAA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BAAoB;IAClC,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAC;IAEpC,4EAA4E;IAC5E,IACE,mBAAmB,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG;QACzD,mBAAmB,CAAC,IAAI,CAAC,EACzB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,8CAA8C,IAAI,yBAAyB;YACzE,+EAA+E;YAC/E,6EAA6E;YAC7E,sCAAsC,4BAA4B,KAAK,CAC1E,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/** Minimal repo manifest at `.agent-deck/deck.yaml` — links a workspace to a dashboard deck. */
|
|
3
|
-
export declare const RepoDeckManifestSchema: z.ZodObject<{
|
|
4
|
-
deck_id: z.ZodString;
|
|
5
|
-
name: z.ZodOptional<z.ZodString>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
deck_id: string;
|
|
8
|
-
name?: string | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
deck_id: string;
|
|
11
|
-
name?: string | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
export type RepoDeckManifest = z.infer<typeof RepoDeckManifestSchema>;
|
|
14
|
-
export declare const REPO_DECK_MANIFEST_PATH = ".agent-deck/deck.yaml";
|
|
15
|
-
//# sourceMappingURL=repo-deck.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-deck.d.ts","sourceRoot":"","sources":["../../src/schemas/repo-deck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gGAAgG;AAChG,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,uBAAuB,0BAA0B,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REPO_DECK_MANIFEST_PATH = exports.RepoDeckManifestSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
/** Minimal repo manifest at `.agent-deck/deck.yaml` — links a workspace to a dashboard deck. */
|
|
6
|
-
exports.RepoDeckManifestSchema = zod_1.z.object({
|
|
7
|
-
deck_id: zod_1.z.string().uuid('deck_id must be a valid Agent Deck UUID'),
|
|
8
|
-
name: zod_1.z.string().min(1).optional(),
|
|
9
|
-
});
|
|
10
|
-
exports.REPO_DECK_MANIFEST_PATH = '.agent-deck/deck.yaml';
|
|
11
|
-
//# sourceMappingURL=repo-deck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-deck.js","sourceRoot":"","sources":["../../src/schemas/repo-deck.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,gGAAgG;AACnF,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,yCAAyC,CAAC;IACnE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAIU,QAAA,uBAAuB,GAAG,uBAAuB,CAAC"}
|