@opengeni/runtime 0.14.0 → 0.14.1
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/{chunk-3NUSY22C.js → chunk-HHWIZHQM.js} +26 -9
- package/dist/chunk-HHWIZHQM.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.js +1 -1
- package/package.json +3 -3
- package/src/context-compaction.ts +0 -5
- package/src/index.ts +9 -3
- package/src/sandbox/toolspace-token.ts +36 -12
- package/dist/chunk-3NUSY22C.js.map +0 -1
package/dist/sandbox/index.js
CHANGED
|
@@ -170,7 +170,7 @@ import {
|
|
|
170
170
|
withToolspaceTokenClient,
|
|
171
171
|
withToolspaceTokenEnvironment,
|
|
172
172
|
withToolspaceTokenSession
|
|
173
|
-
} from "../chunk-
|
|
173
|
+
} from "../chunk-HHWIZHQM.js";
|
|
174
174
|
import "../chunk-4YJ5Z52Z.js";
|
|
175
175
|
import "../chunk-K4V4QYCL.js";
|
|
176
176
|
import "../chunk-PZ5AY32C.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/runtime",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@openai/agents-extensions": "0.13.3",
|
|
51
51
|
"@opengeni/agent-proto": "^0.3.0",
|
|
52
52
|
"@opengeni/codex": "^0.2.7",
|
|
53
|
-
"@opengeni/config": "^0.7.
|
|
54
|
-
"@opengeni/contracts": "^0.
|
|
53
|
+
"@opengeni/config": "^0.7.11",
|
|
54
|
+
"@opengeni/contracts": "^0.22.0",
|
|
55
55
|
"@opengeni/network": "^0.1.1",
|
|
56
56
|
"debug": "4.4.3",
|
|
57
57
|
"modal": "0.7.6",
|
|
@@ -100,11 +100,6 @@ export function isCompactionSummary(item: unknown): boolean {
|
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/** Platform-authored system context exists for one inference and is never persisted. */
|
|
104
|
-
export function isEphemeralInternalContext(item: unknown): boolean {
|
|
105
|
-
return itemType(item) === "message" && itemRole(item) === "system";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
103
|
/**
|
|
109
104
|
* Conservative tokenizer-independent text estimate used for every local input
|
|
110
105
|
* budget. Preserve the stable ASCII `chars / 4` heuristic, but never discount
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
approvalIdentifier,
|
|
16
16
|
CAPABILITY_DESCRIPTORS,
|
|
17
17
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
18
|
+
DEFAULT_FIRST_PARTY_MCP_TOOLS,
|
|
18
19
|
assertUniqueResourceMountPaths,
|
|
19
20
|
gitCredentialBindingIdForRepository,
|
|
20
21
|
gitCredentialProviderForRepository,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
type HumanInputResponse,
|
|
34
35
|
type McpServerConnectionRef,
|
|
35
36
|
type Permission,
|
|
37
|
+
type FirstPartyMcpToolName,
|
|
36
38
|
type ReasoningEffort,
|
|
37
39
|
type ResourceRef,
|
|
38
40
|
type SessionEventType,
|
|
@@ -177,6 +179,7 @@ import {
|
|
|
177
179
|
type RunCredentialSessionReady,
|
|
178
180
|
} from "./sandbox";
|
|
179
181
|
import { runWithToolCallCorrelation } from "./sandbox/op-correlation";
|
|
182
|
+
import { shellToolspacePath } from "./sandbox/toolspace-token";
|
|
180
183
|
import {
|
|
181
184
|
createTurnToolCancellationController,
|
|
182
185
|
TurnSandboxCommandCancelledError,
|
|
@@ -296,7 +299,6 @@ export {
|
|
|
296
299
|
MAX_COMPACTION_THRESHOLD_RATIO,
|
|
297
300
|
SUMMARY_BUFFER_TOKENS,
|
|
298
301
|
SUMMARY_PREFIX,
|
|
299
|
-
isEphemeralInternalContext,
|
|
300
302
|
USER_MESSAGE_TRUNCATION_MARKER,
|
|
301
303
|
} from "./context-compaction";
|
|
302
304
|
export type {
|
|
@@ -2407,6 +2409,9 @@ export type PrepareToolsOptions = {
|
|
|
2407
2409
|
// delegated token (manager-style sessions). The caller is responsible for
|
|
2408
2410
|
// having validated the set against the session creator's grant.
|
|
2409
2411
|
firstPartyPermissions?: Permission[];
|
|
2412
|
+
// Exact model-visible catalog selection for the broad first-party server.
|
|
2413
|
+
// Permissions are signed separately and remain the authorization boundary.
|
|
2414
|
+
firstPartyTools?: FirstPartyMcpToolName[];
|
|
2410
2415
|
resolveCredential?: (
|
|
2411
2416
|
input: ResolveConnectionCredentialInput,
|
|
2412
2417
|
) => Promise<ResolveConnectionCredentialResult>;
|
|
@@ -3163,6 +3168,7 @@ async function signFirstPartyDelegatedBearer(
|
|
|
3163
3168
|
subjectId: options.subjectId ?? "worker:first-party-mcp",
|
|
3164
3169
|
...(options.subjectLabel ? { subjectLabel: options.subjectLabel } : {}),
|
|
3165
3170
|
permissions: options.firstPartyPermissions ?? [...DEFAULT_FIRST_PARTY_MCP_PERMISSIONS],
|
|
3171
|
+
firstPartyMcpTools: options.firstPartyTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS],
|
|
3166
3172
|
...(options.sessionId ? { sessionId: options.sessionId } : {}),
|
|
3167
3173
|
...(options.turnId ? { turnId: options.turnId } : {}),
|
|
3168
3174
|
...(options.attemptId ? { attemptId: options.attemptId } : {}),
|
|
@@ -6812,10 +6818,10 @@ export function toolspaceTokenSeedCommand(
|
|
|
6812
6818
|
' seed_umask="$(umask)"',
|
|
6813
6819
|
" umask 077",
|
|
6814
6820
|
options.tokenFile
|
|
6815
|
-
? ` token_file=${
|
|
6821
|
+
? ` token_file=${shellToolspacePath(options.tokenFile)}`
|
|
6816
6822
|
: ' token_file="${OPENGENI_TOOLSPACE_TOKEN_FILE:-$HOME/.opengeni/toolspace-token}"',
|
|
6817
6823
|
options.legacyTokenFile
|
|
6818
|
-
? ` legacy_token_file=${
|
|
6824
|
+
? ` legacy_token_file=${shellToolspacePath(options.legacyTokenFile)}`
|
|
6819
6825
|
: ' legacy_token_file=""',
|
|
6820
6826
|
' mkdir -p "$(dirname "$token_file")"',
|
|
6821
6827
|
' printf \'%s\' "$OPENGENI_TOOLSPACE_TOKEN_SEED" > "$token_file.tmp.$$"',
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
} from "@openai/agents/sandbox";
|
|
10
10
|
|
|
11
11
|
const MAX_TOOLSPACE_SESSION_ID_BYTES = 512;
|
|
12
|
+
const HOME_RELATIVE_TOOLSPACE_PREFIX = "$HOME/";
|
|
12
13
|
|
|
13
14
|
export class ToolspaceTokenPathError extends Error {
|
|
14
15
|
constructor(message: string) {
|
|
@@ -33,6 +34,36 @@ function assertToolspaceSessionId(sessionId: string): string {
|
|
|
33
34
|
return sessionId;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
function isHomeRelativeToolspacePath(value: string): boolean {
|
|
38
|
+
if (!value.startsWith(HOME_RELATIVE_TOOLSPACE_PREFIX)) return false;
|
|
39
|
+
const relative = value.slice(HOME_RELATIVE_TOOLSPACE_PREFIX.length);
|
|
40
|
+
const segments = relative.split("/");
|
|
41
|
+
return (
|
|
42
|
+
relative.length > 0 &&
|
|
43
|
+
!relative.includes("\0") &&
|
|
44
|
+
segments.every(
|
|
45
|
+
(segment) => segment !== "." && segment !== ".." && /^[A-Za-z0-9._-]+$/.test(segment),
|
|
46
|
+
) &&
|
|
47
|
+
posixPath.normalize(relative) === relative
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assertToolspaceFilePath(value: string, label: string): string {
|
|
52
|
+
if (
|
|
53
|
+
!value ||
|
|
54
|
+
value.includes("\0") ||
|
|
55
|
+
(!posixPath.isAbsolute(value) && !isHomeRelativeToolspacePath(value))
|
|
56
|
+
) {
|
|
57
|
+
throw new ToolspaceTokenPathError(`${label} must be absolute or use the trusted $HOME/ prefix`);
|
|
58
|
+
}
|
|
59
|
+
return posixPath.isAbsolute(value) ? posixPath.normalize(value) : value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function shellToolspacePath(value: string): string {
|
|
63
|
+
const validated = assertToolspaceFilePath(value, "Toolspace token file");
|
|
64
|
+
return isHomeRelativeToolspacePath(validated) ? `"${validated}"` : shellQuote(validated);
|
|
65
|
+
}
|
|
66
|
+
|
|
36
67
|
/**
|
|
37
68
|
* Derive the per-session token file beside the legacy manifest pointer.
|
|
38
69
|
*
|
|
@@ -44,14 +75,10 @@ function assertToolspaceSessionId(sessionId: string): string {
|
|
|
44
75
|
* authority boundary for Toolspace calls.
|
|
45
76
|
*/
|
|
46
77
|
export function toolspaceTokenFileForSession(manifestTokenFile: string, sessionId: string): string {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
) {
|
|
52
|
-
throw new ToolspaceTokenPathError("Toolspace manifest token file must be absolute");
|
|
53
|
-
}
|
|
54
|
-
const normalizedManifestFile = posixPath.normalize(manifestTokenFile);
|
|
78
|
+
const normalizedManifestFile = assertToolspaceFilePath(
|
|
79
|
+
manifestTokenFile,
|
|
80
|
+
"Toolspace manifest token file",
|
|
81
|
+
);
|
|
55
82
|
const digest = createHash("sha256").update(assertToolspaceSessionId(sessionId)).digest("hex");
|
|
56
83
|
return posixPath.join(posixPath.dirname(normalizedManifestFile), "toolspace-tokens", digest);
|
|
57
84
|
}
|
|
@@ -68,10 +95,7 @@ export function toolspaceTokenFileFromEnvironment(
|
|
|
68
95
|
|
|
69
96
|
/** Prefix one sandbox command with its session-specific Toolspace pointer. */
|
|
70
97
|
export function withToolspaceTokenEnvironment(cmd: string, tokenFile: string): string {
|
|
71
|
-
|
|
72
|
-
throw new ToolspaceTokenPathError("Toolspace token file must be absolute");
|
|
73
|
-
}
|
|
74
|
-
return [`export OPENGENI_TOOLSPACE_TOKEN_FILE=${shellQuote(tokenFile)}`, cmd].join("\n");
|
|
98
|
+
return [`export OPENGENI_TOOLSPACE_TOKEN_FILE=${shellToolspacePath(tokenFile)}`, cmd].join("\n");
|
|
75
99
|
}
|
|
76
100
|
|
|
77
101
|
/** Preserve provider identity/capabilities while decorating command creation. */
|