@tangle-network/agent-profile-materialize 0.26.8 → 0.26.9
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/secret-session-view.d.ts +11 -5
- package/dist/secret-session-view.js +65 -22
- package/package.json +3 -3
|
@@ -13,11 +13,17 @@ export declare function secretSessionViewWorkspace(input: {
|
|
|
13
13
|
}): string;
|
|
14
14
|
/**
|
|
15
15
|
* Point a session's view at one published secret revision before the
|
|
16
|
-
* session's turn runs. The view's `reference/`
|
|
17
|
-
* links to the revision's read-only files (the same
|
|
18
|
-
* ACL), so the session reads this turn's files and
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* session's turn runs. The view's `reference/` and `.opencode/skills/` become
|
|
17
|
+
* fresh trees of hard links to the revision's read-only files (the same
|
|
18
|
+
* inodes, owner, mode and ACL), so the session reads this turn's files and
|
|
19
|
+
* skills and nothing the previous revision held. A product's skill index
|
|
20
|
+
* names `.opencode/skills/<id>/SKILL.md` cwd-relative, and OpenCode's skill
|
|
21
|
+
* tool lists the same files through the revision's config directory.
|
|
22
|
+
*
|
|
23
|
+
* The view holds nothing else: no `opencode.json`, and a `.opencode/` with
|
|
24
|
+
* only the revision's digest-attested skills, which the launch does not load
|
|
25
|
+
* as project config (it sets OPENCODE_DISABLE_PROJECT_CONFIG). Profile config
|
|
26
|
+
* stays bound by absolute path.
|
|
21
27
|
*
|
|
22
28
|
* The swap is not atomic for a reader that is already running: the caller
|
|
23
29
|
* runs one turn of a session at a time and binds before that turn spawns.
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { createHash, randomBytes } from "node:crypto";
|
|
2
2
|
import { chmodSync, linkSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, } from "node:fs";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
|
+
import { HARNESS_SKILL_DIRS } from "./harness.js";
|
|
4
5
|
import { assertLaunchRoot } from "./managed-workspace.js";
|
|
5
6
|
import { runSetfacl } from "./secret-concurrent-revision.js";
|
|
6
|
-
/** The
|
|
7
|
-
const
|
|
7
|
+
/** The profile's read-only files, which products name cwd-relative. */
|
|
8
|
+
const REFERENCE_ENTRY = "reference";
|
|
9
|
+
/**
|
|
10
|
+
* The profile's mounted skills, at the cwd-relative directory the platform
|
|
11
|
+
* publishes for products to name in their prompts (`.opencode/skills`).
|
|
12
|
+
*/
|
|
13
|
+
const SKILLS_DIR = HARNESS_SKILL_DIRS.opencode;
|
|
14
|
+
const SKILLS_ENTRY = dirname(SKILLS_DIR);
|
|
15
|
+
/** The only cwd-relative content a secret OpenCode session view serves. */
|
|
16
|
+
const VIEW_ENTRIES = new Set([
|
|
17
|
+
REFERENCE_ENTRY,
|
|
18
|
+
SKILLS_ENTRY,
|
|
19
|
+
]);
|
|
8
20
|
/**
|
|
9
21
|
* The stable, sealed cwd of one secret OpenCode session. OpenCode reopens a
|
|
10
22
|
* native session at the directory it was created in, so a session resumed on
|
|
@@ -27,11 +39,17 @@ export function secretSessionViewWorkspace(input) {
|
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
41
|
* Point a session's view at one published secret revision before the
|
|
30
|
-
* session's turn runs. The view's `reference/`
|
|
31
|
-
* links to the revision's read-only files (the same
|
|
32
|
-
* ACL), so the session reads this turn's files and
|
|
33
|
-
*
|
|
34
|
-
*
|
|
42
|
+
* session's turn runs. The view's `reference/` and `.opencode/skills/` become
|
|
43
|
+
* fresh trees of hard links to the revision's read-only files (the same
|
|
44
|
+
* inodes, owner, mode and ACL), so the session reads this turn's files and
|
|
45
|
+
* skills and nothing the previous revision held. A product's skill index
|
|
46
|
+
* names `.opencode/skills/<id>/SKILL.md` cwd-relative, and OpenCode's skill
|
|
47
|
+
* tool lists the same files through the revision's config directory.
|
|
48
|
+
*
|
|
49
|
+
* The view holds nothing else: no `opencode.json`, and a `.opencode/` with
|
|
50
|
+
* only the revision's digest-attested skills, which the launch does not load
|
|
51
|
+
* as project config (it sets OPENCODE_DISABLE_PROJECT_CONFIG). Profile config
|
|
52
|
+
* stays bound by absolute path.
|
|
35
53
|
*
|
|
36
54
|
* The swap is not atomic for a reader that is already running: the caller
|
|
37
55
|
* runs one turn of a session at a time and binds before that turn spawns.
|
|
@@ -61,32 +79,57 @@ export function bindSecretSessionView(input) {
|
|
|
61
79
|
throw new Error("Secret session view is not an executor-owned directory");
|
|
62
80
|
}
|
|
63
81
|
}
|
|
64
|
-
if (readdirSync(viewWorkspaceDir).some((name) => name
|
|
82
|
+
if (readdirSync(viewWorkspaceDir).some((name) => !VIEW_ENTRIES.has(name))) {
|
|
65
83
|
throw new Error("Secret session view holds an unexpected entry");
|
|
66
84
|
}
|
|
67
85
|
// Only this function writes a view. An interrupted bind leaves a staged or
|
|
68
86
|
// retired tree beside `workspace`, never inside it.
|
|
69
87
|
clearBesideWorkspace(viewRoot);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
const staged = new Map();
|
|
89
|
+
const reference = sealedRevisionDirectory(revisionWorkspaceDir, REFERENCE_ENTRY);
|
|
90
|
+
if (reference) {
|
|
91
|
+
const target = besideWorkspace(viewRoot, "stage");
|
|
92
|
+
sealDirectories(linkSealedTree(reference, target), input.subprocessUid);
|
|
93
|
+
staged.set(REFERENCE_ENTRY, target);
|
|
94
|
+
}
|
|
95
|
+
const skills = sealedRevisionDirectory(revisionWorkspaceDir, SKILLS_DIR);
|
|
96
|
+
if (skills) {
|
|
97
|
+
const target = besideWorkspace(viewRoot, "stage");
|
|
98
|
+
mkdirSync(target, { mode: 0o700 });
|
|
99
|
+
const directories = [
|
|
100
|
+
target,
|
|
101
|
+
...linkSealedTree(skills, join(target, basename(SKILLS_DIR))),
|
|
102
|
+
];
|
|
79
103
|
sealDirectories(directories, input.subprocessUid);
|
|
104
|
+
staged.set(SKILLS_ENTRY, target);
|
|
80
105
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
106
|
+
for (const entry of VIEW_ENTRIES) {
|
|
107
|
+
const current = join(viewWorkspaceDir, entry);
|
|
108
|
+
if (lstatIfPresent(current)) {
|
|
109
|
+
renameSync(current, besideWorkspace(viewRoot, "retired"));
|
|
110
|
+
}
|
|
111
|
+
const next = staged.get(entry);
|
|
112
|
+
if (next)
|
|
113
|
+
renameSync(next, current);
|
|
84
114
|
}
|
|
85
|
-
if (staged)
|
|
86
|
-
renameSync(staged, current);
|
|
87
115
|
clearBesideWorkspace(viewRoot);
|
|
88
116
|
sealDirectories([viewRoot, viewWorkspaceDir], input.subprocessUid);
|
|
89
117
|
}
|
|
118
|
+
/** A sealed directory of the published revision, or undefined when absent. */
|
|
119
|
+
function sealedRevisionDirectory(revisionWorkspaceDir, relPath) {
|
|
120
|
+
const source = join(revisionWorkspaceDir, relPath);
|
|
121
|
+
const stat = lstatIfPresent(source);
|
|
122
|
+
if (!stat)
|
|
123
|
+
return undefined;
|
|
124
|
+
if (!isSealedNode(stat, "directory")) {
|
|
125
|
+
throw new Error(`Secret revision ${relPath}/ is not sealed`);
|
|
126
|
+
}
|
|
127
|
+
return source;
|
|
128
|
+
}
|
|
129
|
+
/** A fresh staged or retired path beside the view's `workspace`. */
|
|
130
|
+
function besideWorkspace(viewRoot, kind) {
|
|
131
|
+
return join(viewRoot, `.${kind}-${randomBytes(8).toString("hex")}`);
|
|
132
|
+
}
|
|
90
133
|
function isLaunchWorkspace(launchRoot, workspace, name) {
|
|
91
134
|
return (basename(workspace) === "workspace" &&
|
|
92
135
|
dirname(dirname(workspace)) === launchRoot &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-profile-materialize",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.9",
|
|
4
4
|
"description": "Materialize an AgentProfile into the native per-harness workspace files (the one shared materializer for cli-bridge, agent-container, and VB).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@tangle-network/agent-interface": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
36
36
|
},
|
|
37
37
|
"tangleRelease": {
|
|
38
|
-
"sourceSha": "
|
|
39
|
-
"mergedAt": "2026-10-
|
|
38
|
+
"sourceSha": "be89262c7e1faaedf04926a27d0ecbf17d91a318",
|
|
39
|
+
"mergedAt": "2026-10-19T23:54:34-06:00"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc -p tsconfig.json",
|