@kodax-ai/kodax 0.7.91 → 0.7.93
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/CHANGELOG.md +69 -0
- package/README.md +27 -0
- package/README_CN.md +24 -0
- package/dist/chunks/{agent-YLYM2UIQ.js → agent-R7HVNARP.js} +1 -1
- package/dist/chunks/argument-completer-JHXUJWHC.js +2 -0
- package/dist/chunks/{chunk-MGM5SUKU.js → chunk-3YOZIFSJ.js} +2 -2
- package/dist/chunks/{chunk-XQWPHL6U.js → chunk-4BY53JTF.js} +123 -123
- package/dist/chunks/{chunk-X75UGXP3.js → chunk-7QBWHCIZ.js} +1 -1
- package/dist/chunks/{chunk-4R4QTBO6.js → chunk-7XSZVOG7.js} +135 -135
- package/dist/chunks/chunk-A3ZQE2BX.js +519 -0
- package/dist/chunks/{chunk-FBL7IVMK.js → chunk-BHE66SP3.js} +14 -14
- package/dist/chunks/chunk-D27EY4XC.js +383 -0
- package/dist/chunks/{chunk-7RF2XYFK.js → chunk-GH3KBC2H.js} +1 -1
- package/dist/chunks/{chunk-G5XXC7ON.js → chunk-GRWUC6H7.js} +1 -1
- package/dist/chunks/{chunk-3SVR6PC4.js → chunk-HLZWPB32.js} +2 -2
- package/dist/chunks/{chunk-P7AW3CQW.js → chunk-JJ2YDBSN.js} +2 -2
- package/dist/chunks/{chunk-UNTT2ZKN.js → chunk-JTZKC4TV.js} +205 -204
- package/dist/chunks/{chunk-7YQT4RAW.js → chunk-PRASABCC.js} +2 -2
- package/dist/chunks/{chunk-YQSQEF6J.js → chunk-SMVC3Q3U.js} +173 -173
- package/dist/chunks/{chunk-HXORFXTH.js → chunk-XTWIGVUL.js} +1 -1
- package/dist/chunks/{chunk-ZNH2MKN5.js → chunk-YVG6OKN7.js} +1 -1
- package/dist/chunks/{client-SKLNEU3G.js → client-OVYKC3ND.js} +1 -1
- package/dist/chunks/{compaction-config-UEGW2ZBT.js → compaction-config-2TVSYSB4.js} +1 -1
- package/dist/chunks/{construction-bootstrap-OUKXVNUQ.js → construction-bootstrap-474QPSYB.js} +1 -1
- package/dist/chunks/{dist-7EWVACPM.js → dist-H4PT2QAV.js} +1 -1
- package/dist/chunks/{dist-WNMK42WE.js → dist-ITTXQHRJ.js} +1 -1
- package/dist/chunks/host-OR3IO2A4.js +2 -0
- package/dist/chunks/{run-manager-J4WO55J2.js → run-manager-MNOTWIFX.js} +1 -1
- package/dist/chunks/{utils-NZXGH43M.js → utils-5J4BHNBV.js} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1365 -1364
- package/dist/runtime-worker.js +1168 -1167
- package/dist/sandbox-workspace-session.js +268 -267
- package/dist/sdk-a2a.d.ts +2 -2
- package/dist/sdk-a2a.js +1 -1
- package/dist/sdk-agent.d.ts +6 -1
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-repl.d.ts +6 -6
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-runtime.d.ts +5 -4
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.d.ts +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +2 -2
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +77 -76
- package/dist/types-chunks/{public-api.d-ItHKrP7K.d.ts → public-api.d-BsZWOq3P.d.ts} +2 -0
- package/dist/types-chunks/{repl.d-Beg6tiSz.d.ts → repl.d-DxD0Olm0.d.ts} +2 -2
- package/dist/types-chunks/{sdk-session-C7aoqrIR.d.ts → sdk-session-BTzblJTQ.d.ts} +1 -1
- package/dist/types-chunks/{utils.d-Qa_Z1w2Q.d.ts → utils.d-50Q24Few.d.ts} +1 -1
- package/package.json +2 -1
- package/dist/chunks/argument-completer-4WND7KNM.js +0 -2
- package/dist/chunks/chunk-4S5ZAR6N.js +0 -383
- package/dist/chunks/chunk-XC2GKTSX.js +0 -519
- package/dist/chunks/host-GDDQKQKH.js +0 -2
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{k as kn}from"./chunk-UNTT2ZKN.js";import{Ia as q,Wa as ar,Ya as dr,_a as Oe,db as Ne,fb as vn,ib as xn,t as W,zc as Z}from"./chunk-4R4QTBO6.js";import{a as s}from"./chunk-ONUPGMER.js";import{spawn as br,spawnSync as Je}from"node:child_process";import{createHash as fn,randomUUID as z}from"node:crypto";import{once as cr}from"node:events";import{constants as tt,existsSync as vr,lstatSync as Mn,mkdirSync as lr,readFileSync as xr,readdirSync as jn,realpathSync as ue,renameSync as $n,rmSync as Ae,statSync as pn,writeFileSync as ur,writeSync as $o}from"node:fs";import{copyFile as kr,lstat as ot,mkdir as X,readFile as Ee,realpath as Me,rename as st,rm as G,rmdir as it,stat as rn,writeFile as Re}from"node:fs/promises";import{createRequire as at}from"node:module";import{createServer as dt}from"node:net";import ie from"node:os";import i from"node:path";import ct from"node:readline";import{fileURLToPath as fr,pathToFileURL as Ar}from"node:url";var ce="0.0.65",{DEFAULT_WINDOWS_PROXY_PORT_RANGE:lt,SandboxManager:An,getSrtWinPath:ut,getWindowsSandboxUserStatus:qn,grantWindowsAcl:ft,installWindowsSandbox:pt,resolveSrtWin:wt,revokeWindowsAcl:Er}=await import("@anthropic-ai/sandbox-runtime");function mt(){let e=process.platform==="win32"?"windows-restricted-user":process.platform==="darwin"?"macos-seatbelt":process.platform==="linux"?"linux-bubblewrap":"unsupported";return{version:3,asrtVersion:ce,platform:process.platform,backend:e,genericCommandExecution:!0,controls:["filesystem","network","environment","timeout","output"],ordinaryCallsTriggerSetup:!1,setupMayElevate:process.platform==="win32",unavailableBehavior:"structured-no-execution",permissionFallback:"normal-permission-policy"}}s(mt,"sandboxRuntimeCapability");var Kn=1048576,Xn=12e4,Gn=at(import.meta.url),Rr=process.env.KODAX_BUNDLED==="true"?void 0:Ar(Gn.resolve("@anthropic-ai/sandbox-runtime")).href,gt=new Set([".ssh",".aws",".azure",".gnupg",".kodax",".agents",".codex",".claude",".gemini",".direnv",".terraform.d"]),yt=new Set([".env",".envrc",".pgpass",".npmrc",".pypirc","credentials","id_rsa","id_ed25519"]),St=[".ssh",".aws",".azure",".gnupg",".kube",".docker",".kodax",".agents",".codex",".claude",".gemini",".direnv",".terraform.d",i.join(".cargo","credentials.toml"),i.join(".config","gcloud"),i.join(".config","gh"),i.join(".config","openai"),i.join(".config","anthropic"),".gitconfig",i.join(".config","git","config"),".terraformrc",i.join(".config","pypoetry","auth.toml"),".condarc",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",i.join(".config","fish","config.fish"),i.join(".config","fish","fish_variables"),".bash_history",".zsh_history",i.join(".m2","settings.xml"),i.join(".m2","settings-security.xml"),i.join(".gradle","gradle.properties"),i.join(".nuget","NuGet","NuGet.Config"),i.join(".pip","pip.conf"),i.join(".config","pip","pip.conf"),i.join(".cache","huggingface","token"),i.join(".huggingface","token"),i.join(".config","rclone","rclone.conf"),i.join(".local","share","keyrings"),i.join("Library","Keychains"),i.join("AppData","Roaming","Microsoft","Protect"),i.join("AppData","Roaming","Microsoft","Credentials"),i.join("AppData","Roaming","Microsoft","Vault"),i.join("AppData","Local","Microsoft","Credentials"),i.join("AppData","Local","Microsoft","Protect"),i.join("AppData","Local","Microsoft","Vault"),".password-store",".env",".envrc",".pgpass",".env.local",".env.development",".env.production",".env.test",".env.staging",".npmrc",".pypirc",".netrc",".git-credentials","credentials","credentials.json","application_default_credentials.json","id_rsa","id_dsa","id_ecdsa","id_ed25519"],ht=["runtime","mcp-tokens","mcp-clients","integrations","sandbox-runtime","processes","learned","config.json","auth.json","trusted-project-rules.json",".env",".envrc",".pgpass",".npmrc",".pypirc",".netrc",".git-credentials","credentials","credentials.json","application_default_credentials.json"],Jn=["runtime","processes","learned"],bt=String.raw`
|
|
3
|
-
$ErrorActionPreference = 'Stop'
|
|
4
|
-
$payload = [Console]::In.ReadToEnd() | ConvertFrom-Json
|
|
5
|
-
$mutex = [System.Threading.Mutex]::new($false, 'Local\KodaXAsrtAclGuard-v1')
|
|
6
|
-
$held = $false
|
|
7
|
-
$missing = [System.Collections.Generic.List[string]]::new()
|
|
8
|
-
function Test-KodaXAsrtAclRule($acl, $sidValue, $rights, $inheritance) {
|
|
9
|
-
foreach ($rule in $acl.Access) {
|
|
10
|
-
try {
|
|
11
|
-
$ruleSid = $rule.IdentityReference.Translate(
|
|
12
|
-
[System.Security.Principal.SecurityIdentifier]
|
|
13
|
-
).Value
|
|
14
|
-
} catch {
|
|
15
|
-
continue
|
|
16
|
-
}
|
|
17
|
-
if (
|
|
18
|
-
$ruleSid -eq $sidValue -and
|
|
19
|
-
$rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Deny -and
|
|
20
|
-
-not $rule.IsInherited -and
|
|
21
|
-
$rule.InheritanceFlags -eq $inheritance -and
|
|
22
|
-
$rule.PropagationFlags -eq [System.Security.AccessControl.PropagationFlags]::None -and
|
|
23
|
-
(([int]$rule.FileSystemRights -band [int]$rights) -eq [int]$rights)
|
|
24
|
-
) {
|
|
25
|
-
return $true
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return $false
|
|
29
|
-
}
|
|
30
|
-
function Test-KodaXParentDeleteChildSafe($acl, $tokenSidValues) {
|
|
31
|
-
foreach ($rule in $acl.Access) {
|
|
32
|
-
try {
|
|
33
|
-
$ruleSid = $rule.IdentityReference.Translate(
|
|
34
|
-
[System.Security.Principal.SecurityIdentifier]
|
|
35
|
-
).Value
|
|
36
|
-
} catch {
|
|
37
|
-
continue
|
|
38
|
-
}
|
|
39
|
-
if (
|
|
40
|
-
$tokenSidValues -contains $ruleSid -and
|
|
41
|
-
$rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Deny -and
|
|
42
|
-
($rule.PropagationFlags -band [System.Security.AccessControl.PropagationFlags]::InheritOnly) -eq 0 -and
|
|
43
|
-
(([int]$rule.FileSystemRights -band [int][System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles) -ne 0)
|
|
44
|
-
) {
|
|
45
|
-
return $true
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
foreach ($rule in $acl.Access) {
|
|
49
|
-
try {
|
|
50
|
-
$ruleSid = $rule.IdentityReference.Translate(
|
|
51
|
-
[System.Security.Principal.SecurityIdentifier]
|
|
52
|
-
).Value
|
|
53
|
-
} catch {
|
|
54
|
-
continue
|
|
55
|
-
}
|
|
56
|
-
if (
|
|
57
|
-
$tokenSidValues -contains $ruleSid -and
|
|
58
|
-
$rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and
|
|
59
|
-
($rule.PropagationFlags -band [System.Security.AccessControl.PropagationFlags]::InheritOnly) -eq 0 -and
|
|
60
|
-
(([int]$rule.FileSystemRights -band [int][System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles) -ne 0)
|
|
61
|
-
) {
|
|
62
|
-
return $false
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return $true
|
|
66
|
-
}
|
|
67
|
-
function Test-KodaXAsrtAclRuleReadsData($acl, $sidValue) {
|
|
68
|
-
foreach ($rule in $acl.Access) {
|
|
69
|
-
try {
|
|
70
|
-
$ruleSid = $rule.IdentityReference.Translate(
|
|
71
|
-
[System.Security.Principal.SecurityIdentifier]
|
|
72
|
-
).Value
|
|
73
|
-
} catch {
|
|
74
|
-
continue
|
|
75
|
-
}
|
|
76
|
-
if (
|
|
77
|
-
$ruleSid -eq $sidValue -and
|
|
78
|
-
$rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Deny -and
|
|
79
|
-
-not $rule.IsInherited -and
|
|
80
|
-
$rule.PropagationFlags -eq [System.Security.AccessControl.PropagationFlags]::None -and
|
|
81
|
-
(([int]$rule.FileSystemRights -band ([int][System.Security.AccessControl.FileSystemRights]::ReadAndExecute -bor [int][System.Security.AccessControl.FileSystemRights]::Synchronize)) -ne 0)
|
|
82
|
-
) {
|
|
83
|
-
return $true
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return $false
|
|
87
|
-
}
|
|
88
|
-
function Add-KodaXAsrtAclRule($target, $sid, $rights, $inheritance, $ruleText) {
|
|
89
|
-
$acl = Get-Acl -LiteralPath $target
|
|
90
|
-
if (Test-KodaXAsrtAclRule $acl $sid.Value $rights $inheritance) {
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
$principal = '*' + $sid.Value
|
|
94
|
-
& "$env:SystemRoot\System32\icacls.exe" $target '/deny' "$($principal):$ruleText" | Out-Null
|
|
95
|
-
if ($LASTEXITCODE -ne 0) {
|
|
96
|
-
throw "icacls failed to install a KodaX sandbox guard on $target."
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function Add-KodaXAsrtWriteAclRule($target, $sid, $rights, $inheritance) {
|
|
100
|
-
$acl = Get-Acl -LiteralPath $target
|
|
101
|
-
if (Test-KodaXAsrtAclRule $acl $sid.Value $rights $inheritance) {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
|
|
105
|
-
$sid,
|
|
106
|
-
$rights,
|
|
107
|
-
$inheritance,
|
|
108
|
-
[System.Security.AccessControl.PropagationFlags]::None,
|
|
109
|
-
[System.Security.AccessControl.AccessControlType]::Deny
|
|
110
|
-
)
|
|
111
|
-
[void]$acl.AddAccessRule($rule)
|
|
112
|
-
Set-Acl -LiteralPath $target -AclObject $acl
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
try {
|
|
116
|
-
$held = $mutex.WaitOne(10000)
|
|
117
|
-
} catch [System.Threading.AbandonedMutexException] {
|
|
118
|
-
$held = $true
|
|
119
|
-
}
|
|
120
|
-
if (-not $held) {
|
|
121
|
-
throw 'Timed out waiting for the KodaX ASRT ACL guard mutex.'
|
|
122
|
-
}
|
|
123
|
-
$sid = [System.Security.Principal.SecurityIdentifier]::new([string]$payload.sid)
|
|
124
|
-
$tokenSidValues = @($payload.tokenSids | ForEach-Object { [string]$_ })
|
|
125
|
-
foreach ($entry in $payload.paths) {
|
|
126
|
-
$target = [System.IO.Path]::GetFullPath([string]$entry.path)
|
|
127
|
-
if (-not (Test-Path -LiteralPath $target)) {
|
|
128
|
-
throw "ACL guard target disappeared before it could be protected: $target"
|
|
129
|
-
}
|
|
130
|
-
$inheritance = if ([bool]$entry.directory) {
|
|
131
|
-
[System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
|
|
132
|
-
[System.Security.AccessControl.InheritanceFlags]::ObjectInherit
|
|
133
|
-
} else {
|
|
134
|
-
[System.Security.AccessControl.InheritanceFlags]::None
|
|
135
|
-
}
|
|
136
|
-
$writeRights = [System.Security.AccessControl.FileSystemRights]::Write -bor
|
|
137
|
-
[System.Security.AccessControl.FileSystemRights]::Delete -bor
|
|
138
|
-
[System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor
|
|
139
|
-
[System.Security.AccessControl.FileSystemRights]::TakeOwnership
|
|
140
|
-
if ([bool]$entry.directory) {
|
|
141
|
-
$writeRights = $writeRights -bor [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles
|
|
142
|
-
}
|
|
143
|
-
$targetRights = if ([string]$entry.mode -eq 'write') {
|
|
144
|
-
$writeRights
|
|
145
|
-
} else {
|
|
146
|
-
[System.Security.AccessControl.FileSystemRights]::FullControl
|
|
147
|
-
}
|
|
148
|
-
$parent = [System.IO.Path]::GetDirectoryName($target)
|
|
149
|
-
$targetAcl = Get-Acl -LiteralPath $target
|
|
150
|
-
$targetReady = Test-KodaXAsrtAclRule $targetAcl $sid.Value $targetRights $inheritance
|
|
151
|
-
$targetTooBroad = [string]$entry.mode -eq 'write' -and (Test-KodaXAsrtAclRuleReadsData $targetAcl $sid.Value)
|
|
152
|
-
if ($targetTooBroad) {
|
|
153
|
-
$targetReady = $false
|
|
154
|
-
}
|
|
155
|
-
$parentReady = -not $parent -or $parent -eq $target -or -not (Test-Path -LiteralPath $parent)
|
|
156
|
-
if (-not $parentReady) {
|
|
157
|
-
$parentAcl = Get-Acl -LiteralPath $parent
|
|
158
|
-
$parentReady = (Test-KodaXAsrtAclRule $parentAcl $sid.Value ([System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles) ([System.Security.AccessControl.InheritanceFlags]::None)) -or (Test-KodaXParentDeleteChildSafe $parentAcl $tokenSidValues)
|
|
159
|
-
}
|
|
160
|
-
if (-not [bool]$payload.install) {
|
|
161
|
-
if (-not $targetReady -or -not $parentReady) {
|
|
162
|
-
[void]$missing.Add($target)
|
|
163
|
-
}
|
|
164
|
-
continue
|
|
165
|
-
}
|
|
166
|
-
if ($targetTooBroad) {
|
|
167
|
-
$principal = '*' + $sid.Value
|
|
168
|
-
& "$env:SystemRoot\System32\icacls.exe" $target '/remove:d' $principal | Out-Null
|
|
169
|
-
if ($LASTEXITCODE -ne 0) {
|
|
170
|
-
throw "icacls failed to remove an obsolete KodaX sandbox guard from $target."
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (-not $targetReady) {
|
|
174
|
-
if ([string]$entry.mode -eq 'write') {
|
|
175
|
-
Add-KodaXAsrtWriteAclRule $target $sid $targetRights $inheritance
|
|
176
|
-
} else {
|
|
177
|
-
$targetRule = if ([bool]$entry.directory) { '(OI)(CI)(F)' } else { '(F)' }
|
|
178
|
-
Add-KodaXAsrtAclRule $target $sid $targetRights $inheritance $targetRule
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (-not $parentReady) {
|
|
182
|
-
Add-KodaXAsrtAclRule $parent $sid ([System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles) ([System.Security.AccessControl.InheritanceFlags]::None) '(DC)'
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
[Console]::Out.Write((@{ missing = @($missing) } | ConvertTo-Json -Compress))
|
|
186
|
-
} finally {
|
|
187
|
-
if ($held) {
|
|
188
|
-
[void]$mutex.ReleaseMutex()
|
|
189
|
-
}
|
|
190
|
-
$mutex.Dispose()
|
|
191
|
-
}
|
|
192
|
-
`,Tn=new Set,Pr=new Set,pr=JSON.stringify(dr),En=JSON.stringify(ar),vt=String.raw`
|
|
193
|
-
const { spawn } = require('node:child_process');
|
|
194
|
-
const { writeSync } = require('node:fs');
|
|
195
|
-
const input = JSON.parse(Buffer.from(process.argv[2], 'base64').toString('utf8'));
|
|
196
|
-
const childEnv = { ...process.env };
|
|
197
|
-
for (const name of Object.keys(childEnv)) {
|
|
198
|
-
if (name.toLowerCase() === 'electron_run_as_node') delete childEnv[name];
|
|
199
|
-
}
|
|
200
|
-
if (input.electronRunAsNode === true) childEnv.ELECTRON_RUN_AS_NODE = '1';
|
|
201
|
-
const child = spawn(input.command, input.args, {
|
|
202
|
-
cwd: input.cwd,
|
|
203
|
-
env: childEnv,
|
|
204
|
-
shell: false,
|
|
205
|
-
stdio: ['inherit', 'inherit', 'pipe'],
|
|
206
|
-
windowsHide: true,
|
|
207
|
-
windowsVerbatimArguments: input.windowsVerbatimArguments === true,
|
|
208
|
-
});
|
|
209
|
-
const stop = (signal) => child.kill(signal);
|
|
210
|
-
process.once('SIGINT', () => stop('SIGINT'));
|
|
211
|
-
process.once('SIGTERM', () => stop('SIGTERM'));
|
|
212
|
-
child.once('spawn', () => {
|
|
213
|
-
writeSync(2, input.targetStartedMarker);
|
|
214
|
-
child.stderr.pipe(process.stderr);
|
|
215
|
-
});
|
|
216
|
-
child.once('error', (error) => {
|
|
217
|
-
process.stderr.write((error instanceof Error ? error.message : String(error)) + '\n');
|
|
218
|
-
process.exitCode = 1;
|
|
219
|
-
});
|
|
220
|
-
child.once('exit', (code, signal) => {
|
|
221
|
-
process.exitCode = signal ? 1 : code ?? 1;
|
|
222
|
-
});
|
|
223
|
-
`,xt="eval(Buffer.from(process.argv[1],'base64').toString('utf8'))",kt=JSON.stringify(xt),At=Buffer.from(vt,"utf8").toString("base64"),Et=JSON.stringify(At),Cr=String.raw`
|
|
224
|
-
import { spawn } from 'node:child_process';
|
|
225
|
-
import { randomUUID } from 'node:crypto';
|
|
226
|
-
import { readFile, rm, writeFile } from 'node:fs/promises';
|
|
227
|
-
import { dirname } from 'node:path';
|
|
228
|
-
let SandboxManager;
|
|
229
|
-
const request = JSON.parse(await readFile(process.argv[2], 'utf8'));
|
|
230
|
-
await rm(process.argv[2], { force: true });
|
|
231
|
-
const targetStartedMarker = request.targetStartedMarker
|
|
232
|
-
?? '\u0000KODAX_ASRT_TARGET_STARTED:' + randomUUID() + '\u0000\n';
|
|
233
|
-
const endpoints = new Set(request.endpoints.map((item) => item.host.toLowerCase() + ':' + item.port));
|
|
234
|
-
const callback = request.allowAllNetwork === true
|
|
235
|
-
? async () => true
|
|
236
|
-
: request.endpoints.length === 0
|
|
237
|
-
? undefined
|
|
238
|
-
: async ({ host, port }) => endpoints.has(host.toLowerCase() + ':' + port);
|
|
239
|
-
const withWindowsChildEnvironment = (argv, environment) => {
|
|
240
|
-
const separator = argv.lastIndexOf('--');
|
|
241
|
-
if (separator < 0) throw new Error('ASRT Windows wrapper omitted its child separator.');
|
|
242
|
-
const requested = [];
|
|
243
|
-
const requestedNames = new Set();
|
|
244
|
-
for (const [name, value] of Object.entries(environment ?? {})) {
|
|
245
|
-
if (value === undefined) continue;
|
|
246
|
-
if (!name || name.includes('=') || name.includes('\0') || value.includes('\0')) {
|
|
247
|
-
throw new Error('Invalid environment entry for ASRT Windows child.');
|
|
248
|
-
}
|
|
249
|
-
const normalized = name.toLowerCase();
|
|
250
|
-
if (requestedNames.has(normalized)) {
|
|
251
|
-
throw new Error('Ambiguous Windows child environment variable: ' + name + '.');
|
|
252
|
-
}
|
|
253
|
-
requestedNames.add(normalized);
|
|
254
|
-
requested.push([name, value]);
|
|
255
|
-
}
|
|
256
|
-
const requestedOverrides = new Set(requested.flatMap(([name]) => (
|
|
257
|
-
['path', 'pathext'].includes(name.toLowerCase()) ? [name.toLowerCase()] : []
|
|
258
|
-
)));
|
|
259
|
-
const controlled = new Set();
|
|
260
|
-
const prefix = [];
|
|
261
|
-
for (let index = 0; index < separator; index += 1) {
|
|
262
|
-
if (argv[index] !== '--env' || index + 1 >= separator) {
|
|
263
|
-
prefix.push(argv[index]);
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
const assignment = argv[index + 1];
|
|
267
|
-
const name = assignment.split('=', 1)[0]?.toLowerCase();
|
|
268
|
-
if (name) controlled.add(name);
|
|
269
|
-
if (!name || !requestedOverrides.has(name)) prefix.push(argv[index], assignment);
|
|
270
|
-
index += 1;
|
|
271
|
-
}
|
|
272
|
-
const injected = [];
|
|
273
|
-
for (const [name, value] of requested) {
|
|
274
|
-
const normalized = name.toLowerCase();
|
|
275
|
-
if (controlled.has(normalized) && normalized !== 'path' && normalized !== 'pathext') continue;
|
|
276
|
-
injected.push('--env', name + '=' + value);
|
|
277
|
-
}
|
|
278
|
-
const result = [...prefix, ...injected, ...argv.slice(separator)];
|
|
279
|
-
const estimate = result.reduce((size, value) => size + value.length + 3, 0);
|
|
280
|
-
if (estimate > 30000) throw new Error('ASRT Windows child environment exceeds the CreateProcess command-line limit.');
|
|
281
|
-
return result;
|
|
282
|
-
};
|
|
283
|
-
const writeObservation = async (observation) => {
|
|
284
|
-
if (typeof request.observationFile !== 'string') return;
|
|
285
|
-
await writeFile(request.observationFile, JSON.stringify(observation), { mode: 0o600 });
|
|
286
|
-
};
|
|
287
|
-
const waitForTarget = (target, observation) => {
|
|
288
|
-
const marker = Buffer.from(targetStartedMarker, 'utf8');
|
|
289
|
-
let pending = Buffer.alloc(0);
|
|
290
|
-
let diagnostic = Buffer.alloc(0);
|
|
291
|
-
let processError;
|
|
292
|
-
let wrapperSpawned = false;
|
|
293
|
-
let targetStarted = false;
|
|
294
|
-
let observationWrite = Promise.resolve();
|
|
295
|
-
return new Promise((resolve, reject) => {
|
|
296
|
-
let settled = false;
|
|
297
|
-
target.once('spawn', () => {
|
|
298
|
-
wrapperSpawned = true;
|
|
299
|
-
});
|
|
300
|
-
const finish = (result) => {
|
|
301
|
-
if (settled) return;
|
|
302
|
-
settled = true;
|
|
303
|
-
void observationWrite.then(() => resolve(result), reject);
|
|
304
|
-
};
|
|
305
|
-
target.stderr.on('data', (chunk) => {
|
|
306
|
-
if (targetStarted) {
|
|
307
|
-
process.stderr.write(chunk);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
pending = Buffer.concat([pending, Buffer.from(chunk)]);
|
|
311
|
-
const markerOffset = pending.indexOf(marker);
|
|
312
|
-
if (markerOffset >= 0) {
|
|
313
|
-
targetStarted = true;
|
|
314
|
-
const suffix = pending.subarray(markerOffset + marker.length);
|
|
315
|
-
pending = Buffer.alloc(0);
|
|
316
|
-
diagnostic = Buffer.alloc(0);
|
|
317
|
-
observationWrite = writeObservation(observation).catch(() => undefined);
|
|
318
|
-
if (suffix.length > 0) process.stderr.write(suffix);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const retained = Math.max(0, marker.length - 1);
|
|
322
|
-
if (pending.length > retained) {
|
|
323
|
-
diagnostic = Buffer.concat([
|
|
324
|
-
diagnostic,
|
|
325
|
-
pending.subarray(0, pending.length - retained),
|
|
326
|
-
]).subarray(-65536);
|
|
327
|
-
pending = pending.subarray(pending.length - retained);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
target.once('error', (error) => {
|
|
331
|
-
processError = error instanceof Error ? error.message : String(error);
|
|
332
|
-
});
|
|
333
|
-
target.once('close', (exitCode, signal) => {
|
|
334
|
-
const preTarget = Buffer.concat([diagnostic, pending]).toString('utf8').trim();
|
|
335
|
-
finish({
|
|
336
|
-
exitCode: signal ? 1 : exitCode ?? 1,
|
|
337
|
-
targetStarted,
|
|
338
|
-
spawnFailedBeforeSpawn: processError !== undefined && !wrapperSpawned,
|
|
339
|
-
diagnostic: preTarget || processError || undefined,
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
let child;
|
|
345
|
-
let targetStarted = false;
|
|
346
|
-
let normalFallbackAttempted = false;
|
|
347
|
-
const runDirect = async () => {
|
|
348
|
-
const internalElectronNode = request.command === process.execPath && process.versions.electron !== undefined;
|
|
349
|
-
const directArgs = internalElectronNode
|
|
350
|
-
? ['--import', ${pr}, ...request.args]
|
|
351
|
-
: request.args;
|
|
352
|
-
const directEnv = internalElectronNode
|
|
353
|
-
? { ...request.env, [${En}]: '1' }
|
|
354
|
-
: request.env;
|
|
355
|
-
child = spawn(request.command, directArgs, {
|
|
356
|
-
cwd: request.cwd,
|
|
357
|
-
env: directEnv,
|
|
358
|
-
shell: false,
|
|
359
|
-
stdio: 'inherit',
|
|
360
|
-
windowsHide: true,
|
|
361
|
-
windowsVerbatimArguments: request.windowsVerbatimArguments === true,
|
|
362
|
-
});
|
|
363
|
-
return await new Promise((resolve, reject) => {
|
|
364
|
-
child.once('error', reject);
|
|
365
|
-
child.once('exit', (exitCode, signal) => resolve(signal ? 1 : exitCode ?? 1));
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
const runNormalFallback = async () => {
|
|
369
|
-
if (
|
|
370
|
-
request.fallbackToNormalExecution !== true
|
|
371
|
-
|| targetStarted
|
|
372
|
-
|| normalFallbackAttempted
|
|
373
|
-
) return false;
|
|
374
|
-
await writeObservation({
|
|
375
|
-
version: 1,
|
|
376
|
-
state: 'fallback',
|
|
377
|
-
reason: 'backend_failed',
|
|
378
|
-
execution: 'normal_permission_policy',
|
|
379
|
-
}).catch(() => undefined);
|
|
380
|
-
normalFallbackAttempted = true;
|
|
381
|
-
process.exitCode = await runDirect();
|
|
382
|
-
return true;
|
|
383
|
-
};
|
|
384
|
-
try {
|
|
385
|
-
if (request.wrappedInvocation) {
|
|
386
|
-
const wrapped = request.wrappedInvocation;
|
|
387
|
-
child = spawn(wrapped.executable, wrapped.args, {
|
|
388
|
-
cwd: request.cwd,
|
|
389
|
-
env: wrapped.env,
|
|
390
|
-
shell: wrapped.shell,
|
|
391
|
-
stdio: ['inherit', 'inherit', 'pipe'],
|
|
392
|
-
windowsHide: true,
|
|
393
|
-
});
|
|
394
|
-
const result = await waitForTarget(child, {
|
|
395
|
-
version: 1,
|
|
396
|
-
state: 'applied',
|
|
397
|
-
backend: request.observationBackend ?? 'unsupported',
|
|
398
|
-
policyId: 'kodax-workspace-shell-v1',
|
|
399
|
-
});
|
|
400
|
-
targetStarted = result.targetStarted;
|
|
401
|
-
const fellBack = result.spawnFailedBeforeSpawn
|
|
402
|
-
? await runNormalFallback()
|
|
403
|
-
: false;
|
|
404
|
-
if (!targetStarted && !fellBack) {
|
|
405
|
-
process.stderr.write((result.diagnostic || 'Sandbox target launch could not be attested.') + '\n');
|
|
406
|
-
}
|
|
407
|
-
if (!fellBack) process.exitCode = targetStarted ? result.exitCode : 1;
|
|
408
|
-
} else {
|
|
409
|
-
({ SandboxManager } = await import(process.argv[1]));
|
|
410
|
-
const bootstrap = request.bootstrapCommand ?? 'node';
|
|
411
|
-
const bootstrapIsAbsolute = /^(?:[A-Za-z]:[\\/]|\\\\)/.test(bootstrap);
|
|
412
|
-
const bootstrapIsElectronNode = bootstrap === process.execPath
|
|
413
|
-
&& process.versions.electron !== undefined;
|
|
414
|
-
const config = process.platform === 'win32' && bootstrapIsAbsolute
|
|
415
|
-
? {
|
|
416
|
-
...request.config,
|
|
417
|
-
filesystem: {
|
|
418
|
-
...request.config.filesystem,
|
|
419
|
-
allowRead: [...new Set([
|
|
420
|
-
...request.config.filesystem.allowRead,
|
|
421
|
-
bootstrap,
|
|
422
|
-
dirname(bootstrap),
|
|
423
|
-
])],
|
|
424
|
-
},
|
|
425
|
-
}
|
|
426
|
-
: request.config;
|
|
427
|
-
await SandboxManager.initialize(config, callback);
|
|
428
|
-
const quote = (value) => process.platform === 'win32'
|
|
429
|
-
? '"' + value.replaceAll('"', '""') + '"'
|
|
430
|
-
: "'" + value.replaceAll("'", "'\"'\"'") + "'";
|
|
431
|
-
const internalElectronNode = request.command === process.execPath && process.versions.electron !== undefined;
|
|
432
|
-
const childArgs = internalElectronNode
|
|
433
|
-
? ['--import', ${pr}, ...request.args]
|
|
434
|
-
: request.args;
|
|
435
|
-
const command = [
|
|
436
|
-
quote(bootstrap),
|
|
437
|
-
'-e',
|
|
438
|
-
quote(${kt}),
|
|
439
|
-
${Et},
|
|
440
|
-
Buffer.from(JSON.stringify({
|
|
441
|
-
command: request.command,
|
|
442
|
-
args: childArgs,
|
|
443
|
-
windowsVerbatimArguments: request.windowsVerbatimArguments === true,
|
|
444
|
-
cwd: request.cwd,
|
|
445
|
-
targetStartedMarker,
|
|
446
|
-
electronRunAsNode: internalElectronNode,
|
|
447
|
-
}), 'utf8').toString('base64'),
|
|
448
|
-
].join(' ');
|
|
449
|
-
if (process.platform === 'win32') {
|
|
450
|
-
const wrapped = await SandboxManager.wrapWithSandboxArgv(command, 'cmd', undefined, undefined, request.cwd);
|
|
451
|
-
const requestedEnv = internalElectronNode || bootstrapIsElectronNode
|
|
452
|
-
? { ...request.env, [${En}]: '1' }
|
|
453
|
-
: request.env;
|
|
454
|
-
const childArgv = withWindowsChildEnvironment(wrapped.argv, requestedEnv);
|
|
455
|
-
child = spawn(childArgv[0], childArgv.slice(1), {
|
|
456
|
-
cwd: request.cwd,
|
|
457
|
-
env: wrapped.env,
|
|
458
|
-
shell: false,
|
|
459
|
-
stdio: ['inherit', 'inherit', 'pipe'],
|
|
460
|
-
windowsHide: true,
|
|
461
|
-
});
|
|
462
|
-
} else {
|
|
463
|
-
const wrapped = await SandboxManager.wrapWithSandbox(command);
|
|
464
|
-
const childEnv = internalElectronNode || bootstrapIsElectronNode
|
|
465
|
-
? { ...request.env, [${En}]: '1' }
|
|
466
|
-
: request.env;
|
|
467
|
-
child = spawn(wrapped, {
|
|
468
|
-
cwd: request.cwd,
|
|
469
|
-
env: childEnv,
|
|
470
|
-
shell: true,
|
|
471
|
-
stdio: ['inherit', 'inherit', 'pipe'],
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
const stop = () => child?.kill('SIGTERM');
|
|
475
|
-
process.once('SIGINT', stop);
|
|
476
|
-
process.once('SIGTERM', stop);
|
|
477
|
-
const result = await waitForTarget(child, {
|
|
478
|
-
version: 1,
|
|
479
|
-
state: 'applied',
|
|
480
|
-
backend: request.observationBackend ?? 'unsupported',
|
|
481
|
-
policyId: 'kodax-workspace-shell-v1',
|
|
482
|
-
});
|
|
483
|
-
targetStarted = result.targetStarted;
|
|
484
|
-
try { SandboxManager.cleanupAfterCommand(); } catch {}
|
|
485
|
-
await SandboxManager.reset().catch(() => undefined);
|
|
486
|
-
const fellBack = result.spawnFailedBeforeSpawn
|
|
487
|
-
? await runNormalFallback()
|
|
488
|
-
: false;
|
|
489
|
-
if (!targetStarted && !fellBack) {
|
|
490
|
-
process.stderr.write((result.diagnostic || 'Sandbox target launch could not be attested.') + '\n');
|
|
491
|
-
}
|
|
492
|
-
if (!fellBack) process.exitCode = targetStarted ? result.exitCode : 1;
|
|
493
|
-
}
|
|
494
|
-
} catch (error) {
|
|
495
|
-
await SandboxManager?.reset().catch(() => undefined);
|
|
496
|
-
if (
|
|
497
|
-
request.fallbackToNormalExecution === true
|
|
498
|
-
&& !targetStarted
|
|
499
|
-
&& !normalFallbackAttempted
|
|
500
|
-
&& child === undefined
|
|
501
|
-
) {
|
|
502
|
-
try {
|
|
503
|
-
await runNormalFallback();
|
|
504
|
-
} catch (fallbackError) {
|
|
505
|
-
process.stderr.write((fallbackError instanceof Error ? fallbackError.message : String(fallbackError)) + '\n');
|
|
506
|
-
process.exitCode = 1;
|
|
507
|
-
}
|
|
508
|
-
} else {
|
|
509
|
-
process.stderr.write((error instanceof Error ? error.message : String(error)) + '\n');
|
|
510
|
-
process.exitCode = 1;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
`,be,ze=0,Rt=3e4,Ie,je,_n=!1,de;function le(e){return e instanceof Error?e.message:String(e)}s(le,"errorText");function qe(e,...n){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&n.includes(e.code)}s(qe,"isFileSystemError");async function wr(e){try{return await Ee(e)}catch(n){if(qe(n,"ENOENT"))return;throw n}}s(wr,"readFileIfPresent");async function Pt(e,n){let r=await wr(n);if(r?.equals(e))return;if(r!==void 0)throw new Error(`Prepared Windows sandbox runner failed integrity verification: ${n}.`);let t=`${n}.${process.pid}.${z()}.tmp`;try{await Re(t,e,{flag:"wx",mode:448});try{await st(t,n)}catch(o){if(!(await wr(n))?.equals(e))throw o}}finally{await G(t,{force:!0})}}s(Pt,"installWindowsRunnerCopy");async function tn(){if(Ie===void 0){let e=(async()=>{let n=await Ee(ut()),r=fn("sha256").update(n).digest("hex").slice(0,16),t=i.join(i.resolve(q()),"sandbox-runtime","runner",ce,process.arch,r),o=i.join(t,"srt-win.exe");await X(gn(),{recursive:!0,mode:448}),await X(t,{recursive:!0,mode:448}),await Pt(n,o);let a={path:o,directory:t,srtWin:wt({path:o})};return je=a,a})();Ie=e,e.catch(()=>{Ie===e&&(Ie=void 0,je=void 0)})}return Ie}s(tn,"prepareWindowsSandboxRunner");function Pe(){if(process.platform!=="win32")throw new Error("A prepared Windows sandbox runner was requested on a non-Windows platform.");if(je===void 0)throw new Error("Windows sandbox runner is not prepared; run the sandbox readiness check first.");return je}s(Pe,"requirePreparedWindowsRunner");var O=new Set,K=new Map,Rn,te=35e3,fe="[acl_cleanup_unconfirmed]",J=class extends Error{static{s(this,"WindowsSandboxAclAdmissionError")}constructor(n,r){super(n,r),this.name="WindowsSandboxAclAdmissionError"}};function wn(e){return e.diagnostics.some(n=>n.startsWith(fe))}s(wn,"doctorHasWindowsSandboxAclCleanupBlock");function mn(){let e=Object.entries(process.env).find(([n,r])=>n.toUpperCase()==="PROGRAMDATA"&&r!==void 0)?.[1]??"C:\\ProgramData";return i.join(i.resolve(e),"KodaX","sandbox-runtime","acl-poison")}s(mn,"windowsSandboxAclPoisonDirectory");function gn(){return i.dirname(mn())}s(gn,"windowsSandboxAclCoordinationDirectory");function Un(e=q()){return i.join(i.resolve(e),"sandbox-runtime","acl-poison")}s(Un,"legacyWindowsSandboxAclPoisonDirectory");function Ct(){return i.join(gn(),"acl-poison-staging")}s(Ct,"windowsSandboxAclPoisonStagingDirectory");function Wt(e=q()){return i.join(i.resolve(e),"sandbox-runtime","acl-poison-staging")}s(Wt,"legacyWindowsSandboxAclPoisonStagingDirectory");function oe(){return i.join(gn(),"acl-recovery.lock")}s(oe,"windowsSandboxAclRecoveryLockFile");function Wr(e){let n=JSON.parse(e);if(typeof n!="object"||n===null)throw new Error("Windows sandbox ACL poison marker is not an object.");let r=n;if(r.version!==1&&r.version!==2||r.state!==void 0&&r.state!=="active"&&r.state!=="unconfirmed"||r.policyKey!==void 0&&typeof r.policyKey!="string"||r.holderPid!==void 0&&(typeof r.holderPid!="number"||!Number.isSafeInteger(r.holderPid)||r.holderPid<=0)||r.holderProcessStartIdentity!==void 0&&typeof r.holderProcessStartIdentity!="string"||r.pid!==void 0&&(typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0)||r.processStartIdentity!==void 0&&typeof r.processStartIdentity!="string"||r.windowsBootIdentity!==void 0&&typeof r.windowsBootIdentity!="string")throw new Error("Windows sandbox ACL poison marker has an invalid owner identity.");return{version:r.version,...r.state==="active"||r.state==="unconfirmed"?{state:r.state}:{},...typeof r.policyKey=="string"?{policyKey:r.policyKey}:{},...typeof r.holderPid=="number"?{holderPid:r.holderPid}:{},...typeof r.holderProcessStartIdentity=="string"?{holderProcessStartIdentity:r.holderProcessStartIdentity}:{},...typeof r.pid=="number"?{pid:r.pid}:{},...typeof r.processStartIdentity=="string"?{processStartIdentity:r.processStartIdentity}:{},...typeof r.windowsBootIdentity=="string"?{windowsBootIdentity:r.windowsBootIdentity}:{}}}s(Wr,"parseWindowsSandboxAclPoisonOwner");function we(e=q()){return[...new Set([mn(),Un(e)])].flatMap(r=>{let t;try{t=jn(r)}catch(o){if(qe(o,"ENOENT"))return[];throw o}return t.filter(o=>o.endsWith(".json")).map(o=>{let a=i.join(r,o);try{let c=Mn(a);if(!c.isFile()||c.isSymbolicLink())throw new Error("Windows sandbox ACL poison marker is not a regular file.");let d=Wr(xr(a,"utf8"));return{file:a,owner:i.basename(a).startsWith("unconfirmed-")?{...d,state:"unconfirmed"}:d}}catch(c){throw new J(`Windows sandbox ACL cleanup was not confirmed because its poison marker is unreadable: ${a}. `+On(),{cause:c})}})})}s(we,"readWindowsSandboxAclPoisonOwners");function me(){if(process.platform!=="win32")return;if(Rn!==void 0)return Rn??void 0;let e=String.raw`
|
|
514
|
-
# KodaXWindowsBootIdentity-v1
|
|
515
|
-
$boot = (Get-CimInstance Win32_OperatingSystem -ErrorAction Stop).LastBootUpTime
|
|
516
|
-
[Console]::Out.Write($boot.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture))
|
|
517
|
-
`,n=Je(Gr(),["-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from(e,"utf16le").toString("base64")],{encoding:"utf8",timeout:5e3,windowsHide:!0}),r=n.status===0?n.stdout.trim():"",t=/^\d+$/.test(r)?`windows-boot-${r}`:void 0;return Rn=t??null,t}s(me,"readWindowsBootIdentity");function Go(){return me()}s(Go,"readWindowsSandboxBootIdentity");function On(){return`After stopping every KodaX and KodaX Space process, run "${je?.path??"srt-win.exe"}" acl recover --force --json, then delete "${mn()}" and "${Un()}".`}s(On,"windowsSandboxAclManualRecoveryInstruction");function $r(e,n=me()){if(e.find(({windowsBootIdentity:a})=>a===void 0||n===void 0)!==void 0)return new J("An unconfirmed Windows sandbox process tree has no verifiable Windows boot identity. "+On());let t=e[0],o=t?.pid===void 0?"":` (last root PID ${t.pid})`;return new J(`An unconfirmed Windows sandbox process tree${o} from the same Windows boot may still have live descendants; restart Windows before retrying. `+On())}s($r,"persistentWindowsSandboxAclPoisonError");function Nn(e,n,r="unconfirmed",t){if(process.platform!=="win32")return;let o=me(),a=Ne(process.pid),c=z(),d=`${r==="unconfirmed"?"unconfirmed-":""}owner-${c}.json`,l=JSON.stringify({version:1,state:r,...t===void 0?{}:{policyKey:t},holderPid:process.pid,...a===void 0?{}:{holderProcessStartIdentity:a},...e===void 0?{}:{pid:e},...n===void 0?{}:{processStartIdentity:n},...o===void 0?{}:{windowsBootIdentity:o}}),u=s((f,p)=>{lr(f,{recursive:!0,mode:448});let w=i.join(f,d);if(r==="unconfirmed")return ur(w,l,{flag:"wx",mode:384}),w;lr(p,{recursive:!0,mode:448});let h=i.join(p,`owner-${c}.tmp`);return ur(h,l,{flag:"wx",mode:384}),$n(h,w),w},"persist"),g=u(mn(),Ct());try{let f=u(Un(),Wt());K.set(g,f)}catch(f){if(r==="active")try{Ae(g,{force:!0})}catch(p){throw new AggregateError([f,p],"Windows sandbox owner compatibility marker and primary rollback both failed.")}throw f}return g}s(Nn,"persistWindowsSandboxAclPoisonOwner");function $t(e){let n=Nn(void 0,void 0,"active",e);if(n!==void 0){O.add(n);let r=K.get(n);r!==void 0&&O.add(r)}return n}s($t,"createWindowsSandboxAclOwnerMarker");function Le(e){if(e===void 0)return;let n=K.get(e);try{n!==void 0&&Ae(n,{force:!0}),Ae(e,{force:!0}),O.delete(e),n!==void 0&&O.delete(n),K.delete(e)}catch(r){throw O.delete(e),n!==void 0&&O.delete(n),pe(r),new Error("Windows sandbox owner poison marker could not be cleared.",{cause:r})}}s(Le,"confirmWindowsSandboxAclOwnerStopped");async function Ye(e,n){pe(n);let r=await Vn(e,void 0,void 0,n);if(pe(r),r!==n)throw r}s(Ye,"retainWindowsSandboxAclOwnerPoison");function Tr(e,n,r){if(e===void 0)return Nn(n,r,"unconfirmed");let t=K.get(e),o=i.join(i.dirname(e),`unconfirmed-${i.basename(e)}`),a=t===void 0?void 0:i.join(i.dirname(t),`unconfirmed-${i.basename(t)}`);if(vr(o))return O.delete(e),t!==void 0&&O.delete(t),a!==void 0&&K.set(o,a),K.delete(e),o;try{return $n(e,o),t!==void 0&&a!==void 0&&$n(t,a),O.delete(e),t!==void 0&&O.delete(t),a!==void 0&&K.set(o,a),K.delete(e),o}catch(c){try{let d=Nn(n,r,"unconfirmed");return O.delete(e),t!==void 0&&O.delete(t),K.delete(e),d}catch(d){throw O.delete(e),t!==void 0&&O.delete(t),K.delete(e),new AggregateError([c,d],"Windows sandbox ACL poison write-ahead failed.")}}}s(Tr,"writeAheadWindowsSandboxAclOwnerPoison");async function Vn(e,n,r,t){if(process.platform!=="win32")return t;let o;try{return o=Tr(e,n,r),await Z(oe(),async()=>{},te),t}catch(a){return new AggregateError([t,a],o===void 0?"Windows sandbox owner termination and durable ACL poison recording both failed.":"Windows sandbox owner termination was not confirmed and ACL poison serialization failed.")}}s(Vn,"transitionWindowsSandboxAclOwnerToPoison");function Tt(e,n){return O.has(e)}s(Tt,"isVerifiedActiveWindowsSandboxAclOwner");function Hn(e){if(e.state!=="active"||e.holderPid===void 0||e.holderProcessStartIdentity===void 0)return"stale";let n=Ne(e.holderPid);if(n!==void 0)return n===e.holderProcessStartIdentity?"live":"stale";try{return process.kill(e.holderPid,0),"unknown"}catch(r){return qe(r,"ESRCH")?"stale":"unknown"}}s(Hn,"windowsSandboxAclOwnerLiveness");function zn(e,n,r){return n.state!=="active"?!1:O.has(e)?r===void 0||n.policyKey===r:r!==void 0&&n.policyKey===r&&Hn(n)==="live"}s(zn,"isCompatibleWindowsSandboxAclOwner");function Yn(e){let n=we().filter(({file:r,owner:t})=>!zn(r,t,e));if(n.length!==0)throw $r(n.map(({owner:r})=>r))}s(Yn,"assertNoPersistentWindowsSandboxAclPoison");async function _r(e,n,r,t){let o=new Error(r);if(process.platform==="win32"){let a=await Vn(t,e,n,o);return pe(a),a instanceof Error?a:o}return pe(o),o}s(_r,"recordUnconfirmedWindowsSandboxOwner");function Or(e){return process.platform==="win32"?`${e} process-tree termination was not confirmed; restart Windows before retrying.`:`${e} process-tree termination was not confirmed; stop the retained process tree before retrying.`}s(Or,"unconfirmedSandboxProcessTreeMessage");function Ke(e=3e4){let n=Pe(),r=Je(n.srtWin.exe,[...n.srtWin.prependArgs,"acl","recover","--json"],{cwd:n.directory,encoding:"utf8",timeout:Math.max(1,Math.min(3e4,e)),windowsHide:!0}),t=(r.stderr??"").trim();if(r.error)throw new Error(`Windows sandbox ACL recovery failed to start: ${r.error.message}`,{cause:r.error});let o;try{o=JSON.parse((r.stdout??"").trim())}catch(c){throw new Error(`Windows sandbox ACL recovery failed with unparseable output (exit ${String(r.status)}): ${t||"(empty stderr)"}.`,{cause:c})}let a=typeof o=="object"&&o!==null?o:void 0;if(r.status!==0||typeof a?.deadBrokers!="number"||!Number.isSafeInteger(a.deadBrokers)||a.deadBrokers<0||typeof a.acesRevoked!="number"||!Number.isSafeInteger(a.acesRevoked)||a.acesRevoked<0)throw new Error(`Windows sandbox ACL recovery failed (exit ${String(r.status)}${r.signal?`, signal ${r.signal}`:""}): ${t||"(empty stderr)"}.`);_n=!0}s(Ke,"recoverWindowsSandboxAcls");async function Jo(e,n,r,t=7e4){if(process.platform!=="win32")return 0;if(n.processStartIdentity===void 0)throw new Error("Windows sandbox ACL recovery requires an exact daemon process identity.");let o=Date.now()+t;return Z(oe(),async()=>{let a=we(e),c=a.filter(({owner:l})=>l.holderPid===n.pid&&l.holderProcessStartIdentity===n.processStartIdentity&&l.windowsBootIdentity===r);if(c.length!==a.length)throw new J("Windows sandbox ACL recovery found a foreign or unverifiable owner marker.");if(c.length===0)return 0;await _t(tn(),Math.max(1,o-Date.now()));let d=o-Date.now();if(d<=0)throw new Error("Windows sandbox ACL recovery deadline expired before mutation.");return Ke(d),c.length},Math.max(1,Math.min(te,t)))}s(Jo,"recoverWindowsSandboxAclsForRuntimeOwner");async function _t(e,n){let r,t=new Promise((o,a)=>{r=setTimeout(()=>a(new Error("Windows sandbox runner preparation timed out.")),n)});try{return await Promise.race([e,t])}finally{r!==void 0&&clearTimeout(r)}}s(_t,"waitForWindowsSandboxRunnerPreparation");async function Uo(e,n,r,t=4e4){if(process.platform!=="win32")return 0;if(n.processStartIdentity===void 0)throw new Error("Windows sandbox marker cleanup requires an exact daemon process identity.");return Z(oe(),async()=>{let o=we(e),a=o.filter(({owner:c})=>c.holderPid===n.pid&&c.holderProcessStartIdentity===n.processStartIdentity&&c.windowsBootIdentity===r);if(a.length!==o.length)throw new J("Windows sandbox marker cleanup found a foreign or unverifiable owner marker.");for(let c of a)Ae(c.file,{force:!0});return a.length},Math.max(1,Math.min(te,t)))}s(Uo,"clearWindowsSandboxAclMarkersForRuntimeOwner");function Ot(e){return e instanceof Error&&e.message.startsWith("learning store lock timed out:")}s(Ot,"isWindowsSandboxAclRecoveryLockTimeout");var on=class extends J{static{s(this,"ForeignWindowsSandboxAclOwnerContentionError")}constructor(n){super("Another Windows sandbox owner is active for the shared sandbox account; wait for it to close or stop the other KodaX/KodaX Space process, then retry.",{cause:n}),this.name="ForeignWindowsSandboxAclOwnerContentionError"}},sn=class extends J{static{s(this,"StaleWindowsSandboxAclOwnerContentionError")}constructor(n){super(n.message,{cause:n}),this.name="StaleWindowsSandboxAclOwnerContentionError"}};function Nr(e){!Ot(e)&&!(e instanceof on)&&!(e instanceof sn)&&pe(e)}s(Nr,"recordWindowsSandboxAclAdmissionFailure");function Xe(e,n=me()){let r=$r(e.map(({owner:t})=>t),n);return e.every(({owner:t})=>t.state==="active")?e.some(({owner:t})=>Hn(t)==="stale")?new sn(r):new on(r):r}s(Xe,"windowsSandboxAclPoisonSnapshotError");function Nt(){let e=we();if(e.length===0)return;let n=me();if(n!==void 0&&e.every(({owner:t})=>t.windowsBootIdentity!==void 0&&t.windowsBootIdentity!==n)){Ke();for(let t of e)Ae(t.file,{force:!0});Yn();return}return e.every(({owner:t})=>Hn(t)!=="stale")?new J("Windows sandbox setup cannot run while a sandbox owner is active for the shared Windows sandbox account; wait for sandboxed commands to finish and stop other KodaX or KodaX Space processes, then retry."):Xe(e,n)}s(Nt,"windowsSandboxAclSetupBlockWithLock");function mr(e,n){return{...e,ready:!1,diagnostics:[...e.diagnostics.filter(r=>!r.startsWith(fe)),`${fe} ${n.message}`]}}s(mr,"withWindowsSandboxAclSetupBlock");function Ir(e){Sn();let n=we(),r=n.filter(({file:t,owner:o})=>!zn(t,o,e));if(_n){if(r.length>0)throw Xe(r);return}if(r.length>0){let t=me();if(!(t!==void 0&&r.every(({owner:a})=>a.windowsBootIdentity!==void 0&&a.windowsBootIdentity!==t)))throw Xe(r,t)}if(n.length>0){_n=!0;return}Ke();for(let t of r)Ae(t.file,{force:!0});Yn(e)}s(Ir,"ensureWindowsSandboxAclRecoveryWithLock");async function an(e){if(process.platform==="win32")try{await Z(oe(),async()=>Ir(e),te)}catch(n){throw Nr(n),n}}s(an,"ensureWindowsSandboxAclRecovery");async function Lr(e){if(process.platform!=="win32")return;let n;try{return await Z(oe(),async()=>{try{Ir(e)}catch(r){throw Nr(r),r}return n=$t(e),n},te)}catch(r){if(n===void 0)throw r;try{Le(n)}catch(t){throw new AggregateError([r,t],"Windows sandbox owner admission and marker cleanup both failed.")}throw r}}s(Lr,"admitWindowsSandboxAclOwner");async function In(e){if(process.platform!=="win32")return;let n;try{if(e===void 0||!O.has(e))return;if(n=Wr(xr(e,"utf8")).policyKey,n!==void 0){await Z(oe(),async()=>{let t=K.get(e),o=new Set([e,t].filter(d=>d!==void 0)),a=we().filter(({file:d})=>!o.has(d)),c=a.filter(({file:d,owner:l})=>!zn(d,l,n));if(c.length>0)throw Xe(c);if(a.length>0){Le(e);return}Ke(),Le(e)},te);return}let r=Tr(e,void 0,void 0);await Z(oe(),async()=>{Ke(),Le(r),e!==r&&Le(e)},te)}catch(r){let t=n===void 0?r:await Vn(e,void 0,void 0,r);throw pe(t),t}}s(In,"confirmWindowsSandboxAclRecovery");function Pn(){de!==void 0&&(Er({sandboxUserSid:de.sandboxUserSid,holderPid:process.pid,srtWin:de.runner.srtWin}),de=void 0)}s(Pn,"releasePreparedWindowsRunnerGrant");function It(e,n){if(!(de?.runner.path===e.path&&de.sandboxUserSid===n)){process.removeListener("exit",Pn),Pn();try{ft({read:[e.directory,e.path],write:[],sandboxUserSid:n,holderPid:process.pid,srtWin:e.srtWin})}catch(r){try{Er({sandboxUserSid:n,holderPid:process.pid,srtWin:e.srtWin})}catch(t){throw new AggregateError([r,t],"Windows sandbox runner ACL grant failed and its partial grant could not be revoked.")}throw r}de={runner:e,sandboxUserSid:n},process.once("exit",Pn)}}s(It,"retainPreparedWindowsRunnerGrant");async function Lt(){let[e,n]=lt;for(let r=0;r<5;r+=1){let t=dt();t.listen(0,"127.0.0.1"),await cr(t,"listening");let o=t.address();if(typeof o=="object"&&o!==null&&(o.port<e||o.port>n))return{server:t,target:`127.0.0.1:${o.port}`};let a=cr(t,"close");t.close(),await a}throw new Error(`[wfp_probe_bind_failed] Could not bind a loopback listener outside the Windows sandbox proxy range [${e},${n}].`)}s(Lt,"bindWindowsWfpProbe");function gr(e){return/0x80070005|access (?:is )?denied|拒绝访问/i.test(e)?"runner_launch_access_denied":/seclogon|secondary logon/i.test(e)?"secondary_logon_unavailable":"wfp_probe_failed"}s(gr,"windowsRunnerFailureCode");function Dt(e){return qe(e,"ETIMEDOUT")?"wfp_probe_timeout":qe(e,"EACCES","EPERM")?"runner_launch_access_denied":"runner_spawn_failed"}s(Dt,"windowsRunnerSpawnFailureCode");async function Bt(e){let{server:n,target:r}=await Lt();try{let t=Je(e.srtWin.exe,[...e.srtWin.prependArgs,"wfp","verify","--target",r],{cwd:e.directory,encoding:"utf8",timeout:3e4,windowsHide:!0}),o=(t.stderr??"").trim();if(t.error)throw new Error(`[${Dt(t.error)}] Windows sandbox runner failed to start: ${t.error.message}`);let a;try{a=JSON.parse((t.stdout??"").trim())}catch{let c=t.status===null?"wfp_probe_timeout":gr(o);throw new Error(`[${c}] Windows sandbox WFP probe exited ${String(t.status)}${t.signal?` (signal ${t.signal})`:""} with unparseable output; stderr: ${o||"(empty)"}.`)}if(t.status===3)throw new Error(`[wfp_fence_inactive] Direct outbound access to ${String(a.target??r)} succeeded. Run "kodax sandbox setup" to reinstall the Windows network policy.`);if(t.status!==0||a.egress_probe!=="blocked")throw new Error(`[${gr(o)}] Windows sandbox WFP probe to ${String(a.target??r)} was ${String(a.egress_probe)} (exit ${String(t.status)}): ${o||"(empty stderr)"}.`)}finally{n.close()}}s(Bt,"verifyPreparedWindowsWfp");function Dr(e){let n=[];return e.provisioned||n.push("Windows sandbox account does not exist."),e.sid||n.push("Windows sandbox account SID is unavailable."),(!e.groupExists||!e.groupSid)&&n.push("Windows sandbox local group is unavailable."),e.inBuiltinUsers||n.push("Windows sandbox account is not in the built-in Users group."),e.inSandboxGroup||n.push("Windows sandbox account is not in the sandbox-runtime-users group."),e.hiddenFromLogon||n.push("Windows sandbox account is not hidden from interactive logon."),e.credPresent||n.push("Windows sandbox account credential is unavailable."),n}s(Dr,"windowsSandboxAccountDiagnostics");function Ft(e){let n=JSON.parse(e);if(typeof n!="object"||n===null)return;let r=n;if(r.version===1&&(r.state==="applied"&&r.policyId==="kodax-workspace-shell-v1"&&(r.backend==="windows-restricted-user"||r.backend==="macos-seatbelt"||r.backend==="linux-bubblewrap"||r.backend==="unsupported")||r.state==="fallback"&&r.reason==="backend_failed"&&r.execution==="normal_permission_policy"))return r}s(Ft,"parseBrokerObservation");function yn(){return process.env.KODAX_A2A_NODE!==void 0?process.env.KODAX_A2A_NODE:process.versions.electron!==void 0?process.execPath:process.env.KODAX_BUNDLED==="true"?"node":process.execPath}s(yn,"sandboxJavaScriptCommand");async function Q(e={}){if(e.refresh||be===void 0||Date.now()>=ze){let n=Mt();be=n,ze=Number.POSITIVE_INFINITY,n.then(r=>{be===n&&(ze=r.ready?Number.POSITIVE_INFINITY:Date.now()+Rt)},()=>{be===n&&(be=void 0,ze=0)})}return be}s(Q,"doctorSandboxRuntime");async function Mt(){let e=[],n=!1;An.isSupportedPlatform()||e.push(`Unsupported platform: ${process.platform}.`);let r=process.platform==="win32"?{errors:[],warnings:[]}:An.checkDependencies();e.push(...r.warnings,...r.errors);let t=r.errors.length>0;if(process.env.KODAX_BUNDLED!=="true")try{let d=JSON.parse(await Ee(Gn.resolve("@anthropic-ai/sandbox-runtime/package.json"),"utf8"));d.version!==ce&&(t=!0,e.push(`ASRT package version mismatch: expected ${ce}, found ${String(d.version)}.`))}catch(d){t=!0,e.push(`ASRT package provenance check failed: ${le(d)}`)}let o=yn(),a=Oe({args:["--version"],env:Ce(),isElectron:o===process.execPath&&process.versions.electron!==void 0}),c=Je(o,a.args,{env:a.env,shell:!1,encoding:"utf8",windowsHide:!0,timeout:5e3});if(c.status!==0){t=!0;let d=c.error?.message??(c.stderr.trim()||o);e.push(`JavaScript Skill interpreter is unavailable: ${d}.`)}if(process.platform==="win32"){try{let d=await tn(),l=qn({srtWin:d.srtWin}),u=Dr(l);if(u.length>0||!l.sid)t=!0,e.push(...u);else{It(d,l.sid);let g=Xr(dn(),l.sid,l.groupSid,!1,"read");g.length>0&&(t=!0,e.push(`[acl_guards_missing] ${g.length} persistent Windows sandbox ACL guard(s) are missing. Run "kodax sandbox setup" once to install them outside the startup path.`)),await Bt(d)}}catch(d){t=!0,e.push(le(d))}try{let d=we().filter(({file:l,owner:u})=>!Tt(l,u));if(d.length>0){let l=me();l!==void 0&&d.every(({owner:g})=>g.windowsBootIdentity!==void 0&&g.windowsBootIdentity!==l)||(n=!0,e.push(`${fe} `+Xe(d,l).message))}}catch(d){n=!0,e.push(`${fe} ${le(d)}`)}}return{ready:An.isSupportedPlatform()&&!t&&!n,platform:process.platform,version:ce,diagnostics:e,setupRequired:t}}s(Mt,"inspectSandboxRuntime");async function jt(){let e=await Q({refresh:!0});try{let t=Nt();if(t!==void 0)return mr(e,t)}catch(t){let o=t instanceof Error?t:new Error(String(t));return mr(e,o)}if(e.ready||wn(e)||!e.setupRequired)return e;let n=!1;try{let t=await tn(),o=qn({srtWin:t.srtWin});n=Dr(o).length===0&&o.sid!==void 0}catch{n=!1}if(n){Dn(dn(),"read");let t=await Q({refresh:!0});if(t.ready)return t}if(pt().cancelled)throw new Error("Sandbox setup was cancelled.");return await tn(),Dn(dn(),"read"),Q({refresh:!0})}s(jt,"setupWindowsSandboxRuntimeWithLock");async function qt(){return process.platform!=="win32"?Q({refresh:!0}):Z(oe(),jt,te)}s(qt,"setupSandboxRuntime");function ve(e){if(e.ready)return[`KodaX sandbox is active (${e.platform}, ASRT ${e.version}).`];if(e.platform==="win32"){let n=e.diagnostics.find(r=>r.startsWith(fe));return n!==void 0?[n.slice(fe.length).trim()]:['Run "kodax sandbox setup". Windows will show a UAC prompt for the one-time sandbox account and network policy setup.',"The terminal itself does not need to be started as Administrator; approve the UAC prompt when it appears."]}return e.platform==="darwin"?['KodaX uses macOS Seatbelt through sandbox-exec. Install the missing dependency, then rerun "kodax sandbox doctor".',"Homebrew: brew install ripgrep"]:e.platform==="linux"?['KodaX uses bubblewrap on Linux. Install bubblewrap, socat, and ripgrep, then rerun "kodax sandbox doctor".',"Debian/Ubuntu: sudo apt install bubblewrap socat ripgrep","Fedora/RHEL: sudo dnf install bubblewrap socat ripgrep","Arch Linux: sudo pacman -S bubblewrap socat ripgrep"]:[`KodaX sandbox is not supported on ${e.platform}.`]}s(ve,"sandboxSetupGuidance");async function Vo(e={}){let n=await Q({refresh:!0});if(n.ready)return{status:"ready",attempted:!1,doctor:n,guidance:ve(n)};if(wn(n))return{status:"unavailable",attempted:!1,doctor:n,guidance:ve(n)};if(!n.setupRequired)return{status:"unavailable",attempted:!1,doctor:n,guidance:ve(n)};if(n.platform!=="win32"||e.allowElevation===!1)return{status:"unavailable",attempted:!1,doctor:n,guidance:ve(n)};try{let r=await qt();return{status:r.ready?"ready":"unavailable",attempted:!0,doctor:r,guidance:ve(r)}}catch(r){let t=await Q({refresh:!0}),o=le(r);return{status:/cancelled/i.test(o)?"cancelled":"unavailable",attempted:!0,doctor:t,guidance:ve(t),error:o}}}s(Vo,"prepareSandboxRuntimeForSetup");function se(e,n){let r=e.replaceAll("\\","/").replace(/^\.\//,"");if(!r||i.posix.isAbsolute(r)||r.split("/").includes(".."))throw new Error(`${n} must be a safe relative path.`);return r}s(se,"canonicalRelative");function _(e,n){let r=i.relative(e,n);return r===""||!r.startsWith("..")&&!i.isAbsolute(r)}s(_,"isInside");function Br(e){let n=e.split(i.sep).map(r=>r.toLowerCase());return n.some(r=>gt.has(r))||n.some(r=>yt.has(r)||r.startsWith(".env."))}s(Br,"isSensitiveRelative");async function Kt(e,n){await X(n,{recursive:!0,mode:448});let r=[...(e.scripts??[]).map(t=>({folder:"scripts",file:t})),...(e.references??[]).map(t=>({folder:"references",file:t})),...(e.assets??[]).map(t=>({folder:"assets",file:t})),...(e.templates??[]).map(t=>({folder:"templates",file:t})),...(e.resources??[]).map(t=>({folder:"resources",file:t}))];await Re(i.join(n,"SKILL.md"),await Ee(e.skillFilePath),{mode:384});for(let{folder:t,file:o}of r){let a=se(o.relativePath,`Skill ${e.name} support file`),c=i.join(n,t,...a.split("/"));await X(i.dirname(c),{recursive:!0,mode:448}),await Re(c,await Ee(o.path),{mode:384})}}s(Kt,"copySkillSnapshot");async function Xt(e,n){let r=new Map;for(let[t,o]of Object.entries(e.admissions)){let a=await e.registry.loadFull(t),c=new Map((a.scripts??[]).map(l=>[`scripts/${se(l.relativePath,`Skill ${t} script`)}`,l])),d=i.join(n,t.replace(/[^A-Za-z0-9._-]/g,"_"));await Kt(a,d);for(let l of o){let u=se(l,`toolPolicy.skillScripts.${t}`);if(!c.has(u))throw new Error(`Skill "${t}" has no script "${u}".`);r.set(`${t}\0${u}`,{skill:t,relativePath:u,snapshotPath:i.join(d,...u.split("/"))})}}return r}s(Xt,"snapshotAdmissions");function Gt(e){return e.mode==="deny"?[]:e.origins.map(n=>{let r=new URL(n);return{host:r.hostname.toLowerCase(),port:r.port?Number(r.port):r.protocol==="https:"?443:80}})}s(Gt,"networkEndpoints");function Ce(){let e=["PATH","Path","PATHEXT","SystemRoot","COMSPEC","TEMP","TMP","HOME","USERPROFILE","LOCALAPPDATA","LANG"],n={NO_COLOR:"1"};for(let r of e)process.env[r]!==void 0&&(n[r]=process.env[r]);for(let[r,t]of Object.entries(process.env))r.startsWith("LC_")&&t!==void 0&&(n[r]=t);return Zn(n)}s(Ce,"sanitizedEnvironment");function Zn(e){if(process.platform!=="win32")return{...e};let n=new Map;for(let[r,t]of Object.entries(e))t!==void 0&&n.set(r.toLowerCase(),[r,t]);return Object.fromEntries(n.values())}s(Zn,"normalizedSandboxEnvironment");function Fr(e,n){return Zn({...e,...n})}s(Fr,"mergeSandboxEnvironment");function Jt(e){let n=i.extname(e).toLowerCase();if([".js",".mjs",".cjs"].includes(n))return{command:process.env.KODAX_A2A_NODE??(process.env.KODAX_BUNDLED==="true"?"node":process.execPath),args:[e]};if(n===".py")return{command:process.env.KODAX_A2A_PYTHON??(process.platform==="win32"?"python.exe":"python3"),args:[e]};if(n===".ps1")return{command:process.env.KODAX_A2A_POWERSHELL??(process.platform==="win32"?i.join(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"):"pwsh"),args:["-NoProfile","-NonInteractive","-File",e]};if(n===".sh"&&process.platform!=="win32")return{command:"/bin/sh",args:[e]};if([".cmd",".bat"].includes(n)&&process.platform==="win32")return{command:process.env.COMSPEC??i.join(process.env.SystemRoot??"C:\\Windows","System32","cmd.exe"),args:["/d","/s","/c",e]};throw new Error(`Unsupported admitted Skill script type: ${n||"<none>"}.`)}s(Jt,"interpreterFor");var yr=250,Ut=1500;async function Vt(e,n,r=Xn,t=Kn,o){let a=[],c=[],d=e.pid===void 0?void 0:Ne(e.pid),l=0,u,g=s(()=>{},"reportStopRequested"),f,p,w=new Promise(S=>{g=S}),h=s(S=>{if(u!==void 0)return;u=S,g();let A=!1,E,L;f=new Promise((R,M)=>{E=R,L=M}),f.catch(()=>{});let P=s(async R=>{let M=await _r(e.pid,d,Or("Sandbox broker"),o);return R===void 0?M:new AggregateError([M,R],"Sandbox broker termination failed and its process tree may still be alive.")},"unconfirmedTermination"),Y=s(R=>{A||(A=!0,p!==void 0&&clearTimeout(p),R===void 0?E():L(R))},"finish");p=setTimeout(()=>{try{e.kill("SIGKILL"),P().then(Y)}catch(R){P(R).then(Y)}},Ut),xn(e,{expectedProcessStartIdentity:d,forceMs:yr,taskkillMs:yr}).then(async R=>Y(R.status==="unknown"?await P():void 0),async R=>Y(await P(R)))},"requestStop"),k=s((S,A)=>{l+=A.byteLength,l>t?h(new Error(`Sandboxed command output exceeded ${t} bytes.`)):S.push(A)},"append");e.stdout?.on("data",S=>{k(a,S)}),e.stderr?.on("data",S=>{k(c,S)});let b=setTimeout(()=>{h(new Error(`Sandboxed command exceeded its ${r} ms timeout.`))},r),v=s(()=>{let S=n?.reason;h(S instanceof Error?S:new Error("Sandboxed command was cancelled."))},"abort");n?.addEventListener("abort",v,{once:!0}),n?.aborted&&v();try{let S=new Promise((E,L)=>{e.once("error",L),e.once("close",P=>E(P??1))}),A=await Promise.race([S,w.then(()=>1)]);if(u!==void 0)throw await f,u;return{exitCode:A,stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(c).toString("utf8")}}finally{clearTimeout(b),p!==void 0&&clearTimeout(p),n?.removeEventListener("abort",v)}}s(Vt,"collectProcess");async function Mr(e,n,r=Xn,t=Kn){let o=process.platform==="win32"?await bn():ie.tmpdir(),a=i.join(o,`kodax-asrt-${process.pid}-${z()}.json`),c=process.platform==="win32"?rr(e.config):{...e.config,filesystem:{...e.config.filesystem,denyRead:[...e.config.filesystem.denyRead,a]}},d={...e,bootstrapCommand:e.bootstrapCommand??yn(),config:c};await Re(a,JSON.stringify(d),{mode:384});let l,u,g;try{if(process.platform==="win32"){await tr(),g=await kn();let h=await or(!0);if(h.length===1)throw h[0];if(h.length>1)throw new AggregateError(h,"Cached workspace sandbox reset was not confirmed before standalone execution.")}let f=process.env.KODAX_BUNDLED==="true"?["__asrt-broker",a]:["--input-type=module","-e",Cr,Rr,a],p=Oe({args:f,env:Ce(),isElectron:process.versions.electron!==void 0});u=await Lr();let w=br(process.execPath,p.args,{cwd:process.platform==="win32"?Pe().directory:void 0,env:p.env,shell:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0,detached:process.platform!=="win32"});return vn(w),await Vt(w,n,r,t,u)}catch(f){throw l=f,f}finally{let f=[];try{await G(a,{force:!0})}catch(p){f.push(p)}try{await In(u)}catch(p){f.push(p)}if(g!==void 0)try{await g()}catch(p){f.push(p)}if(f.length>0)throw l!==void 0&&f.unshift(l),f.length===1?f[0]:new AggregateError(f,"Sandbox broker cleanup was not confirmed.")}}s(Mr,"runBrokerResult");async function Ht(e,n){let r=await Mr(e,n);if(r.exitCode!==0){let t=r.stderr.trim()||r.stdout.trim();throw new Error(`Sandboxed Skill script failed (${r.exitCode}): ${t}`)}return r.stdout}s(Ht,"runBroker");async function zt(e,n){let r=await Me(e),t=i.resolve(e,se(n,"Skill script input")),o=await Me(t);if(!_(r,o)||Br(i.relative(r,o)))throw new Error("Skill script input is outside the permitted workspace surface.");if(!(await rn(o)).isFile())throw new Error("Skill script inputs must be files.");return o}s(zt,"workspaceSource");async function Yt(e,n){let r=await Me(e),t=i.resolve(e,se(n,"Skill script output target"));if(!_(i.resolve(e),t)||Br(i.relative(i.resolve(e),t)))throw new Error("Skill script output target is outside the permitted workspace surface.");if(await X(i.dirname(t),{recursive:!0}),!_(r,await Me(i.dirname(t))))throw new Error("Skill script output target escapes through a symlink.");try{throw await rn(t),new Error("Skill script output target already exists.")}catch(o){if(o.code!=="ENOENT")throw o}return t}s(Yt,"workspaceTarget");async function Zt(e,n,r,t){if(r.inputs.length>0&&t==="none")throw new Error("Skill script inputs require workspace read access.");for(let o of r.inputs){let a=await zt(e,o.path),c=se(o.as??i.basename(a),"Skill script staged input"),d=i.resolve(n,"inputs",...c.split("/"));if(!_(i.join(n,"inputs"),d))throw new Error("Skill script staged input escapes staging.");await X(i.dirname(d),{recursive:!0,mode:448}),await kr(a,d)}}s(Zt,"stageInputFiles");async function Qt(e,n,r,t,o){if(r.outputs.length>0&&t!=="write")throw new Error("Skill script outputs require workspace write access.");let a=[];for(let c of r.outputs){let d=se(c.path,"Skill script staged output"),l=i.resolve(n,"outputs",...d.split("/")),u=await Me(l);if(!_(i.join(n,"outputs"),u)||(await ot(l)).isSymbolicLink()||!(await rn(l)).isFile())throw new Error(`Skill script did not produce output "${d}".`);let g=await Yt(e,c.target);if(o!==void 0&&jr(e,!0)+(await rn(l)).size>o)throw new Error("Skill script outputs would exceed the remote workspace byte quota.");await kr(l,g,tt.COPYFILE_EXCL),a.push(i.relative(e,g))}return a}s(Qt,"promoteOutputs");function jr(e,n=!1){let r=0;for(let t of jn(e,{withFileTypes:!0})){if(n&&t.name===".kodax-a2a-script"||t.isSymbolicLink())continue;let o=i.join(e,t.name);t.isDirectory()?r+=jr(o):t.isFile()&&(r+=pn(o).size)}return r}s(jr,"directorySize");function Qn(e){if(process.platform!=="win32")return e;let n=Pe();return{...e,windows:{...e.windows,srtWin:{path:n.path}},filesystem:{...e.filesystem,allowRead:[...new Set([...e.filesystem.allowRead,n.directory])],denyWrite:process.platform==="win32"?e.filesystem.denyWrite:[...new Set([...e.filesystem.denyWrite??[],n.directory])]}}}s(Qn,"withPreparedWindowsRunner");function eo(e,n,r,t){let o=ie.homedir(),a=process.platform==="win32"?dn():[o],c=s(d=>i.isAbsolute(d)?process.platform==="win32"?[d,i.dirname(d)]:[d]:[],"executableReadScopes");return Qn({network:{allowedDomains:[],deniedDomains:[],strictAllowlist:r.length===0,allowUnixSockets:[],allowAllUnixSockets:!1,allowLocalBinding:!1},filesystem:{denyRead:a,allowRead:[e,n,...new Set([...c(process.execPath),...c(t)])],allowWrite:[e],denyWrite:a}})}s(eo,"sandboxConfig");function no(){let e=[ie.tmpdir(),process.env.TEMP,process.env.TMP,process.env.TMPDIR,...process.platform==="win32"?[]:["/tmp","/var/tmp"]];return[...new Set(e.filter(n=>typeof n=="string"&&i.isAbsolute(n)).map(n=>i.resolve(n)))]}s(no,"canonicalTempDirectories");function qr(e){return[i.join(e,".git","config"),i.join(e,".git","hooks")].filter(r=>{try{return pn(r),!0}catch{return!1}})}s(qr,"existingWorkspaceDenyWrites");function er(e,n,r){let t=St.map(a=>i.resolve(e,a)).filter(a=>i.relative(a,n)!==""),o=process.platform==="win32"?[i.resolve(n),gn()]:[i.resolve(r),...ht.map(a=>i.resolve(n,a))];return[...new Set([...o,...t])]}s(er,"workspaceShellSensitiveReadDenies");function nr(e){let n=[...new Set(e.map(t=>i.resolve(t)))].filter(t=>pn(t,{throwIfNoEntry:!1})!==void 0).sort((t,o)=>t.length-o.length),r=[];for(let t of n)r.some(o=>_(o,t))||r.push(t);return r}s(nr,"existingMinimalWindowsAclGuardRoots");function Kr(e){return i.resolve(e).toLowerCase()}s(Kr,"windowsAclGuardKey");function Ln(e,n){let r=Kr(e),t=n==="read"?Tn:new Set([...Tn,...Pr]);for(let o of t)if(r===o||r.startsWith(o.endsWith(i.sep)?o:`${o}${i.sep}`))return!0;return!1}s(Ln,"windowsAclGuardCovers");function dn(){let e=i.resolve(ie.homedir()),n=i.resolve(q());return nr(er(e,n,i.join(n,"sandbox-runtime")))}s(dn,"windowsPersistentAclGuardRoots");function Xr(e,n,r,t,o){let a=nr(e);if(a.length===0)return[];let c=JSON.stringify({sid:n,tokenSids:[n,r,"S-1-1-0","S-1-5-11","S-1-5-32-545"].filter(g=>g!==void 0),install:t,paths:a.map(g=>({path:g,directory:pn(g).isDirectory(),mode:o}))}),d=Gr(),l=Je(d,["-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from(bt,"utf16le").toString("base64")],{input:c,encoding:"utf8",timeout:t&&o==="read"?15*6e4:t?15e3:5e3,windowsHide:!0});if(l.error||l.status!==0){let g=(l.error?.message||l.stderr||l.stdout||"no diagnostics").trim().slice(-4096);throw new Error(`Windows sandbox ACL guard failed: ${g}`)}let u;try{let g=JSON.parse(l.stdout.trim());u=Array.isArray(g.missing)?g.missing.filter(f=>typeof f=="string"):[]}catch(g){throw new Error(`Windows sandbox ACL guard returned invalid output: ${le(g)}`)}if(u.length===0){let g=o==="read"?Tn:Pr;for(let f of a)g.add(Kr(f))}return u}s(Xr,"runWindowsAclGuard");function Gr(){let e=process.env.ProgramFiles??"C:\\Program Files",n=i.join(e,"PowerShell","7","pwsh.exe");return vr(n)?n:i.join(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe")}s(Gr,"windowsAclPowerShellExecutable");function Dn(e,n){if(process.platform!=="win32"||e.length===0)return;let r=e.filter(c=>!Ln(c,n));if(r.length===0)return;let t=Pe(),o=qn({srtWin:t.srtWin});if(!o.sid)throw new Error("Windows sandbox account SID is unavailable for ACL guards.");if(Xr(r,o.sid,o.groupSid,!0,n).length>0)throw new Error("Windows sandbox ACL guards were not installed completely.")}s(Dn,"installWindowsAclGuards");function rr(e){return process.platform!=="win32"?e:{...e,filesystem:{...e.filesystem,denyRead:e.filesystem.denyRead.filter(n=>!Ln(n,"read")),denyWrite:e.filesystem.denyWrite?.filter(n=>!Ln(n,"write"))}}}s(rr,"withoutWindowsAsrtDenyPropagation");function ro(e,n){let r;try{r=ue.native(n)}catch{return[]}let t=[];for(let o of e){let a;try{a=ue.native(o)}catch{continue}if(!_(a,r))t.push(o);else if(a!==r){let c=i.relative(a,r).split(i.sep),d=a;try{for(let l of c){for(let u of jn(d,{withFileTypes:!0}))u.name!==l&&t.push(i.join(d,u.name));d=i.join(d,l)}}catch{}}}return process.platform!=="win32"&&t.push(n),[...new Set(t)]}s(ro,"workspaceShellWriteRoots");function to(e,n){let r=process.platform==="win32"?n:i.resolve(e);return i.join(ie.tmpdir(),"kodax-sandbox",fn("sha256").update(r).digest("hex").slice(0,16))}s(to,"workspaceShellTempRoot");function oo(e,n){return i.join(to(e,n),`${process.pid}-${z()}`)}s(oo,"createWorkspaceShellTempDirectory");async function Cn(e){await G(e,{recursive:!0,force:!0}),await it(i.dirname(e)).catch(n=>{if(n.code!=="ENOENT"&&n.code!=="ENOTEMPTY")throw n})}s(Cn,"removeWorkspaceShellTempDirectory");function so(e){return process.platform==="win32"?e===void 0?[]:[i.dirname(e)]:no()}s(so,"workspaceShellTempWriteRoots");function io(e,n,r){try{let t=ue.native(n),o=i.resolve(n),a=i.resolve(e);if(!_(o,a)||a===o)return;for(;a!==o;)try{let c=ue.native(a);if(c===t||!_(t,c))return;let d=i.relative(t,c).split(i.sep)[0]?.toLowerCase();return d==="sandbox-runtime"||r&&Jn.some(l=>l===d)?void 0:c}catch(c){if(!r||c.code!=="ENOENT")return;try{Mn(a);return}catch(l){if(l.code!=="ENOENT")return}let d=i.dirname(a);if(d===a)return;a=d}return}catch{return}}s(io,"windowsAgentHomeAccessRoot");function Jr(e,n){if(!n)return{read:[],write:[]};let r=s((t,o)=>[...new Set(t.flatMap(a=>{let c=io(a,e,o);return c?[c]:[]}))],"roots");return{read:r(n.read,!1),write:r(n.write,!0),...n.ephemeral===!0?{ephemeral:!0}:{}}}s(Jr,"windowsAgentHomeAccessRoots");function Ge(e){return e??(process.platform==="win32"?process.env.COMSPEC??i.join(process.env.SystemRoot??"C:\\Windows","System32","cmd.exe"):"/bin/sh")}s(Ge,"workspaceShellExecutable");function ao(e,n){return Object.entries(e).find(([r,t])=>r.toUpperCase()===n&&t!==void 0)?.[1]}s(ao,"shellEnvironmentValue");function co(e){let n=process.env.LOCALAPPDATA,r=[n===void 0?void 0:i.join(n,"Programs"),n,process.env.APPDATA,i.join(e,"AppData","Local","Programs"),i.join(e,"AppData","Local"),i.join(e,"AppData","Roaming"),e];return[...new Set(r.flatMap(t=>t===void 0?[]:[i.resolve(t)]))].filter(t=>_(e,t)).sort((t,o)=>o.length-t.length)}s(co,"workspaceShellUserDataBoundaries");function lo(e,n,r){if(process.platform!=="win32"||e.toLowerCase()===n.toLowerCase())return[];try{if(!Mn(e).isSymbolicLink())return[]}catch{return[]}let t=r.find(d=>d.toLowerCase()!==n.toLowerCase()&&_(d,n));if(t===void 0)return[];let[o]=i.relative(t,n).split(i.sep);if(!o)return[];let a=i.join(t,o),c=[];for(let d=i.dirname(n);d.toLowerCase()!==a.toLowerCase()&&_(a,d);d=i.dirname(d))c.push(d);return c}s(lo,"workspaceShellLinkedTargetAncestors");function cn(e,n){let r=i.resolve(ie.homedir()),t=i.resolve(q()),o=er(r,t,i.join(t,"sandbox-runtime")),a=co(r),c=new Map,d=s(f=>{let p=i.resolve(f);if(!(p===i.parse(p).root||p.toLowerCase()===r.toLowerCase()||_(t,p)||_(p,t)||o.some(w=>_(w,p))))return p},"safe"),l=s((f,p)=>{let w=d(f);if(w===void 0)return;let h;try{h=ue(w)}catch{return}if(d(h)===void 0)return;let k=p?[w,h].filter(b=>_(r,b)):[w,h];for(let b of k)c.set(process.platform==="win32"?b.toLowerCase():b,b);if(p&&k.includes(h))for(let b of lo(w,h,a)){let v=d(b);v!==void 0&&_(r,v)&&c.set(v.toLowerCase(),v)}},"remember");for(let f of(ao(e,"PATH")??"").split(i.delimiter)){let p=f.trim().replace(/^"(.*)"$/,"$1");p&&i.isAbsolute(p)&&l(p,!0)}let u=Ge(n);i.isAbsolute(u)&&l(i.dirname(u),!0);let g=yn();if(i.isAbsolute(g)){let f=d(g);f!==void 0&&c.set(process.platform==="win32"?f.toLowerCase():f,f),l(i.dirname(g),!1)}return[...c.values()].sort((f,p)=>f.toLowerCase().localeCompare(p.toLowerCase()))}s(cn,"workspaceShellRuntimeReadScopes");function Ur(e,n,r,t,o=cn(process.env,Ge())){let a=i.resolve(q()),c=i.join(a,"sandbox-runtime"),d=i.resolve(ie.homedir()),l=er(d,a,c),u=process.platform==="win32"?nr(l):l.filter(p=>p!==a),g=process.platform==="win32"?Jr(a,r):{read:[],write:[]},f=ro([e,...so(n),...g.write,...t?.write??[]],a);return Qn({network:{allowedDomains:[],deniedDomains:[],strictAllowlist:!1,allowUnixSockets:[],allowAllUnixSockets:!1,allowLocalBinding:!1},filesystem:{denyRead:u,allowRead:[...new Set([...o,...g.read,...t?.read??[]])],allowWrite:f,denyWrite:[c,...Jn.map(p=>i.join(a,p)),...qr(e)]}})}s(Ur,"workspaceShellSandboxConfig");function Vr(e,n,r,t,o){let a=Ur(e,n,r,t,o);return process.platform!=="win32"?a:Hr(a)}s(Vr,"workspaceShellSessionSandboxConfig");function Hr(e){let n=e.filesystem.allowWrite;return{...e,filesystem:{...e.filesystem,denyRead:e.filesystem.denyRead,denyWrite:e.filesystem.denyWrite.filter(r=>n.some(t=>_(t,r)))}}}s(Hr,"boundedWindowsWorkspaceDenies");function uo(e,n,r,t,o){let a=Ur(e,n,r,t,o);return process.platform==="win32"?Hr(a):a}s(uo,"workspaceShellCommandSandboxConfig");function Ze(e,n){return[...new Set((e??[]).map(r=>i.resolve(n,r)))]}s(Ze,"normalizedSandboxPaths");function fo(e){return e.mode!=="allowlist"?[]:e.origins.map(n=>{let r=new URL(n);if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password||r.pathname!=="/"||r.search||r.hash)throw new Error(`Sandbox network origin must be an HTTP(S) origin: ${n}`);return{host:r.hostname.toLowerCase(),port:r.port?Number(r.port):r.protocol==="https:"?443:80}})}s(fo,"sdkSandboxEndpoints");async function Ho(e){if(!e.command.trim())throw new Error("Sandbox command must not be empty.");if(e.timeoutMs!==void 0&&(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0))throw new Error("Sandbox timeoutMs must be a positive finite number.");if(e.maxOutputBytes!==void 0&&(!Number.isSafeInteger(e.maxOutputBytes)||e.maxOutputBytes<=0))throw new Error("Sandbox maxOutputBytes must be a positive safe integer.");let n=i.resolve(e.cwd),r=e.network??{mode:"deny"},t=fo(r),o=await Q();if(!o.ready){if(!wn(o))return{status:"unavailable",sandboxed:!1,doctor:o};if(await an(),o.setupRequired)return{status:"unavailable",sandboxed:!1,doctor:o}}let a=Fr(e.inheritEnvironment===!0?process.env:Ce(),e.env??{}),c={config:Qn({network:{allowedDomains:[],deniedDomains:[],strictAllowlist:r.mode==="deny",allowUnixSockets:[],allowAllUnixSockets:!1,allowLocalBinding:!1},filesystem:{allowRead:Ze(e.filesystem.allowRead,n),allowWrite:Ze(e.filesystem.allowWrite,n),denyRead:Ze(e.filesystem.denyRead,n),denyWrite:Ze(e.filesystem.denyWrite,n)}}),command:e.command,args:e.args??[],cwd:n,env:a,endpoints:t,allowAllNetwork:r.mode==="allow"},d=await Mr(c,e.signal,e.timeoutMs??Xn,e.maxOutputBytes??Kn);return{status:"completed",sandboxed:!0,exitCode:d.exitCode,stdout:d.stdout,stderr:d.stderr}}s(Ho,"runKodaXSandboxed");var po=5*6e4,wo=3e4,mo=3e4,Qe=1500,zr=13e4,go=zr,yo=mo,So=go,ho=8,I=new Map,Fe=new Set,xe=new Set,ke=new Set,De,Bn,ln=!1;function pe(e){let n=e instanceof Error?e:new Error(String(e));if(process.platform!=="win32"){Bn??=n;return}De??=n}s(pe,"recordWindowsSandboxAclFailure");function Sn(){if(process.platform!=="win32"&&Bn!==void 0)throw new Error("Sandbox process cleanup was not confirmed; stop the retained process tree before more sandboxed commands.",{cause:Bn});if(process.platform==="win32"&&De!==void 0)throw De instanceof J?De:new Error("Windows sandbox ACL cleanup was not confirmed; stop the retained owner or restart Windows before more sandboxed commands.",{cause:De})}s(Sn,"assertWindowsSandboxAclProcessSafe");function hn(e){Sn(),process.platform==="win32"&&Yn(e)}s(hn,"assertWindowsSandboxAclSafe");function Yr(e){xe.add(e),e.then(()=>xe.delete(e),()=>xe.delete(e))}s(Yr,"trackWorkspaceSessionReset");function bo(e){ke.add(e),e.then(()=>ke.delete(e),n=>{ke.delete(e),W({source:"sandbox:workspace-session",level:"error",message:"Workspace sandbox durable ACL poison transition failed.",detail:n})})}s(bo,"trackWindowsSandboxAclTransition");async function vo(){for(;ke.size>0;)await Promise.allSettled([...ke])}s(vo,"waitForWindowsSandboxAclTransitions");async function tr(){for(;xe.size>0;)await Promise.allSettled([...xe]);await vo(),Sn()}s(tr,"waitForWorkspaceSessionResets");async function or(e=!1){let n=[...I.values()];I.clear();let r=[];for(let t of n)try{await(await t).close(e)}catch(o){r.push(o),W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox shutdown could not confirm ACL reset.",detail:o})}return r}s(or,"closeCachedWorkspaceSessions");var Zr=s(()=>{ln=!1,or()},"closeWorkspaceSessionsBeforeExit");function xo(){ln||(ln=!0,process.once("beforeExit",Zr))}s(xo,"registerWorkspaceSessionBeforeExit");async function zo(){for(process.removeListener("beforeExit",Zr),ln=!1;Fe.size>0;)await Promise.allSettled([...Fe]);let e=await or();try{await tr()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Workspace sandbox shutdown was not confirmed.")}s(zo,"shutdownAsrtWorkspaceSessions");function Qr(){let e=new Error("ASRT workspace session preparation timed out.");return e.name="TimeoutError",e}s(Qr,"workspacePreparationTimeoutError");function un(e,n){if(e?.aborted)throw new DOMException("Operation aborted","AbortError");if(n!==void 0&&Date.now()>=n)throw Qr()}s(un,"throwIfWorkspacePreparationStopped");function Fn(e,n,r){return un(n,r),n===void 0&&r===void 0?e:new Promise((t,o)=>{let a=!1,c,d=s(u=>{a||(a=!0,c&&clearTimeout(c),n?.removeEventListener("abort",l),u())},"finish"),l=s(()=>{d(()=>o(new DOMException("Operation aborted","AbortError")))},"onAbort");n?.addEventListener("abort",l,{once:!0}),r!==void 0&&(c=setTimeout(()=>{d(()=>o(Qr()))},Math.max(0,r-Date.now())),c.unref()),e.then(u=>d(()=>t(u)),u=>d(()=>o(u)))})}s(Fn,"waitForWorkspacePreparation");async function bn(){let e=i.join(q(),"sandbox-runtime");return await X(e,{recursive:!0,mode:448}),e}s(bn,"sandboxControlDirectory");function ko(e){if(process.env.KODAX_BUNDLED==="true")return["__asrt-workspace-session",e];if(import.meta.url.endsWith(".ts"))return["--import",Ar(Gn.resolve("tsx")).href,fr(new URL("./sandbox-workspace-session-entry.ts",import.meta.url)),e];let n=i.dirname(fr(import.meta.url)),r=i.basename(n)==="chunks"?i.dirname(n):n;return[i.join(r,"sandbox-workspace-session.js"),e]}s(ko,"workspaceSessionEntryArgs");function en(e,n){let r=n?"ref":"unref";e[r]();for(let t of e.stdio){if(!t)continue;t[r]?.()}}s(en,"setWorkspaceSessionReferenced");async function et(e,n,r){if(e)return n();let t=await kn(r);try{return await n()}finally{await t()}}s(et,"withExclusiveFileSystemEffectFence");async function Ao(e,n,r,t,o,a,c){let d=process.platform==="win32"?oo(e,o):void 0;d!==void 0&&await X(d,{recursive:!0,mode:448});let l=await bn();process.platform==="win32"&&Dn(qr(e),"write");let u=i.join(l,`workspace-${process.pid}-${z()}.json`),g=rr(Vr(e,d,n,r,t));await Re(u,JSON.stringify({config:g}),{mode:384});let f=Oe({args:ko(u),env:Ce(),isElectron:process.versions.electron!==void 0}),p;try{p=await Lr(o)}catch(y){let m=await Promise.allSettled([G(u,{force:!0}),...d===void 0?[]:[Cn(d)]]),x=[y,...m.flatMap(C=>C.status==="rejected"?[C.reason]:[])];throw x.length===1?y:new AggregateError(x,"Workspace sandbox owner admission and pre-launch cleanup both failed.")}let w;try{w=br(process.execPath,f.args,{cwd:process.platform==="win32"?Pe().directory:void 0,env:f.env,shell:!1,stdio:["pipe","pipe","pipe","pipe"],windowsHide:!0})}catch(y){let m=[y];try{await In(p)}catch(C){await Ye(p,C),m.push(C)}let x=await Promise.allSettled([G(u,{force:!0}),...d===void 0?[]:[Cn(d)]]);throw m.push(...x.flatMap(C=>C.status==="rejected"?[C.reason]:[])),m.length===1?y:new AggregateError(m,"Workspace sandbox owner launch cleanup failed.")}vn(w);let h=w.pid===void 0?void 0:Ne(w.pid),k=w.stdio[3];if(!k)throw new Error("ASRT workspace session control pipe was not created.");let b=ct.createInterface({input:k}),v=new Map,S="",A=!1,E=!1,L=!1,P=!1,Y=0,R=0,M,j,ae,ge=new Promise(y=>{w.once("exit",(m,x)=>y({code:m,signal:x}))}),ye=ge.then(async()=>{if(d!==void 0)try{await Cn(d)}catch(y){W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox temp cleanup failed.",detail:y})}}),Ue=s(async(y=!1)=>{let m=await ge;await ye;let x=[];if(!y&&(m.code!==0||m.signal!==null)){let C=m.signal===null?`code ${m.code??"unknown"}`:`signal ${m.signal}`;x.push(new Error(`ASRT workspace session ACL reset was not confirmed (${C}): ${S.trim()||"no diagnostics"}`))}try{await In(p)}catch(C){x.push(C)}if(x.length===1)throw x[0];if(x.length>1)throw new AggregateError(x,"Workspace sandbox cleanup was not confirmed.")},"confirmCleanReset"),B,U,F=new Promise((y,m)=>{B=y,U=m}),We=s(()=>{P||(P=!0,c())},"evict"),Ve=s(async()=>{if(!E||!L||R!==0||w.exitCode!==null||w.signalCode!==null||!w.stdin.writable)return!1;try{w.stdin.end()}catch{return!1}let y;try{let m=await Promise.race([ge,new Promise(x=>{y=setTimeout(x,process.platform==="win32"?zr:Qe)})]);return m!==void 0&&m.code===0&&m.signal===null}finally{y!==void 0&&clearTimeout(y)}},"waitForOrderlyClose"),N,$e=!1,sr=!1,ee=s(()=>N||(sr=!0,N=(async()=>{try{if(await Ve())return;if((await xn(w,{gracefulStdinEnd:!1,gracefulMs:Qe,forceMs:Qe,taskkillMs:Qe})).status==="unknown")throw await _r(w.pid,h,Or("ASRT workspace session"),p);$e=!0}finally{b.close(),k.destroy(),w.stdin.destroy()}})().finally(We),N),"terminate"),ne=s(y=>{if(!A){A=!0,U(y);for(let m of v.values())m.reject(y);v.clear()}},"fail");w.stderr.on("data",y=>{S=(S+y.toString("utf8")).slice(-16384)}),w.stdout.on("data",y=>{S=(S+y.toString("utf8")).slice(-16384)}),b.on("line",y=>{let m;try{m=JSON.parse(y)}catch{ne(new Error("ASRT workspace session returned malformed control data.")),ee();return}if(m.type==="ready"){m.ok?(L=!0,B()):U(new Error(m.error??"ASRT workspace session failed."));return}if(m.type!=="result"||!m.id){ne(new Error("ASRT workspace session returned an invalid control response.")),ee();return}let x=v.get(m.id);x&&(v.delete(m.id),x.resolve(m))}),w.once("error",y=>{ne(y),ee()}),b.once("close",()=>{E||A||(ne(new Error("ASRT workspace session control pipe closed unexpectedly.")),ee())}),w.once("exit",(y,m)=>{j&&clearTimeout(j);let x=new Error(`ASRT workspace session exited ${m??y??1}: ${S.trim()||"no diagnostics"}`);!sr&&(y!==0||m!==null||!E)&&bo(Ye(p,x)),ne(x),We()});let rt=setTimeout(()=>{ne(new Error("ASRT workspace session initialization timed out.")),ee()},wo);try{await F.finally(()=>clearTimeout(rt))}catch(y){E=!0;let m=[y],x=!1;try{await ee(),x=!0}catch(C){m.push(C)}if(x)try{await Ue($e)}catch(C){await Ye(p,C),m.push(C)}throw await G(u,{force:!0}),m.length===1?y:new AggregateError(m,`Workspace sandbox startup cleanup failed: ${le(m.at(-1))}`)}let He=s(async(y,m)=>{if(A||E&&y==="wrap")throw new Error("ASRT workspace session is unavailable.");let x=`workspace_${++Y}`,C=new Promise((D,he)=>{v.set(x,{resolve:D,reject:he})}),re=setTimeout(()=>{ne(new Error(`ASRT workspace session ${y} request timed out.`)),Se.close(a).catch(D=>{W({source:"sandbox:workspace-session",level:"warn",message:"Timed-out workspace sandbox request could not retire its session.",detail:D})})},y==="cleanup"?So:yo);re.unref();try{await new Promise((D,he)=>{w.stdin.write(`${JSON.stringify({id:x,type:y,request:m})}
|
|
518
|
-
`,Te=>Te?he(Te):D())})}catch(D){throw v.delete(x),clearTimeout(re),ne(D instanceof Error?D:new Error(String(D))),ee(),D}return C.finally(()=>clearTimeout(re))},"request"),ir=s(()=>{if(j&&clearTimeout(j),!(R>0||E||A)){if(process.platform==="win32"){en(w,!1);return}j=setTimeout(()=>{Se.close().catch(y=>{W({source:"sandbox:workspace-session",level:"warn",message:"Idle workspace sandbox session could not confirm ACL reset.",detail:y})})},po),j.unref(),en(w,!1)}},"scheduleIdleClose"),Se={policyKey:o,...d===void 0?{}:{tempDirectory:d},async acquire(y,m,x){if(hn(o),un(m,x),A||E)throw new Error("ASRT workspace session is unavailable.");j&&clearTimeout(j),en(w,!0),R+=1;let C=!1,re=s(()=>{if(C)return!1;C=!0,R-=1;let V=R===0;return R===0&&(M?.(),M=void 0),ir(),V},"finalize"),D=s(async()=>{re()&&process.platform==="win32"&&await Se.close(a)},"finalizeAndCloseIfIdle"),he=s((V,$)=>{W({source:"sandbox:workspace-session",level:"warn",message:V,detail:$}),re()&&Se.close(a).catch(H=>{W({source:"sandbox:workspace-session",level:"warn",message:"Failed workspace sandbox cleanup could not retire its session.",detail:H})})},"retireAfterCleanupFailure"),Te=He("wrap",y),_e;try{_e=await Fn(Te,m,x)}catch(V){throw Te.then(async $=>{if(!$.ok||!$.invocation)return;let T=await He("cleanup");if(!T.ok)throw new Error(T.error??"ASRT command cleanup failed.")}).then(D,$=>he("Late workspace sandbox preparation cleanup failed.",$)),V}try{if(!_e.ok||!_e.invocation){re();let $=new Error(_e.error??"ASRT workspace wrapping failed.");try{await Se.close(a)}catch(T){let H=T instanceof Error?T.message:String(T);throw new Error(`${$.message} Workspace session reset failed: ${H}`,{cause:$})}throw $}try{un(m,x)}catch($){try{let T=await He("cleanup");if(!T.ok)throw new Error(T.error??"ASRT command cleanup failed.")}catch(T){he("Cancelled workspace sandbox preparation cleanup failed.",T)}throw await D(),$}let V=!1;return{invocation:_e.invocation,async release(){if(V)return;V=!0;let $;try{let H=await He("cleanup");if(!H.ok)throw new Error(H.error??"ASRT command cleanup failed.")}catch(H){$=H}let T;try{await D()}catch(H){T=H}if($!==void 0&&T!==void 0)throw new AggregateError([$,T],"Workspace sandbox command cleanup and policy-group reset both failed.");if($!==void 0)throw $;if(T!==void 0)throw T}}}catch(V){throw re(),V}},async close(y=!1){return ae||(E=!0,We(),ae=(async()=>{j&&clearTimeout(j),en(w,!0),R>0&&await new Promise(m=>{M=m}),await et(a||y,async()=>{await ee(),await Ue()},o)})().catch(async m=>{throw await Ye(p,m),m}),Yr(ae),ae)}};return ir(),Se}s(Ao,"startWorkspaceSessionClientWithFence");function Sr(e,n,r,t,o,a,c){return et(a,async()=>{if(nt(e,n,r,t)!==o)throw new Error("Sandbox policy paths changed before ACL initialization.");return hn(o),await an(o),Ao(e,n,r,t,o,a,c)},o)}s(Sr,"startWorkspaceSessionClient");function Wn(e){return[...new Set(e.map(n=>{let r=i.resolve(n);return process.platform==="win32"?r.toLowerCase():r}))].sort()}s(Wn,"normalizedWorkspacePolicyPaths");function Be(e){let n=s(t=>{let o=i.resolve(t);return process.platform==="win32"?o.toLowerCase():o},"normalize"),r=null;try{r=n(ue.native(e))}catch{}return{lexical:n(e),canonical:r}}s(Be,"workspacePolicyPathIdentity");function nn(e){let n=new Map;for(let r of e){let t=Be(r);n.set(`${t.lexical}\0${t.canonical??""}`,t)}return[...n.values()].sort((r,t)=>r.lexical.localeCompare(t.lexical)||(r.canonical??"").localeCompare(t.canonical??""))}s(nn,"workspacePolicyPathIdentities");function nt(e,n,r,t){let o=Vr(e,void 0,n,r,t);return fn("sha256").update(JSON.stringify({workspace:Be(e),agentHome:Be(q()),tempBase:Be(ie.tmpdir()),filesystem:{allowRead:nn(o.filesystem.allowRead),allowWrite:nn(o.filesystem.allowWrite),denyRead:nn(o.filesystem.denyRead),denyWrite:nn(o.filesystem.denyWrite)},network:o.network,windowsRunner:process.platform==="win32"?{version:ce,architecture:process.arch,path:Be(Pe().path)}:null,ephemeral:n?.ephemeral===!0})).digest("hex")}s(nt,"workspaceShellPolicyKey");function Eo(e){return process.platform!=="win32"?!0:(e?.write??[]).every(n=>{try{return ue.native(n),!0}catch{return!1}})}s(Eo,"workspaceShellFilesystemAccessIsRepresentable");async function hr(e,n,r,t=cn(process.env,Ge()),o=t,a=!1){if(process.platform==="win32"){if(xe.size>0||ke.size>0)return}else await tr();Sn();let c=await Q();if(!c.ready&&!wn(c))return;if(process.platform!=="win32"){let v=q();await Promise.all([bn(),...Jn.map(S=>X(i.join(v,S),{recursive:!0,mode:448}))])}let d=nt(e,process.platform==="win32"?n:void 0,r,t);if(!c.ready&&(await an(d),c.setupRequired))return;await an(d),hn(d),xo();let l=process.platform==="win32"?n:void 0,u=process.platform==="win32"?e.toLowerCase():e,g=Wn,f=g(t),p=JSON.stringify(f)===JSON.stringify(g(o)),w=(r?.read.length??0)>0||(r?.write.length??0)>0,h=l===void 0&&!w&&p?"workspace":fn("sha256").update(JSON.stringify({read:[...l?.read??[]].map(v=>v.toLowerCase()).sort(),write:[...l?.write??[]].map(v=>v.toLowerCase()).sort(),additionalRead:Wn(r?.read??[]),additionalWrite:Wn(r?.write??[]),runtimeReadScopes:f})).digest("hex"),k=process.platform==="win32"?d:`${u}\0${h}`;if(process.platform==="win32"&&a){let v=l?.ephemeral===!0?void 0:k;for(let[S,A]of[...I])if(S!==v){I.delete(S);try{await(await A).close(!0)}catch(E){throw W({source:"sandbox:workspace-session",level:"warn",message:"Retiring the previous Windows workspace sandbox scope failed.",detail:E}),E}}}if(l?.ephemeral===!0)return Sr(e,l,r,t,d,a,()=>{});let b=I.get(k);if(b&&(I.delete(k),I.set(k,b)),!b){if(process.platform!=="win32"&&h!=="workspace"){let v=[...I.keys()].filter(S=>!S.endsWith("\0workspace"));if(v.length>=ho){let S=v[0],A=I.get(S);if(I.delete(S),A)try{await(await A).close()}catch(E){throw W({source:"sandbox:workspace-session",level:"warn",message:"Retiring an old scoped workspace sandbox failed.",detail:E}),E}}}b=Sr(e,l,r,t,d,a,()=>{I.get(k)===b&&I.delete(k)}),I.set(k,b),b.catch(()=>{I.get(k)===b&&I.delete(k)})}return b}s(hr,"getWorkspaceSession");function Yo(e){let n=i.resolve(e.workspaceRoot),r=cn(process.platform==="win32"?{}:process.env,Ge()),t=process.platform==="win32"?void 0:hr(n,void 0,void 0,r,r);return t!==void 0&&(Fe.add(t),t.then(()=>Fe.delete(t),()=>Fe.delete(t)),t.catch(o=>{W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox warm-up failed; admitted commands will use normal permission fallback.",detail:o})})),{processTreeContainment:process.platform==="linux"?"root-exit-drains":void 0,async prepare(o){if(!o.toolCallId){o.reportObservation?.({version:1,state:"not_selected"});return}let a={id:o.toolCallId,name:"bash",input:{...o.toolInput}},c=await e.shouldSandbox(a);if(!c){o.reportObservation?.({version:1,state:"not_selected"});return}let d=typeof c=="object"?c.agentHomeAccess:void 0,l=process.platform==="win32"&&d!==void 0?Jr(i.resolve(q()),d):d,u=typeof c=="object"?c.filesystemAccess:void 0;if(!Eo(u)){o.reportObservation?.({version:1,state:"fallback",reason:"not_ready",execution:"normal_permission_policy"});return}let g=process.platform==="win32"&&l?.ephemeral===!0,f=Ge(o.executable),p=o.args??(process.platform==="win32"?["/d","/s","/c",o.command]:["-c",o.command]),w=Zn(o.env),h=cn(w,f),k,b;try{t!==void 0&&(await Fn(t.then(()=>{},()=>{}),o.signal,o.deadlineAt),un(o.signal,o.deadlineAt));let v=hr(n,l,u,h,r),S;try{S=await Fn(v,o.signal,o.deadlineAt)}catch(B){if(process.platform==="win32"&&(o.signal?.aborted||o.deadlineAt!==void 0&&Date.now()>=o.deadlineAt)){let U=v.then(async F=>{F&&await F.close()},async()=>{});Yr(U),U.catch(F=>{W({source:"sandbox:workspace-session",level:"warn",message:"Late cancelled workspace session rollback failed.",detail:F})})}throw B}if(!S){o.reportObservation?.({version:1,state:"fallback",reason:"not_ready",execution:"normal_permission_policy"});return}let A=S.policyKey;b=S;let E=await bn(),L=i.join(E,`kodax-asrt-shell-${process.pid}-${z()}.json`),P=i.join(E,`kodax-asrt-observation-${process.pid}-${z()}.json`),Y=w;if(process.platform==="win32"){let B=S.tempDirectory;if(B===void 0)throw new Error("Windows workspace sandbox temp directory is unavailable.");Y=Fr(w,{TEMP:B,TMP:B,TMPDIR:B,GIT_CONFIG_GLOBAL:"NUL",GIT_CONFIG_NOSYSTEM:"1"})}let R={config:rr(uo(n,S.tempDirectory,l,u,h)),command:f,args:p,windowsVerbatimArguments:o.windowsVerbatimArguments===!0,cwd:o.cwd,env:Y,endpoints:[],allowAllNetwork:!0,bootstrapCommand:yn(),fallbackToNormalExecution:!0,observationBackend:mt().backend,observationFile:P,targetStartedMarker:`\0KODAX_ASRT_TARGET_STARTED:${z()}\0
|
|
519
|
-
`},M=await S.acquire(R,o.signal,o.deadlineAt);k=M;let j={...R,wrappedInvocation:M.invocation},ae=process.env.KODAX_BUNDLED==="true"?["__asrt-broker",L]:["--input-type=module","-e",Cr,Rr,L],ge=Oe({args:ae,env:Ce(),isElectron:process.versions.electron!==void 0});await Re(L,JSON.stringify(j),{mode:384});let ye,Ue=s(async()=>{g||(ye===void 0&&(ye=b?.close(!1)??Promise.resolve(),ye.catch(B=>{W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox session retirement failed.",detail:B})})),process.platform==="win32"&&await ye)},"retireWorkspaceSession");return{executable:process.execPath,args:ge.args,env:ge.env,fileSystemEffectPolicyKey:A,authorizeStart:s(()=>hn(A),"authorizeStart"),async cleanup(B){let U,F=[];try{U=await Ee(P,"utf8").then(Ft).catch(N=>{if(N.code!=="ENOENT")throw N})}catch(N){F.push(N)}let We=await Promise.allSettled([G(L,{force:!0}),G(P,{force:!0})]);for(let N of We)N.status==="rejected"&&F.push(N.reason);try{await M.release()}catch(N){F.push(N)}let Ve=B?.execution==="started_or_unknown"&&U===void 0;if(Ve&&F.push(new Error("Required OS sandbox execution could not be attested; the workspace session must be retired and the command was not retried")),F.length>0){let N=Ve?"Required OS sandbox execution could not be attested and request cleanup failed; the workspace session must be retired and the command was not retried.":"Required OS sandbox request cleanup failed; the workspace session must be retired.",$e=new AggregateError(F,N);throw W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox command cleanup failed.",detail:$e}),$e}return U},retire:Ue}}catch(v){let S=[v],A=o.signal?.aborted||o.deadlineAt!==void 0&&Date.now()>=o.deadlineAt,E=!1;if(k)try{await k.release()}catch(P){E=!0,S.push(P),W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox lease release failed.",detail:P})}if(A&&process.platform==="win32"&&b&&k===void 0)throw b.close().catch(P=>{W({source:"sandbox:workspace-session",level:"warn",message:"Cancelled workspace preparation cleanup could not retire its session.",detail:P})}),v;if(process.platform==="win32"&&b)try{await b.close()}catch(P){S.push(P),W({source:"sandbox:workspace-session",level:"warn",message:"Failed workspace lease cleanup could not retire its session.",detail:P})}else E&&b&&b.close().catch(P=>{W({source:"sandbox:workspace-session",level:"warn",message:"Failed workspace lease cleanup could not retire its session.",detail:P})});if(A)throw v;let L=S.length===1?v:new AggregateError(S,`Workspace sandbox preparation failed and cleanup was incomplete: ${S.map(le).join(" | ")}`);W({source:"sandbox:workspace-session",level:"warn",message:"Workspace sandbox preparation failed; using normal permission fallback.",detail:L}),o.reportObservation?.({version:1,state:"fallback",reason:"prepare_failed",execution:"normal_permission_policy"});return}}}}s(Yo,"createAsrtShellSandbox");async function Zo(e){let n=await Q();if(!n.ready)throw new Error(`ASRT ${ce} is not ready: ${n.diagnostics.join(" ")||"run kodax sandbox setup"}`);let r=i.join(e.snapshotRoot,z()),t=i.join(r,"skills");await X(t,{recursive:!0,mode:448});try{let o=await Xt(e,t),a=Gt(e.network),c=Promise.resolve();return{async run(d,l){let u=c,g;if(c=new Promise(f=>{g=f}),await u,l.signal?.aborted)throw g?.(),l.signal.reason??new Error("Sandboxed Skill script was cancelled.");try{if(d.args.length>64||d.args.some(h=>h.length>8192))throw new Error("Skill script arguments exceed the bounded remote contract.");if(d.inputs.length>32||d.outputs.length>32)throw new Error("Skill script file mappings exceed the bounded remote contract.");let f=se(d.script,"Skill script"),p=o.get(`${d.skill}\0${f}`);if(!p)throw new Error("Skill script is not admitted by this Runtime binding.");if([".cmd",".bat"].includes(i.extname(p.snapshotPath).toLowerCase())&&d.args.some(h=>/[&|<>^]/.test(h)))throw new Error("Batch Skill script arguments cannot contain command operators.");let w=i.join(l.workspaceRoot,".kodax-a2a-script",z());try{await X(i.join(w,"inputs"),{recursive:!0,mode:448}),await X(i.join(w,"outputs"),{recursive:!0,mode:448}),await Zt(l.workspaceRoot,w,d,e.workspaceAccess);let h=Jt(p.snapshotPath),k=await Ht({config:eo(w,r,a,h.command),command:h.command,args:[...h.args,...d.args],cwd:w,env:Ce(),endpoints:a},l.signal),b=await Qt(l.workspaceRoot,w,d,e.workspaceAccess,e.workspaceByteLimit);return JSON.stringify({stdout:k.trim(),outputs:b})}finally{await G(w,{recursive:!0,force:!0})}}finally{g?.()}},async dispose(){await c,await G(r,{recursive:!0,force:!0})}}}catch(o){throw await G(r,{recursive:!0,force:!0}),o}}s(Zo,"createAsrtSkillScriptRunner");export{ce as a,mt as b,Go as c,Jo as d,Uo as e,Q as f,qt as g,ve as h,Vo as i,Ho as j,zo as k,Yo as l,Zo as m};
|