@lqc123qwe/car-runtime 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/SHA256SUMS +1 -0
- package/dist/authz/authz.d.ts +44 -0
- package/dist/authz/authz.js +65 -0
- package/dist/car-runtime-1.10.0.tgz +0 -0
- package/dist/car-runtime-1.10.0.tgz.sig.bundle +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +825 -0
- package/dist/dx/doctor.d.ts +62 -0
- package/dist/dx/doctor.js +127 -0
- package/dist/governance/dump.d.ts +47 -0
- package/dist/governance/dump.js +17 -0
- package/dist/host/facade.d.ts +13 -0
- package/dist/host/facade.js +154 -0
- package/dist/host/hostGateway.d.ts +117 -0
- package/dist/host/hostGateway.js +65 -0
- package/dist/host/mappings.d.ts +27 -0
- package/dist/host/mappings.js +52 -0
- package/dist/host/stdio.d.ts +14 -0
- package/dist/host/stdio.js +83 -0
- package/dist/kernel/context.d.ts +76 -0
- package/dist/kernel/context.js +203 -0
- package/dist/kernel/events.d.ts +37 -0
- package/dist/kernel/events.js +82 -0
- package/dist/load/config.d.ts +79 -0
- package/dist/load/config.js +285 -0
- package/dist/load/loader.d.ts +72 -0
- package/dist/load/loader.js +162 -0
- package/dist/load/registry.d.ts +44 -0
- package/dist/load/registry.js +58 -0
- package/dist/load/report.d.ts +98 -0
- package/dist/load/report.js +301 -0
- package/dist/load/sigGate.d.ts +22 -0
- package/dist/load/sigGate.js +68 -0
- package/dist/load/sign.d.ts +25 -0
- package/dist/load/sign.js +47 -0
- package/dist/load/verifier.d.ts +35 -0
- package/dist/load/verifier.js +56 -0
- package/dist/loop/goal.d.ts +31 -0
- package/dist/loop/goal.js +34 -0
- package/dist/loop/recover.d.ts +17 -0
- package/dist/loop/recover.js +39 -0
- package/dist/loop/stop.d.ts +79 -0
- package/dist/loop/stop.js +151 -0
- package/dist/mcp/gateway.d.ts +96 -0
- package/dist/mcp/gateway.js +69 -0
- package/dist/mcp/httpClient.d.ts +27 -0
- package/dist/mcp/httpClient.js +196 -0
- package/dist/mcp/stdioClient.d.ts +8 -0
- package/dist/mcp/stdioClient.js +73 -0
- package/dist/ptc/budget.d.ts +21 -0
- package/dist/ptc/budget.js +36 -0
- package/dist/ptc/erasable.d.ts +14 -0
- package/dist/ptc/erasable.js +27 -0
- package/dist/ptc/runCode.d.ts +65 -0
- package/dist/ptc/runCode.js +140 -0
- package/dist/ptc/schemaRender.d.ts +15 -0
- package/dist/ptc/schemaRender.js +90 -0
- package/dist/ptc/sdk.d.ts +27 -0
- package/dist/ptc/sdk.js +23 -0
- package/dist/ptc/worker-entry.d.ts +1 -0
- package/dist/ptc/worker-entry.js +71 -0
- package/dist/release-audit.jsonl +4 -0
- package/dist/runtime-core/chatStep.d.ts +40 -0
- package/dist/runtime-core/chatStep.js +104 -0
- package/dist/runtime-core/credentials.d.ts +49 -0
- package/dist/runtime-core/credentials.js +118 -0
- package/dist/runtime-core/errors.d.ts +30 -0
- package/dist/runtime-core/errors.js +36 -0
- package/dist/runtime-core/llm.d.ts +76 -0
- package/dist/runtime-core/llm.js +553 -0
- package/dist/runtime-core/redaction.d.ts +39 -0
- package/dist/runtime-core/redaction.js +79 -0
- package/dist/runtime-core/telemetry.d.ts +88 -0
- package/dist/runtime-core/telemetry.js +332 -0
- package/dist/runtime-core/tools.d.ts +15 -0
- package/dist/runtime-core/tools.js +12 -0
- package/dist/runtime-core/trace.d.ts +55 -0
- package/dist/runtime-core/trace.js +137 -0
- package/dist/runtime-core/types.d.ts +84 -0
- package/dist/runtime-core/types.js +13 -0
- package/dist/sandbox/sandbox.d.ts +68 -0
- package/dist/sandbox/sandbox.js +153 -0
- package/dist/sbom.json +263 -0
- package/dist/seam.d.ts +21 -0
- package/dist/seam.js +20 -0
- package/dist/security/secrets-baseline.d.ts +43 -0
- package/dist/security/secrets-baseline.js +176 -0
- package/dist/security/secrets.d.ts +45 -0
- package/dist/security/secrets.js +138 -0
- package/dist/session/export.d.ts +55 -0
- package/dist/session/export.js +81 -0
- package/dist/session/fork.d.ts +51 -0
- package/dist/session/fork.js +63 -0
- package/dist/session/format.d.ts +21 -0
- package/dist/session/format.js +49 -0
- package/dist/session/indexStore.d.ts +44 -0
- package/dist/session/indexStore.js +265 -0
- package/dist/session/log.d.ts +79 -0
- package/dist/session/log.js +157 -0
- package/dist/session/store.d.ts +9 -0
- package/dist/session/store.js +37 -0
- package/dist/telemetry/metrics.d.ts +25 -0
- package/dist/telemetry/metrics.js +26 -0
- package/package.json +17 -1
- package/src/mcp/gateway.ts +10 -2
- package/src/mcp/httpClient.ts +23 -5
- package/src/runtime-core/trace.ts +5 -0
- package/src/seam.ts +21 -0
- package/.gitattributes +0 -11
- package/.github/workflows/ci.yml +0 -293
- package/.github/workflows/release.yml +0 -54
- package/adr/ADR-001.md +0 -4
- package/adr/ADR-002.md +0 -5
- package/adr/ADR-003.md +0 -35
- package/adr/host-onboarding.md +0 -68
- package/adr/mlps-audit-checklist.md +0 -41
- package/adr/win32-spike.md +0 -45
- package/docs/plugin-authoring.md +0 -82
- package/native/landlock-run/Makefile +0 -19
- package/native/landlock-run/landlock-run.c +0 -162
- package/scripts/contract-check.ts +0 -56
- package/scripts/invariant-n1.ts +0 -96
- package/scripts/package-check.ts +0 -29
- package/scripts/ptc-baseline/run-baseline.ts +0 -118
- package/scripts/release-artifacts.ts +0 -111
- package/scripts/release-pipeline.ts +0 -245
- package/scripts/secrets-baseline.ts +0 -33
- package/scripts/secrets-scan.ts +0 -56
- package/scripts/win32-ffi-debug.ts +0 -143
- package/scripts/win32-koffi-spike.ts +0 -537
- package/test/contract/eventmap.golden.json +0 -7
- package/test/fixtures/hello-plugin.ts +0 -5
- package/test/kernel.spec.ts +0 -136
- package/test/registry-e2e/run-e2e.ts +0 -213
- package/test/s11.spec.ts +0 -129
- package/test/s12.spec.ts +0 -135
- package/test/s13.spec.ts +0 -117
- package/test/s14.spec.ts +0 -117
- package/test/s15.spec.ts +0 -80
- package/test/s16.spec.ts +0 -133
- package/test/s17.spec.ts +0 -102
- package/test/s18.spec.ts +0 -81
- package/test/s19.spec.ts +0 -138
- package/test/s2.spec.ts +0 -245
- package/test/s20.spec.ts +0 -241
- package/test/s21.spec.ts +0 -231
- package/test/s22-m7-store-format.spec.ts +0 -135
- package/test/s23-m7-export-index.spec.ts +0 -189
- package/test/s24-signature-gate.spec.ts +0 -185
- package/test/s25-m8-runtime-core.spec.ts +0 -600
- package/test/s26-signature-closeout.spec.ts +0 -349
- package/test/s27-host-load-wiring.spec.ts +0 -134
- package/test/s28-session-index-followup.spec.ts +0 -236
- package/test/s29-otel-producer.spec.ts +0 -252
- package/test/s3.spec.ts +0 -179
- package/test/s30-release-artifacts.spec.ts +0 -127
- package/test/s31-real-model-wiring.spec.ts +0 -329
- package/test/s32-telemetry-mcp-ptc.spec.ts +0 -218
- package/test/s33-anthropic-adapter.spec.ts +0 -354
- package/test/s34-mcp-remote-transport.spec.ts +0 -250
- package/test/s35-config-ts-zod.spec.ts +0 -145
- package/test/s36-host-tool-surface.spec.ts +0 -250
- package/test/s37-projection-dedupe.spec.ts +0 -161
- package/test/s38-config-jiti.spec.ts +0 -116
- package/test/s39-otlp-span-semantics.spec.ts +0 -100
- package/test/s4.spec.ts +0 -169
- package/test/s40-metrics-cumulative.spec.ts +0 -67
- package/test/s41-mcp-serve-turn-span.spec.ts +0 -148
- package/test/s42-traceparent-propagation.spec.ts +0 -415
- package/test/s5.spec.ts +0 -95
- package/test/s6.spec.ts +0 -169
- package/test/s7.spec.ts +0 -136
- package/test/s7b-baseline.spec.ts +0 -20
- package/test/s9.spec.ts +0 -89
- package/test/sandbox-escape/j17-orchestrate.sh +0 -30
- package/test/sandbox-escape/run-matrix.sh +0 -98
- package/tsconfig.json +0 -18
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* win32 FFI 诊断矩阵(M5-S26 临时诊断,非门禁):定位 windows-2025 runner 上
|
|
3
|
-
* CreateProcessAsUserW 子进程 0xC0000142(STATUS_DLL_INIT_FAILED)的确切触发条件。
|
|
4
|
-
* 矩阵:API(AsUser/WithToken/normal)× 环境块(NULL/显式 Unicode)×
|
|
5
|
-
* 标志(CREATE_NO_WINDOW/DETACHED_PROCESS)× 程序(cmd/whoami/node)× token(原发/受限)。
|
|
6
|
-
* 本机(非提权交互会话)全绿为基线;runner 上首个失败行即回归点。
|
|
7
|
-
*/
|
|
8
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
9
|
-
import { tmpdir } from 'node:os'
|
|
10
|
-
import path from 'node:path'
|
|
11
|
-
|
|
12
|
-
const koffi = (await import('koffi')).default ?? (await import('koffi') as any)
|
|
13
|
-
const kernel32 = koffi.load('kernel32.dll')
|
|
14
|
-
const advapi32 = koffi.load('advapi32.dll')
|
|
15
|
-
|
|
16
|
-
const CREATE_NO_WINDOW = 0x08000000
|
|
17
|
-
const CREATE_SUSPENDED = 0x00000004
|
|
18
|
-
const CREATE_UNICODE_ENVIRONMENT = 0x00000400
|
|
19
|
-
const DETACHED_PROCESS = 0x00000008
|
|
20
|
-
const STILL_ACTIVE = 259
|
|
21
|
-
const PSEUDO_CURRENT_PROCESS = BigInt.asUintN(64, -1n)
|
|
22
|
-
const SystemRoot = process.env.SystemRoot ?? 'C:\\Windows'
|
|
23
|
-
|
|
24
|
-
const SID_AND_ATTRIBUTES = koffi.struct('SID_AND_ATTRIBUTES', { Sid: 'void *', Attributes: 'uint32' })
|
|
25
|
-
const CloseHandle = kernel32.func('int32 __stdcall CloseHandle(uint64 hObject)')
|
|
26
|
-
const WaitForSingleObject = kernel32.func('uint32 __stdcall WaitForSingleObject(uint64 hHandle, uint32 dwMilliseconds)')
|
|
27
|
-
const ResumeThread = kernel32.func('uint32 __stdcall ResumeThread(uint64 hThread)')
|
|
28
|
-
const GetExitCodeProcess = kernel32.func('int32 __stdcall GetExitCodeProcess(uint64 hProcess, void *lpExitCode)')
|
|
29
|
-
const OpenProcessToken = advapi32.func('int32 __stdcall OpenProcessToken(uint64 ProcessHandle, uint32 DesiredAccess, void *TokenHandle)')
|
|
30
|
-
const CreateRestrictedToken = advapi32.func('int32 __stdcall CreateRestrictedToken(uint64 ExistingTokenHandle, uint32 Flags, uint32 DisableSidCount, SID_AND_ATTRIBUTES *SidsToDisable, uint32 DeletePrivilegeCount, void *PrivilegesToDelete, uint32 RestrictedSidCount, void *SidsToRestrict, void *NewTokenHandle)')
|
|
31
|
-
const CreateProcessAsUserW = advapi32.func('int32 __stdcall CreateProcessAsUserW(uint64 hToken, void *lpApplicationName, void *lpCommandLine, void *pa, void *ta, int32 bInherit, uint32 flags, void *env, void *dir, void *si, void *pi)')
|
|
32
|
-
const CreateProcessW = kernel32.func('int32 __stdcall CreateProcessW(void *lpApplicationName, void *lpCommandLine, void *pa, void *ta, int32 bInherit, uint32 flags, void *env, void *dir, void *si, void *pi)')
|
|
33
|
-
const CreateProcessWithTokenW = advapi32.func('int32 __stdcall CreateProcessWithTokenW(uint64 hToken, uint32 logonFlags, void *lpApplicationName, void *lpCommandLine, uint32 flags, void *env, void *dir, void *si, void *pi)')
|
|
34
|
-
|
|
35
|
-
function buildEnvBlock(): Buffer {
|
|
36
|
-
const env: Record<string, string> = {}
|
|
37
|
-
for (const [k, v] of Object.entries(process.env)) if (v !== undefined) env[k] = v
|
|
38
|
-
if (env.SystemRoot === undefined) env.SystemRoot = SystemRoot
|
|
39
|
-
if (env.windir === undefined) env.windir = SystemRoot
|
|
40
|
-
if (env.SystemDrive === undefined) env.SystemDrive = 'C:'
|
|
41
|
-
return Buffer.from(Object.entries(env).map(([k, v]) => `${k}=${v}`).join('\0') + '\0\0', 'utf16le')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function buildAdminSid(): Buffer {
|
|
45
|
-
const b = Buffer.alloc(16)
|
|
46
|
-
b[0] = 1; b[1] = 2; b.set([0, 0, 0, 0, 0, 5], 2)
|
|
47
|
-
b.writeUInt32LE(32, 8); b.writeUInt32LE(544, 12)
|
|
48
|
-
return b
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function hexExit(code: number): string {
|
|
52
|
-
return code === STILL_ACTIVE ? 'STILL_ACTIVE' : (code >= 0x80000000 ? `0x${code.toString(16).toUpperCase()}` : String(code))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface Variant {
|
|
56
|
-
label: string
|
|
57
|
-
api: 'normal' | 'asUser' | 'withToken'
|
|
58
|
-
token: 'plain' | 'restricted'
|
|
59
|
-
env: 'null' | 'block'
|
|
60
|
-
flags: number
|
|
61
|
-
program: 'cmd' | 'whoami' | 'node'
|
|
62
|
-
explicitAppName?: boolean
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const results: string[] = []
|
|
66
|
-
async function runVariant(v: Variant, hToken: bigint, hRestricted: bigint, execPath: string): Promise<void> {
|
|
67
|
-
const dir = mkdtempSync(path.join(tmpdir(), 'car-dbg-'))
|
|
68
|
-
const outFile = path.join(dir, 'out.txt')
|
|
69
|
-
const program = v.program === 'cmd' ? path.join(SystemRoot, 'System32', 'cmd.exe')
|
|
70
|
-
: v.program === 'whoami' ? path.join(SystemRoot, 'System32', 'whoami.exe')
|
|
71
|
-
: execPath
|
|
72
|
-
const cmdline = v.program === 'cmd'
|
|
73
|
-
? `"${program}" /c exit 0`
|
|
74
|
-
: v.program === 'whoami'
|
|
75
|
-
? `"${program}" /priv /fo list`
|
|
76
|
-
: `"${program}" -e process.exit(0)`
|
|
77
|
-
const cmdBuf = Buffer.from(cmdline + '\0', 'utf16le')
|
|
78
|
-
const si = Buffer.alloc(104); si.writeUInt32LE(104, 0)
|
|
79
|
-
const pi = Buffer.alloc(24)
|
|
80
|
-
const envArg = v.env === 'block' ? buildEnvBlock() : null
|
|
81
|
-
const flags = v.env === 'block' ? (v.flags | CREATE_UNICODE_ENVIRONMENT) : v.flags
|
|
82
|
-
const tok = v.token === 'restricted' ? hRestricted : hToken
|
|
83
|
-
let ok = 0
|
|
84
|
-
try {
|
|
85
|
-
if (v.api === 'normal') {
|
|
86
|
-
ok = CreateProcessW(null, cmdBuf, null, null, 0, flags, envArg, null, si, pi)
|
|
87
|
-
} else if (v.api === 'asUser') {
|
|
88
|
-
ok = CreateProcessAsUserW(tok, null, cmdBuf, null, null, 0, flags, envArg, null, si, pi)
|
|
89
|
-
} else {
|
|
90
|
-
ok = CreateProcessWithTokenW(tok, 0, null, cmdBuf, flags, envArg, null, si, pi)
|
|
91
|
-
}
|
|
92
|
-
if (!ok) {
|
|
93
|
-
results.push(`${v.label}: CREATE_FAILED rc=0`)
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
const hProcess = pi.readBigUInt64LE(0)
|
|
97
|
-
const hThread = pi.readBigUInt64LE(8)
|
|
98
|
-
const wait = WaitForSingleObject(hProcess, 30000)
|
|
99
|
-
const codeBuf = Buffer.alloc(4)
|
|
100
|
-
GetExitCodeProcess(hProcess, codeBuf)
|
|
101
|
-
const code = codeBuf.readUInt32LE(0)
|
|
102
|
-
CloseHandle(hThread); CloseHandle(hProcess)
|
|
103
|
-
results.push(`${v.label}: created=1 wait=${wait === 0 ? 'signaled' : 'timeout'} exit=${hexExit(code)}`)
|
|
104
|
-
} catch (e) {
|
|
105
|
-
results.push(`${v.label}: JS_ERROR ${e instanceof Error ? e.message : String(e)}`)
|
|
106
|
-
} finally {
|
|
107
|
-
rmSync(dir, { recursive: true, force: true })
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async function main() {
|
|
112
|
-
console.log('=== win32 FFI debug matrix ===')
|
|
113
|
-
const hTokBuf = Buffer.alloc(8)
|
|
114
|
-
if (!OpenProcessToken(PSEUDO_CURRENT_PROCESS, 0x1 | 0x2 | 0x8, hTokBuf)) throw new Error('OpenProcessToken failed')
|
|
115
|
-
const hToken = hTokBuf.readBigUInt64LE(0)
|
|
116
|
-
const sidBuf = buildAdminSid()
|
|
117
|
-
const hRestrBuf = Buffer.alloc(8)
|
|
118
|
-
if (!CreateRestrictedToken(hToken, 0x1, 1, [{ Sid: sidBuf, Attributes: 0 }], 0, null, 0, null, hRestrBuf)) throw new Error('CreateRestrictedToken failed')
|
|
119
|
-
const hRestricted = hRestrBuf.readBigUInt64LE(0)
|
|
120
|
-
const execPath = process.execPath
|
|
121
|
-
|
|
122
|
-
const matrix: Variant[] = [
|
|
123
|
-
{ label: '01 normal cmd nowin env=null ', api: 'normal', token: 'plain', env: 'null', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
124
|
-
{ label: '02 asUser plain cmd nowin env=null ', api: 'asUser', token: 'plain', env: 'null', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
125
|
-
{ label: '03 asUser plain cmd nowin env=block ', api: 'asUser', token: 'plain', env: 'block', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
126
|
-
{ label: '04 asUser plain cmd DETACH env=block ', api: 'asUser', token: 'plain', env: 'block', flags: DETACHED_PROCESS, program: 'cmd' },
|
|
127
|
-
{ label: '05 asUser plain whoami nowin env=block', api: 'asUser', token: 'plain', env: 'block', flags: CREATE_NO_WINDOW, program: 'whoami' },
|
|
128
|
-
{ label: '06 asUser restr cmd nowin env=null ', api: 'asUser', token: 'restricted', env: 'null', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
129
|
-
{ label: '07 asUser restr cmd nowin env=block ', api: 'asUser', token: 'restricted', env: 'block', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
130
|
-
{ label: '08 asUser restr cmd DETACH env=block ', api: 'asUser', token: 'restricted', env: 'block', flags: DETACHED_PROCESS, program: 'cmd' },
|
|
131
|
-
{ label: '09 asUser restr whoami nowin env=block', api: 'asUser', token: 'restricted', env: 'block', flags: CREATE_NO_WINDOW, program: 'whoami' },
|
|
132
|
-
{ label: '10 withToken plain cmd nowin env=block ', api: 'withToken', token: 'plain', env: 'block', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
133
|
-
{ label: '11 withToken restr cmd nowin env=block ', api: 'withToken', token: 'restricted', env: 'block', flags: CREATE_NO_WINDOW, program: 'cmd' },
|
|
134
|
-
{ label: '12 normal node nowin env=null ', api: 'normal', token: 'plain', env: 'null', flags: CREATE_NO_WINDOW, program: 'node' },
|
|
135
|
-
{ label: '13 asUser restr node nowin env=block', api: 'asUser', token: 'restricted', env: 'block', flags: CREATE_NO_WINDOW, program: 'node' },
|
|
136
|
-
{ label: '14 asUser restr node DETACH env=block ', api: 'asUser', token: 'restricted', env: 'block', flags: DETACHED_PROCESS, program: 'node' },
|
|
137
|
-
]
|
|
138
|
-
for (const v of matrix) await runVariant(v, hToken, hRestricted, execPath)
|
|
139
|
-
console.log(results.join('\n'))
|
|
140
|
-
CloseHandle(hRestricted); CloseHandle(hToken)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
main().catch((e) => { console.error('FATAL:', e instanceof Error ? e.message : e); process.exitCode = 1 })
|