agents-bridge 0.3.12 → 0.3.14

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.
Files changed (34) hide show
  1. package/dist/agents/cli-runner.d.ts +18 -0
  2. package/dist/agents/cli-runner.d.ts.map +1 -1
  3. package/dist/agents/cli-runner.js +35 -19
  4. package/dist/agents/cli-runner.js.map +1 -1
  5. package/dist/agents/codex-app-server-runtime.d.ts.map +1 -1
  6. package/dist/agents/codex-app-server-runtime.js +2 -1
  7. package/dist/agents/codex-app-server-runtime.js.map +1 -1
  8. package/dist/agents/windows-model-control-security.d.ts +1 -0
  9. package/dist/agents/windows-model-control-security.d.ts.map +1 -1
  10. package/dist/agents/windows-model-control-security.js +20 -15
  11. package/dist/agents/windows-model-control-security.js.map +1 -1
  12. package/dist/channels/botlink.d.ts +7 -0
  13. package/dist/channels/botlink.d.ts.map +1 -1
  14. package/dist/channels/botlink.js +33 -20
  15. package/dist/channels/botlink.js.map +1 -1
  16. package/dist/channels/mention-gating.d.ts +12 -0
  17. package/dist/channels/mention-gating.d.ts.map +1 -1
  18. package/dist/channels/mention-gating.js +20 -0
  19. package/dist/channels/mention-gating.js.map +1 -1
  20. package/dist/cli/cmd-start.d.ts.map +1 -1
  21. package/dist/cli/cmd-start.js +8 -4
  22. package/dist/cli/cmd-start.js.map +1 -1
  23. package/dist/config/zod-schema.d.ts +26 -26
  24. package/dist/text-diagnostics.d.ts +14 -0
  25. package/dist/text-diagnostics.d.ts.map +1 -0
  26. package/dist/text-diagnostics.js +10 -0
  27. package/dist/text-diagnostics.js.map +1 -0
  28. package/dist/types/index.d.ts +14 -1
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/docs/WEM01-windows-validation.md +46 -0
  31. package/package.json +5 -2
  32. package/scripts/windows-acl-json-smoke.mjs +54 -0
  33. package/scripts/windows-log-diagnostics.mjs +23 -0
  34. package/scripts/windows-smoke.mjs +17 -1
@@ -0,0 +1,54 @@
1
+ // No filesystem, ACL, account, configuration or network access in the probe.
2
+ // Run the exact production batch protocol under Windows PowerShell5.1, with
3
+ // an in-memory inspection fixture so this can run before the full ACL suite.
4
+ import assert from 'node:assert/strict'
5
+ import { execFile } from 'node:child_process'
6
+ import { promisify } from 'node:util'
7
+ import { resolve, win32 } from 'node:path'
8
+ import { fileURLToPath } from 'node:url'
9
+ import { WINDOWS_ACL_BATCH_PROTOCOL } from '../dist/agents/windows-model-control-security.js'
10
+
11
+ export async function checkWindowsAclBatchProtocol(protocol = WINDOWS_ACL_BATCH_PROTOCOL) {
12
+ if (process.platform !== 'win32') throw new Error('WINDOWS_NATIVE_REQUIRED: run with native Windows PowerShell5.1')
13
+ const cases = [1, 2, 3].map(count => Array.from({ length: count }, (_, index) => ({
14
+ index, path: `C:\\fixture (中文)\\Agent & ${index}`, kind: index % 2 ? 'file' : 'directory', privateDirectory: index === 0,
15
+ })))
16
+ const script = `
17
+ $ErrorActionPreference='Stop'
18
+ $ProgressPreference='SilentlyContinue'
19
+ [Console]::OutputEncoding=[Text.UTF8Encoding]::new($false)
20
+ if ($PSVersionTable.PSVersion.Major -ne 5 -or $PSVersionTable.PSVersion.Minor -ne 1) { throw 'WINDOWS_POWERSHELL_5_1_REQUIRED' }
21
+ function Inspect-ControlAcl($target, $kind, $privateDirectory) {
22
+ @{ target=$target; kind=$kind; privateDirectory=$privateDirectory }
23
+ }
24
+ $payloads = ConvertFrom-Json -InputObject $env:WMC01_JSON_CASES
25
+ foreach ($payload in $payloads) {
26
+ $env:AGENTS_BRIDGE_ACL_REQUESTS = $payload
27
+ ${protocol}
28
+ }
29
+ `
30
+ const executable = win32.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
31
+ const { stdout } = await promisify(execFile)(executable, [
32
+ '-NoLogo', '-NoProfile', '-NonInteractive', '-EncodedCommand', Buffer.from(script, 'utf16le').toString('base64'),
33
+ ], { env: { ...process.env, WMC01_JSON_CASES: JSON.stringify(cases.map(entries => JSON.stringify(entries))) }, windowsHide: true, timeout: 30_000, maxBuffer: 64 * 1024 })
34
+ const replies = stdout.replace(/^\uFEFF/, '').trim().split(/\r?\n/).map(line => JSON.parse(line))
35
+ assert.equal(replies.length, cases.length)
36
+ replies.forEach((reply, caseIndex) => {
37
+ assert.ok(Array.isArray(reply)); assert.equal(reply.length, cases[caseIndex].length)
38
+ reply.forEach((entry, index) => {
39
+ assert.equal(entry.index, index); assert.equal(entry.ok, true)
40
+ const expected = cases[caseIndex][index]
41
+ assert.deepEqual(entry.snapshot, { target: expected.path, kind: expected.kind, privateDirectory: expected.privateDirectory })
42
+ })
43
+ })
44
+ return { status: 'PASSED', host: 'Windows PowerShell5.1', requestCounts: [1, 2, 3], stateOrAclChanges: false, networkCalls: 0 }
45
+ }
46
+
47
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
48
+ if (process.platform !== 'win32') {
49
+ console.error('WINDOWS_NATIVE_REQUIRED: run with native Windows PowerShell5.1')
50
+ process.exitCode = 2
51
+ } else {
52
+ console.log(JSON.stringify(await checkWindowsAclBatchProtocol()))
53
+ }
54
+ }
@@ -0,0 +1,23 @@
1
+ // Read-only diagnostic: no locale changes, no repair/re-encoding of existing logs.
2
+ import { readFileSync, writeFileSync } from 'node:fs'
3
+ import { createHash } from 'node:crypto'
4
+ const [mode, path] = process.argv.slice(2)
5
+ if (!path || !['--inspect', '--fixture'].includes(mode)) {
6
+ console.error('Usage: node scripts/windows-log-diagnostics.mjs --inspect FILE | --fixture NEW_FILE')
7
+ process.exit(2)
8
+ }
9
+ if (mode === '--fixture') {
10
+ writeFileSync(path, JSON.stringify({ msg: '中文日志 😀 mixed English 日本語', marker: 'WEM01' }) + '\n', { encoding: 'utf8', flag: 'wx' })
11
+ }
12
+ const bytes = readFileSync(path)
13
+ let text
14
+ try { text = new TextDecoder('utf-8', { fatal: true }).decode(bytes) }
15
+ catch { console.log(JSON.stringify({ validUtf8: false, bytes: bytes.length, diagnosis: 'Not valid UTF-8; preserve source bytes and check writer/redirection encoding.' })); process.exit(1) }
16
+ let invalidJsonLines = 0
17
+ const lines = text.split(/\r?\n/).filter(Boolean)
18
+ for (const line of lines) { try { JSON.parse(line) } catch { invalidJsonLines++ } }
19
+ console.log(JSON.stringify({ platform: process.platform, node: process.version, validUtf8: true,
20
+ bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex'),
21
+ lines: lines.length, invalidJsonLines, replacementCharacters: [...text].filter(c => c === '\ufffd').length,
22
+ diagnosis: 'Valid UTF-8 does not prove source text is correct. Compare original source; explicitly read as UTF-8 in the viewer.' }))
23
+ if (invalidJsonLines) process.exitCode = 1
@@ -1,3 +1,4 @@
1
+ import { checkWindowsAclBatchProtocol } from './windows-acl-json-smoke.mjs'
1
2
  // Run against the built/installed package on native Windows. No real model,
2
3
  // registry request, production account, or current Bridge configuration is used.
3
4
  import assert from 'node:assert/strict'
@@ -9,7 +10,7 @@ import { tmpdir } from 'node:os'
9
10
  import { join, win32 } from 'node:path'
10
11
  import { once } from 'node:events'
11
12
  import { spawn } from '../dist/agents/platform-spawn.js'
12
- import { ensureWindowsModelControlSecurity } from '../dist/agents/windows-model-control-security.js'
13
+ import { ensureWindowsModelControlSecurity, WINDOWS_ACL_BATCH_PROTOCOL } from '../dist/agents/windows-model-control-security.js'
13
14
  import { createModelControlFileAccess } from '../dist/agents/model-control-files.js'
14
15
  import { agentStatePath } from '../dist/config/paths.js'
15
16
  import { automaticModelControl } from '../dist/agents/model-auto-binding.js'
@@ -209,3 +210,18 @@ test('native batched ACL isolates rejected target and preserves healthy peers',
209
210
  await ensureWindowsModelControlSecurity(root, 'directory')
210
211
  progress('batched ACL failure isolation and subsequent check completed')
211
212
  })
213
+
214
+
215
+ test('native Windows PowerShell5.1 production batch protocol enumerates1/2/3requests with scalar indexes', { timeout: 60_000 }, async () => {
216
+ const nested = WINDOWS_ACL_BATCH_PROTOCOL.replace(
217
+ '$requests = ConvertFrom-Json -InputObject $env:AGENTS_BRIDGE_ACL_REQUESTS',
218
+ '$requests = @(ConvertFrom-Json -InputObject $env:AGENTS_BRIDGE_ACL_REQUESTS)',
219
+ )
220
+ assert.notEqual(nested, WINDOWS_ACL_BATCH_PROTOCOL)
221
+ // Execute the prior broken protocol too: only an actual shape assertion
222
+ // failure is accepted, never a missing host/process or script error.
223
+ await assert.rejects(checkWindowsAclBatchProtocol(nested), { code: 'ERR_ASSERTION' })
224
+ const result = await checkWindowsAclBatchProtocol()
225
+ assert.deepEqual(result.requestCounts, [1, 2, 3])
226
+ progress('Windows PowerShell5.1 production batch JSON shapes passed1/2/3requests')
227
+ })