@tangle-network/agent-profile-materialize 0.26.3 → 0.26.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.
|
@@ -20,5 +20,5 @@ export declare function assertPrivateManagedRoot(root: string): void;
|
|
|
20
20
|
* The caller must keep the returned tree while an admitted turn uses it and
|
|
21
21
|
* dispose it after that turn, so a later binding cannot expose old secrets.
|
|
22
22
|
*/
|
|
23
|
-
export declare function prepareManagedWorkspacePlan(plan: WorkspacePlan, managedRoot: string, sharedWorkspaceDir: string, secretProvider: AgentProfileSecretProvider, options?: Pick<ApplyWorkspacePlanOptions, "ownership" | "runtimeOnlyFiles" | "
|
|
23
|
+
export declare function prepareManagedWorkspacePlan(plan: WorkspacePlan, managedRoot: string, sharedWorkspaceDir: string, secretProvider: AgentProfileSecretProvider, options?: Pick<ApplyWorkspacePlanOptions, "ownership" | "runtimeOnlyFiles" | "secretFileSlotReferences">): Promise<PreparedManagedWorkspace>;
|
|
24
24
|
export declare function lstatIfPresent(path: string): ReturnType<typeof lstatSync> | null;
|
package/dist/plan-application.js
CHANGED
|
@@ -9,7 +9,7 @@ export function applyWorkspacePlan(plan, workspaceDir, options = {}) {
|
|
|
9
9
|
*/
|
|
10
10
|
export async function applyWorkspacePlanWithSecretProvider(plan, workspaceDir, secretProvider, options = {}) {
|
|
11
11
|
const planDigest = hashWorkspacePlan(plan);
|
|
12
|
-
const resolved = await resolvePrivateWorkspacePlan(plan, secretProvider, options.
|
|
12
|
+
const resolved = await resolvePrivateWorkspacePlan(plan, secretProvider, options.secretFileSlotReferences);
|
|
13
13
|
return applyResolvedWorkspacePlan(plan, resolved, workspaceDir, options, planDigest);
|
|
14
14
|
}
|
|
15
15
|
function secretRefLabel(ref) {
|
|
@@ -81,7 +81,7 @@ function resolvePublicWorkspacePlan(plan) {
|
|
|
81
81
|
/**
|
|
82
82
|
* OpenCode substitutes `{env:NAME}` textually into its config before parsing
|
|
83
83
|
* it, so only a value that cannot break out of a JSON string or start another
|
|
84
|
-
* substitution may
|
|
84
|
+
* substitution may stand behind a reference.
|
|
85
85
|
*/
|
|
86
86
|
const SUBSTITUTABLE_SECRET_VALUE = /^[\x20-\x7e]+$/;
|
|
87
87
|
const UNSUBSTITUTABLE_SECRET_CHARACTERS = /["\\{}]/;
|
|
@@ -93,7 +93,7 @@ function secretSlotEnvironmentName(ref) {
|
|
|
93
93
|
.toUpperCase();
|
|
94
94
|
return `TANGLE_PROFILE_SECRET_${digest}`;
|
|
95
95
|
}
|
|
96
|
-
async function resolvePrivateWorkspacePlan(plan, secretProvider,
|
|
96
|
+
async function resolvePrivateWorkspacePlan(plan, secretProvider, fileSlotReferences) {
|
|
97
97
|
if (!secretProvider || typeof secretProvider.get !== "function") {
|
|
98
98
|
throw new Error("AgentProfileSecretProvider.get is required");
|
|
99
99
|
}
|
|
@@ -123,13 +123,17 @@ async function resolvePrivateWorkspacePlan(plan, secretProvider, fileSlotEnviron
|
|
|
123
123
|
const resolveFileSlot = async (input) => {
|
|
124
124
|
const ref = agentProfileSecretRefSchema.parse(input);
|
|
125
125
|
const value = await resolveRawRef(ref);
|
|
126
|
-
if (!
|
|
127
|
-
!SUBSTITUTABLE_SECRET_VALUE.test(value) ||
|
|
128
|
-
UNSUBSTITUTABLE_SECRET_CHARACTERS.test(value)) {
|
|
126
|
+
if (!fileSlotReferences) {
|
|
129
127
|
return ref.format === "bearer" ? `Bearer ${value}` : value;
|
|
130
128
|
}
|
|
129
|
+
// Never write the value in place: the file is readable by the process
|
|
130
|
+
// that loads it, and so by every tool that process runs.
|
|
131
|
+
if (!SUBSTITUTABLE_SECRET_VALUE.test(value) ||
|
|
132
|
+
UNSUBSTITUTABLE_SECRET_CHARACTERS.test(value)) {
|
|
133
|
+
throw new Error(`AgentProfile secret ${secretRefLabel(ref)} has a value that cannot be referenced from a secret OpenCode config: it may hold only printable ASCII without quotes, backslashes or braces`);
|
|
134
|
+
}
|
|
131
135
|
const name = secretSlotEnvironmentName(ref);
|
|
132
|
-
|
|
136
|
+
fileSlotReferences[name] = value;
|
|
133
137
|
return ref.format === "bearer" ? `Bearer {env:${name}}` : `{env:${name}}`;
|
|
134
138
|
};
|
|
135
139
|
const files = await Promise.all(normalizePlanFiles(plan.files).map(async (file) => {
|
package/dist/plan-types.d.ts
CHANGED
|
@@ -321,14 +321,15 @@ export interface ApplyWorkspacePlanOptions {
|
|
|
321
321
|
*/
|
|
322
322
|
appliedPlanDigest?: string;
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* lands here under NAME
|
|
328
|
-
*
|
|
329
|
-
*
|
|
324
|
+
* Write every JSON file secret slot as an `{env:NAME}` reference (OpenCode
|
|
325
|
+
* config substitution) and never its value, so file bytes and every digest
|
|
326
|
+
* over them stay identical when only a secret's value changes. The value
|
|
327
|
+
* lands here under NAME for the executor alone: never put it in the launch
|
|
328
|
+
* environment, argv or any file the native process reads, because that
|
|
329
|
+
* process hands everything it holds to every tool it runs. A value that
|
|
330
|
+
* could not be substituted safely is refused.
|
|
330
331
|
*/
|
|
331
|
-
|
|
332
|
+
secretFileSlotReferences?: Record<string, string>;
|
|
332
333
|
}
|
|
333
334
|
import type { AgentProfileSecretRef } from "@tangle-network/agent-interface";
|
|
334
335
|
import type { HarnessId } from "./harness.js";
|
|
@@ -18,5 +18,13 @@ export declare function prepareSecretConcurrentProfileRevision(input: {
|
|
|
18
18
|
namingKey: Uint8Array;
|
|
19
19
|
secretProvider: AgentProfileSecretProvider;
|
|
20
20
|
options?: Pick<ApplyWorkspacePlanOptions, "runtimeOnlyFiles">;
|
|
21
|
-
}): Promise<ConcurrentProfileRevision
|
|
21
|
+
}): Promise<ConcurrentProfileRevision & {
|
|
22
|
+
/**
|
|
23
|
+
* The value behind each `{env:NAME}` reference in the revision's config,
|
|
24
|
+
* for the executor alone: the launch never receives them. An executor
|
|
25
|
+
* that serves a referencing MCP server through its own loopback proxy
|
|
26
|
+
* resolves the server's headers here.
|
|
27
|
+
*/
|
|
28
|
+
secretReferences: Readonly<Record<string, string>>;
|
|
29
|
+
}>;
|
|
22
30
|
export declare function runSetfacl(args: string[], paths: readonly string[]): void;
|
|
@@ -5,6 +5,7 @@ import { join } from "node:path";
|
|
|
5
5
|
import { assertLaunchRoot, listRevisionFiles, makeStageWritable, prepareExplicitOpenCodePlan, } from "./managed-workspace.js";
|
|
6
6
|
import { bindConcurrentLaunch } from "./managed-workspace-bind.js";
|
|
7
7
|
import { lstatIfPresent, prepareManagedWorkspacePlan, } from "./managed-workspace-stage.js";
|
|
8
|
+
import { normalizeWorkspacePlanArgument } from "./plan-normalize.js";
|
|
8
9
|
import { assertWorkspacePlanSupported } from "./plan-support.js";
|
|
9
10
|
/**
|
|
10
11
|
* Publish a resolved revision for exactly one native subprocess UID. The
|
|
@@ -52,12 +53,21 @@ export async function prepareSecretConcurrentProfileRevision(input) {
|
|
|
52
53
|
if (plan.files.some((file) => file.relPath.startsWith(".config/opencode/"))) {
|
|
53
54
|
throw new Error("Secret OpenCode reserves its native config directory");
|
|
54
55
|
}
|
|
56
|
+
// OpenCode and every process it spawns run as the session UID, so a value in
|
|
57
|
+
// its environment, argv or config is readable by the agent's own shell
|
|
58
|
+
// (`/proc/<pid>/environ`, `/proc/<pid>/cmdline`, `cat`). No profile secret
|
|
59
|
+
// value may reach the launch: config slots stay references whose values the
|
|
60
|
+
// launch never receives (#11875).
|
|
61
|
+
if (Object.values(plan.env).some((value) => typeof value !== "string") ||
|
|
62
|
+
plan.flags.some((argument) => typeof normalizeWorkspacePlanArgument(argument) !== "string")) {
|
|
63
|
+
throw new Error("Secret OpenCode refuses a profile secret in its launch environment or arguments");
|
|
64
|
+
}
|
|
55
65
|
assertWorkspacePlanSupported(plan);
|
|
56
66
|
assertLaunchRoot(input.launchRoot);
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
const
|
|
60
|
-
const prepared = await prepareManagedWorkspacePlan(plan, input.managedRoot, input.sharedWorkspaceDir, input.secretProvider, { ...input.options,
|
|
67
|
+
// File slots reference their secrets, so an unchanged profile with a rotated
|
|
68
|
+
// per-turn secret reuses this revision.
|
|
69
|
+
const secretReferences = {};
|
|
70
|
+
const prepared = await prepareManagedWorkspacePlan(plan, input.managedRoot, input.sharedWorkspaceDir, input.secretProvider, { ...input.options, secretFileSlotReferences: secretReferences });
|
|
61
71
|
try {
|
|
62
72
|
// XDG_CONFIG_HOME is bound to this executor-owned tree at native launch.
|
|
63
73
|
// An agent-owned HOME may hold SQLite state, never native authority.
|
|
@@ -112,14 +122,11 @@ export async function prepareSecretConcurrentProfileRevision(input) {
|
|
|
112
122
|
prepared.dispose();
|
|
113
123
|
}
|
|
114
124
|
}
|
|
115
|
-
// Added after launchDigest so the digest and receipt never cover a value.
|
|
116
125
|
return {
|
|
117
126
|
directory,
|
|
118
127
|
manifest: prepared.manifest,
|
|
119
|
-
application: {
|
|
120
|
-
|
|
121
|
-
spawn: { ...spawn, env: { ...spawn.env, ...secretEnvironment } },
|
|
122
|
-
},
|
|
128
|
+
application: { ...prepared.application, spawn },
|
|
129
|
+
secretReferences,
|
|
123
130
|
};
|
|
124
131
|
}
|
|
125
132
|
catch (error) {
|
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.5",
|
|
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": "264ba6910963c1036183ef29fe6ed3dadb465256",
|
|
39
|
+
"mergedAt": "2026-10-19T06:31:19-06:00"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc -p tsconfig.json",
|