@standardagents/code 0.14.1-issue.650.d27328 → 0.14.1-issue.653.6647dc-linux-x64-gnu

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.
@@ -0,0 +1,152 @@
1
+ libevent.txt
2
+ ============
3
+ Libevent is available for use under the following license, commonly known
4
+ as the 3-clause (or "modified") BSD license:
5
+
6
+ ==============================
7
+ Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
8
+ Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in the
17
+ documentation and/or other materials provided with the distribution.
18
+ 3. The name of the author may not be used to endorse or promote products
19
+ derived from this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ ==============================
32
+
33
+ Portions of Libevent are based on works by others, also made available by
34
+ them under the three-clause BSD license above. The copyright notices are
35
+ available in the corresponding source files; the license is as above. Here's
36
+ a list:
37
+
38
+ log.c:
39
+ Copyright (c) 2000 Dug Song <dugsong@monkey.org>
40
+ Copyright (c) 1993 The Regents of the University of California.
41
+
42
+ strlcpy.c:
43
+ Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
44
+
45
+ win32select.c:
46
+ Copyright (c) 2003 Michael A. Davis <mike@datanerds.net>
47
+
48
+ evport.c:
49
+ Copyright (c) 2007 Sun Microsystems
50
+
51
+ ht-internal.h:
52
+ Copyright (c) 2002 Christopher Clark
53
+
54
+ minheap-internal.h:
55
+ Copyright (c) 2006 Maxim Yegorushkin <maxim.yegorushkin@gmail.com>
56
+
57
+ ==============================
58
+
59
+ The arc4module is available under the following, sometimes called the
60
+ "OpenBSD" license:
61
+
62
+ Copyright (c) 1996, David Mazieres <dm@uun.org>
63
+ Copyright (c) 2008, Damien Miller <djm@openbsd.org>
64
+
65
+ Permission to use, copy, modify, and distribute this software for any
66
+ purpose with or without fee is hereby granted, provided that the above
67
+ copyright notice and this permission notice appear in all copies.
68
+
69
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
70
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
71
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
72
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
73
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
74
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
75
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
76
+
77
+ ==============================
78
+
79
+ The Windows timer code is based on code from libutp, which is
80
+ distributed under this license, sometimes called the "MIT" license.
81
+
82
+
83
+ Copyright (c) 2010 BitTorrent, Inc.
84
+
85
+ Permission is hereby granted, free of charge, to any person obtaining a copy
86
+ of this software and associated documentation files (the "Software"), to deal
87
+ in the Software without restriction, including without limitation the rights
88
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
89
+ copies of the Software, and to permit persons to whom the Software is
90
+ furnished to do so, subject to the following conditions:
91
+
92
+ The above copyright notice and this permission notice shall be included in
93
+ all copies or substantial portions of the Software.
94
+
95
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
98
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
100
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
101
+ THE SOFTWARE.
102
+
103
+
104
+ ncurses.txt
105
+ ===========
106
+ Copyright 2018-2024,2025 Thomas E. Dickey
107
+ Copyright 1998-2017,2018 Free Software Foundation, Inc.
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining a
110
+ copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, distribute with modifications, sublicense, and/or sell
114
+ copies of the Software, and to permit persons to whom the Software is
115
+ furnished to do so, subject to the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be included
118
+ in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
121
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
123
+ IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
124
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
125
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
126
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ Except as contained in this notice, the name(s) of the above copyright
129
+ holders shall not be used in advertising or otherwise to promote the
130
+ sale, use or other dealings in this Software without prior written
131
+ authorization.
132
+
133
+ -- vile:txtmode fc=72
134
+ -- $Id: COPYING,v 1.14 2025/01/04 10:53:46 tom Exp $
135
+
136
+
137
+ tmux.txt
138
+ ========
139
+ Copyright (c) Various Authors
140
+
141
+ Permission to use, copy, modify, and distribute this software for any
142
+ purpose with or without fee is hereby granted, provided that the above
143
+ copyright notice and this permission notice appear in all copies.
144
+
145
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
146
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
147
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
148
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
149
+ WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
150
+ IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
151
+ OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
152
+
package/manifest.json ADDED
@@ -0,0 +1 @@
1
+ {"schema":2,"format":"standard-npm-native-target-v2","repository":"standardagents/code-rs","commit":"6647dc62cf91b02086fdfef2250843f06b65d042","version":"0.14.1-issue.653.6647dc","target":"x86_64-unknown-linux-gnu","runtime":{"tmuxVersion":"3.7","tmuxSha256":"27f6336520fb81d4a4a495b74ae60cb502203cce5a5c4411b2bc320d38855954","accountUpdateProtocol":1,"minimumGlibc":"2.28"},"signing":{"algorithm":"ed25519","keyId":"team-2026-1","platformCodeSignature":"ed25519-only"},"files":[{"path":"bin/standard","size":40005472,"sha256":"cb4f816dac37596499700b15a2162e238c5fb4b2cf4ff379f6c585eea3fdebef"},{"path":"bin/standardd","size":48737664,"sha256":"95df8467976181501e5457346ac48ce46b9492a2ec0782d3855bc408d955b3a4"},{"path":"bin/tmux","size":1433024,"sha256":"27f6336520fb81d4a4a495b74ae60cb502203cce5a5c4411b2bc320d38855954"},{"path":"licenses/THIRD-PARTY.txt","size":6779,"sha256":"fc410e91ff375a3057837d3029ec2626e6110a05f69b6fee7ca4e9f588b1a294"},{"path":"lib/standard-plugin-runner/index.mjs","size":43643,"sha256":"27b33908c2450d03035eca8ff6b1b0795de411d6f7d3845c75c6d3055da79cb8"},{"path":"lib/standard-plugin-runner/worker.mjs","size":66854,"sha256":"ea98bb6824394bef31231820dbff4c51bee02a6bb7b6c925acf67f35a1ffac3b"},{"path":"lib/standard-plugin-runner/loader.mjs","size":9941496,"sha256":"9d8b50fd453aff0e2d0e09124e70b4f8474450abbf32570ed012daae453cf1b7"},{"path":"lib/standard-plugin-runner/sdk.mjs","size":27145,"sha256":"9367dde0ef6b22b7aa3f7e5ad1f67bdfa9c0eb89626442564ee200b98b17b3b7"},{"path":"lib/standard-plugin-runner/runtime.json","size":291,"sha256":"1e243a4eb585411818b42b451651cee9c07ee2945b5a9dd592710346384061f0"},{"path":"lib/standard-plugin-runner/THIRD-PARTY.txt","size":47041,"sha256":"99747b97f9fe386da34e92120cec7ce1806c515409db20adc546b6ecc434f1ca"}]}
package/manifest.sig ADDED
@@ -0,0 +1 @@
1
+ mNxWTrx0k1aAEuKikj7Uksl5Mcqkxtzn8r7qF4s7QT24daLxReZzwZxbrpcFZA+qE+AXwUx3lL1kzIofuI/hDw==
package/package.json CHANGED
@@ -1,42 +1,30 @@
1
1
  {
2
2
  "name": "@standardagents/code",
3
- "version": "0.14.1-issue.650.d27328",
4
- "description": "Platform launcher for the Standard universal terminal network.",
5
- "type": "module",
6
- "license": "UNLICENSED",
3
+ "version": "0.14.1-issue.653.6647dc-linux-x64-gnu",
4
+ "description": "Standard native binaries for linux-x64-gnu.",
7
5
  "repository": {
8
6
  "type": "git",
9
7
  "url": "git+https://github.com/standardagents/code-rs.git"
10
8
  },
11
- "publishConfig": {
12
- "access": "public",
13
- "registry": "https://registry.npmjs.org/"
14
- },
15
- "engines": {
16
- "node": ">=20"
17
- },
18
- "bin": {
19
- "standard": "bin/standard.mjs",
20
- "standardd": "bin/standardd.mjs"
21
- },
9
+ "license": "UNLICENSED",
10
+ "os": [
11
+ "linux"
12
+ ],
13
+ "cpu": [
14
+ "x64"
15
+ ],
16
+ "libc": [
17
+ "glibc"
18
+ ],
22
19
  "files": [
23
20
  "bin",
21
+ "licenses",
24
22
  "lib",
25
- "postinstall.mjs"
23
+ "manifest.json",
24
+ "manifest.sig"
26
25
  ],
27
- "scripts": {
28
- "postinstall": "node postinstall.mjs"
29
- },
30
- "optionalDependencies": {
31
- "@standardagents/code-darwin-arm64": "npm:@standardagents/code@0.14.1-issue.650.d27328-darwin-arm64",
32
- "@standardagents/code-linux-x64-gnu": "npm:@standardagents/code@0.14.1-issue.650.d27328-linux-x64-gnu"
33
- },
34
- "standardUpgrade": {
35
- "schema": 1,
36
- "reader": 1,
37
- "bridge": {
38
- "version": "0.14.1-canary.76909e",
39
- "commit": "76909e97ec56c2ba5490932135642962c4035596"
40
- }
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
41
29
  }
42
30
  }
package/bin/standard.mjs DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { main } from '../lib/launcher.mjs'
3
-
4
- main('standard')
package/bin/standardd.mjs DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { main } from '../lib/launcher.mjs'
3
-
4
- main('standardd')
package/lib/artifact.mjs DELETED
@@ -1,326 +0,0 @@
1
- import { createHash, createPublicKey, verify } from 'node:crypto'
2
- import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync } from 'node:fs'
3
- import { dirname, join } from 'node:path'
4
- import { isPreviewBuild, normalizeBackendProfile } from './backend-profile.mjs'
5
-
6
- export const ARTIFACT_FORMAT = 'standard-npm-native-target-v2'
7
- export const ARTIFACT_FILES = Object.freeze([
8
- 'bin/standard', 'bin/standardd', 'bin/tmux', 'licenses/THIRD-PARTY.txt',
9
- ])
10
- export const BUNDLE_ARTIFACT_FORMAT = 'standard-npm-native-target-v3'
11
- export const BUNDLE_ARTIFACT_FILES = Object.freeze([
12
- // Stapled notarization tickets are distinct from the code signature seals.
13
- 'Standard Code.app/Contents/CodeResources',
14
- 'Standard Code.app/Contents/Info.plist',
15
- 'Standard Code.app/Contents/MacOS/standard',
16
- 'Standard Code.app/Contents/_CodeSignature/CodeResources',
17
- 'Standard Code Daemon.app/Contents/CodeResources',
18
- 'Standard Code Daemon.app/Contents/Info.plist',
19
- 'Standard Code Daemon.app/Contents/MacOS/standardd',
20
- 'Standard Code Daemon.app/Contents/Helpers/tmux',
21
- 'Standard Code Daemon.app/Contents/_CodeSignature/CodeResources',
22
- ...['TMUX-ARTIFACT-MANIFEST.sha256', 'TMUX-ARTIFACT-METADATA.txt',
23
- 'TMUX-BUILD-TOOLS.txt', 'TMUX-OTOOL-L.txt', 'TMUX-SIGNED-RUNTIME.sha256',
24
- 'licenses/libevent.txt', 'licenses/tmux.txt',
25
- ].map(path => `Standard Code Daemon.app/Contents/Resources/tmux/${path}`),
26
- 'licenses/THIRD-PARTY.txt',
27
- ])
28
-
29
- export const RUNNER_ASSET_NAMES = Object.freeze([
30
- 'index.mjs', 'worker.mjs', 'loader.mjs', 'sdk.mjs', 'runtime.json', 'THIRD-PARTY.txt',
31
- ])
32
- export const MAX_RUNNER_ASSET_BYTES = 16 * 1024 * 1024
33
- export const RUNNER_ARTIFACT_FILES = Object.freeze([
34
- ...ARTIFACT_FILES, ...RUNNER_ASSET_NAMES.map(name => `lib/standard-plugin-runner/${name}`),
35
- ])
36
- export const BUNDLE_RUNNER_ARTIFACT_FILES = Object.freeze([
37
- ...BUNDLE_ARTIFACT_FILES,
38
- ...RUNNER_ASSET_NAMES.map(name => `Standard Code Daemon.app/Contents/Resources/plugin-runner/${name}`),
39
- ])
40
-
41
- export function artifactFiles(manifest) {
42
- const hasRunner = manifest.files?.some(file => file.path?.includes('/plugin-runner/') || file.path?.startsWith('lib/standard-plugin-runner/'))
43
- if (manifest.schema === 2 && manifest.format === ARTIFACT_FORMAT
44
- && manifest.target?.endsWith('-unknown-linux-gnu')) return hasRunner ? RUNNER_ARTIFACT_FILES : ARTIFACT_FILES
45
- if (manifest.schema === 3 && manifest.format === BUNDLE_ARTIFACT_FORMAT
46
- && manifest.target?.endsWith('-apple-darwin')) return hasRunner ? BUNDLE_RUNNER_ARTIFACT_FILES : BUNDLE_ARTIFACT_FILES
47
- throw new Error('Native artifact identity is invalid')
48
- }
49
-
50
- export function artifactBinaryPath(manifest, command) {
51
- if (!['standard', 'standardd', 'tmux'].includes(command)) throw new Error('Invalid artifact command')
52
- artifactFiles(manifest)
53
- if (manifest.target.endsWith('-unknown-linux-gnu')) return `bin/${command}`
54
- if (command === 'tmux') return 'Standard Code Daemon.app/Contents/Helpers/tmux'
55
- return `${command === 'standard' ? 'Standard Code' : 'Standard Code Daemon'}.app/Contents/MacOS/${command}`
56
- }
57
-
58
- export function artifactDirectories(files) {
59
- const directories = new Set()
60
- for (const file of files) {
61
- for (let directory = dirname(file); directory !== '.'; directory = dirname(directory)) directories.add(directory)
62
- }
63
- return [...directories].sort()
64
- }
65
-
66
- // Bundle signatures seal resources too: reject unmanifested contents and links
67
- // at every directory level, including links in an executable's ancestors.
68
- export function verifyArtifactTree(root, files, metadata = ['manifest.json', 'manifest.sig', 'package.json']) {
69
- const allowedFiles = new Set([...files, ...metadata])
70
- const allowedDirectories = new Set(artifactDirectories(files))
71
- function visit(relative) {
72
- const path = join(root, relative)
73
- if (!lstatSync(path).isDirectory()) throw new Error(`Invalid artifact directory: ${path}`)
74
- for (const name of readdirSync(path)) {
75
- const child = relative ? `${relative}/${name}` : name
76
- const entry = lstatSync(join(root, child))
77
- if (entry.isDirectory() && allowedDirectories.has(child)) visit(child)
78
- else if (!entry.isFile() || !allowedFiles.has(child)) throw new Error(`Unexpected artifact content: ${child}`)
79
- }
80
- }
81
- visit('')
82
- for (const directory of allowedDirectories) {
83
- if (!lstatSync(join(root, directory)).isDirectory()) throw new Error(`Invalid artifact directory: ${directory}`)
84
- }
85
- }
86
-
87
- // The four native targets the launcher has ever installed. The two deferred
88
- // ones stay so their published history verifies.
89
- export const NATIVE_ARTIFACT_TARGETS = Object.freeze([
90
- 'aarch64-apple-darwin', 'x86_64-apple-darwin',
91
- 'aarch64-unknown-linux-gnu', 'x86_64-unknown-linux-gnu',
92
- ])
93
- // The browser viewer runtime: a fifth, distinct artifact kind that the same
94
- // build workers compile and sign. It never installs through the launcher.
95
- export const WEB_ARTIFACT_TARGET = 'wasm32-unknown-unknown'
96
- export const ARTIFACT_TARGETS = Object.freeze([...NATIVE_ARTIFACT_TARGETS, WEB_ARTIFACT_TARGET])
97
-
98
- // Web artifact (schema 4): the wasm-bindgen output, the bundled fonts, their
99
- // licenses, and the build record, at the artifact root. The font and license
100
- // sets vary with the pinned font list, so the manifest enumerates what the
101
- // build produced and the verifier checks each path against these rules.
102
- export const WEB_ARTIFACT_FORMAT = 'standard-npm-web-target-v1'
103
- export const WEB_ARTIFACT_SCHEMA = 4
104
- export const WEB_ARTIFACT_REQUIRED_FILES = Object.freeze([
105
- 'build.json', 'pkg/standard_web.js', 'pkg/standard_web_bg.wasm',
106
- ])
107
- export const WEB_ARTIFACT_OPTIONAL_FILES = Object.freeze([
108
- 'pkg/standard_web.d.ts', 'pkg/standard_web_bg.wasm.d.ts',
109
- ])
110
- // One level deep, one file kind each; at least one entry of each.
111
- export const WEB_ARTIFACT_DIRECTORIES = Object.freeze({ fonts: /\.ttf$/, licenses: /\.txt$/ })
112
- export const WEB_ARTIFACT_FILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/
113
- export const MAX_WEB_ASSET_BYTES = 64 * 1024 * 1024
114
-
115
- // Whether one artifact-relative path may appear in a web artifact.
116
- export function webArtifactPathAllowed(path) {
117
- if (typeof path !== 'string') return false
118
- const parts = path.split('/')
119
- if (!parts.every(part => WEB_ARTIFACT_FILE_NAME.test(part))) return false
120
- if (WEB_ARTIFACT_REQUIRED_FILES.includes(path) || WEB_ARTIFACT_OPTIONAL_FILES.includes(path)) return true
121
- return parts.length === 2 && Boolean(WEB_ARTIFACT_DIRECTORIES[parts[0]]?.test(parts[1]))
122
- }
123
-
124
- // Check a complete web file list: every path allowed, every required file
125
- // present, each directory non-empty, no duplicates. Returns the sorted list.
126
- export function webArtifactFileList(paths) {
127
- if (!Array.isArray(paths) || paths.some(path => !webArtifactPathAllowed(path))) {
128
- throw new Error('Web artifact file manifest is invalid')
129
- }
130
- const files = [...paths].sort()
131
- if (new Set(files).size !== files.length) throw new Error('Web artifact file manifest is invalid')
132
- const missing = WEB_ARTIFACT_REQUIRED_FILES.filter(path => !files.includes(path))
133
- for (const directory of Object.keys(WEB_ARTIFACT_DIRECTORIES)) {
134
- if (!files.some(path => path.startsWith(`${directory}/`))) missing.push(`${directory}/`)
135
- }
136
- if (missing.length) throw new Error(`Web artifact is incomplete: missing ${missing.join(', ')}`)
137
- return files
138
- }
139
-
140
- // Enumerate a built web artifact root as the file list its manifest binds.
141
- // Every entry must be a regular file the rules allow; anything else fails.
142
- export function webArtifactFilesOnDisk(root, metadata = ['manifest.json', 'manifest.sig']) {
143
- const files = []
144
- function visit(relative) {
145
- for (const name of readdirSync(join(root, relative))) {
146
- const child = relative ? `${relative}/${name}` : name
147
- if (!relative && metadata.includes(child)) continue
148
- const entry = lstatSync(join(root, child))
149
- if (entry.isDirectory() && !relative && Object.hasOwn(WEB_ARTIFACT_DIRECTORIES, child)) visit(child)
150
- else if (entry.isDirectory() && !relative && child === 'pkg') visit(child)
151
- else if (!entry.isFile() || !webArtifactPathAllowed(child)) throw new Error(`Unexpected artifact content: ${child}`)
152
- else files.push(child)
153
- }
154
- }
155
- visit('')
156
- return webArtifactFileList(files)
157
- }
158
- // Public trust anchor, not a credential. Never obtain the verification key
159
- // from the package being verified or a mutable registry response.
160
- export const ARTIFACT_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
161
- MCowBQYDK2VwAyEAk+Ndu0WtdSgUFkraXP5CAUlQqzm+EN/My2AwkoPOMqg=
162
- -----END PUBLIC KEY-----
163
- `
164
-
165
- export function validArtifactVersion(version) {
166
- return typeof version === 'string'
167
- && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(version)
168
- && (version.match(/^[^-]+-(.*)$/)?.[1].split('.') ?? []).every(part => !/^0\d+$/.test(part))
169
- }
170
-
171
- function regularFile(path, limit) {
172
- const descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW)
173
- try {
174
- const metadata = fstatSync(descriptor)
175
- if (!metadata.isFile() || metadata.size < 1 || metadata.size > limit) throw new Error(`Invalid artifact file: ${path}`)
176
- return { descriptor, metadata }
177
- } catch (error) { closeSync(descriptor); throw error }
178
- }
179
-
180
- function boundedBytes(path, limit) {
181
- const { descriptor } = regularFile(path, limit)
182
- try {
183
- const buffer = Buffer.alloc(limit + 1)
184
- let size = 0
185
- while (size <= limit) {
186
- const count = readSync(descriptor, buffer, size, buffer.length - size, null)
187
- if (!count) return buffer.subarray(0, size)
188
- size += count
189
- }
190
- throw new Error(`Artifact exceeds size limit: ${path}`)
191
- } finally { closeSync(descriptor) }
192
- }
193
-
194
- // Read and authenticate an artifact's manifest against the pinned key. The
195
- // bytes that were signed are the bytes parsed; nothing is trusted before this.
196
- function signedManifest(root, publicKey, label) {
197
- if (!lstatSync(root).isDirectory()) throw new Error(`Invalid artifact directory: ${root}`)
198
- const bytes = boundedBytes(join(root, 'manifest.json'), 64 * 1024)
199
- const signature = boundedBytes(join(root, 'manifest.sig'), 256).toString('utf8').trim()
200
- const key = createPublicKey(publicKey)
201
- if (key.asymmetricKeyType !== 'ed25519' || !verify(null, bytes, key, Buffer.from(signature, 'base64'))) {
202
- throw new Error(`${label} artifact signature is invalid`)
203
- }
204
- return JSON.parse(bytes)
205
- }
206
-
207
- // Every manifested file must exist with exactly its signed size and digest.
208
- function verifyFileDigests(root, manifest, limitFor, label) {
209
- const buffer = Buffer.alloc(1024 * 1024)
210
- for (const file of manifest.files) {
211
- if (!Number.isSafeInteger(file.size) || !/^[0-9a-f]{64}$/.test(file.sha256)) throw new Error(`${label} artifact file metadata is invalid`)
212
- const path = join(root, file.path)
213
- const { descriptor, metadata } = regularFile(path, limitFor(file.path))
214
- try {
215
- if (metadata.size !== file.size) throw new Error(`${label} artifact size mismatch: ${file.path}`)
216
- const hash = createHash('sha256')
217
- let size = 0
218
- for (;;) {
219
- const count = readSync(descriptor, buffer, 0, buffer.length, null)
220
- if (!count) break
221
- size += count
222
- if (size > file.size) throw new Error(`${label} artifact grew while verifying: ${file.path}`)
223
- hash.update(buffer.subarray(0, count))
224
- }
225
- if (size !== file.size || hash.digest('hex') !== file.sha256) throw new Error(`${label} artifact digest mismatch: ${file.path}`)
226
- } finally { closeSync(descriptor) }
227
- }
228
- }
229
-
230
- export function verifyNativeArtifact(root, expected = {}, publicKey = ARTIFACT_PUBLIC_KEY) {
231
- const manifest = signedManifest(root, publicKey, 'Native')
232
- const files = artifactFiles(manifest)
233
- if (manifest.repository !== 'standardagents/code-rs'
234
- || !NATIVE_ARTIFACT_TARGETS.includes(manifest.target)
235
- || !/^[0-9a-f]{40}$/.test(manifest.commit)
236
- || !validArtifactVersion(manifest.version)
237
- || ['commit', 'version', 'target'].some(name => expected[name] != null && manifest[name] !== expected[name])
238
- || manifest.signing?.algorithm !== 'ed25519') throw new Error('Native artifact identity is invalid')
239
- if (Object.hasOwn(manifest, 'backendProfile') && (manifest.backendProfile == null || manifest.backendProfile === '')) {
240
- throw new Error('Native artifact backend profile cannot be null')
241
- }
242
- const backendProfile = normalizeBackendProfile(manifest.backendProfile)
243
- if (backendProfile && !isPreviewBuild(manifest.version)) {
244
- throw new Error('Native artifact preview backend profile is not valid for this version')
245
- }
246
- if (!Array.isArray(manifest.files) || manifest.files.map(file => file.path).sort().join(',') !== [...files].sort().join(',')) {
247
- throw new Error('Native artifact file manifest is invalid')
248
- }
249
- const runnerFiles = manifest.target.endsWith('-apple-darwin')
250
- ? BUNDLE_RUNNER_ARTIFACT_FILES.slice(BUNDLE_ARTIFACT_FILES.length)
251
- : RUNNER_ARTIFACT_FILES.slice(ARTIFACT_FILES.length)
252
- if (!manifest.files.some(file => runnerFiles.includes(file.path))) {
253
- for (const path of runnerFiles) {
254
- try { lstatSync(join(root, path)) }
255
- catch (error) { if (error.code === 'ENOENT') continue; throw error }
256
- throw new Error('Native artifact contains unsigned plugin runner files')
257
- }
258
- }
259
- if (manifest.schema === 3) verifyArtifactTree(root, files)
260
- else for (const directory of artifactDirectories(files)) {
261
- if (!lstatSync(join(root, directory)).isDirectory()) throw new Error(`Invalid artifact directory: ${directory}`)
262
- }
263
- const tmux = manifest.files.find(file => file.path === artifactBinaryPath(manifest, 'tmux'))
264
- if (manifest.runtime?.tmuxVersion !== '3.7' || manifest.runtime.tmuxSha256 !== tmux.sha256) {
265
- throw new Error('Native artifact tmux identity is invalid')
266
- }
267
- const protocol = manifest.runtime.accountUpdateProtocol
268
- if (protocol != null && (!Number.isSafeInteger(protocol) || protocol < 1 || protocol > 0xffff_ffff)) {
269
- throw new Error('Native artifact account update protocol is invalid')
270
- }
271
- if (manifest.target.endsWith('-apple-darwin')
272
- && (manifest.signing.platformCodeSignature !== 'apple-developer-id'
273
- || manifest.signing.notarization?.status !== 'Accepted'
274
- || !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(manifest.signing.notarization?.submissionId ?? ''))) {
275
- throw new Error('macOS artifact lacks signed notarization acceptance')
276
- }
277
- if (manifest.target.endsWith('-unknown-linux-gnu')
278
- && !/^\d+\.\d+(?:\.\d+)?$/.test(manifest.runtime.minimumGlibc ?? '')) throw new Error('Linux artifact lacks its glibc requirement')
279
- verifyFileDigests(root, manifest, path => runnerFiles.includes(path) ? MAX_RUNNER_ASSET_BYTES : 256 * 1024 * 1024, 'Native')
280
- return manifest
281
- }
282
-
283
- // Verify a web artifact root: the Ed25519 signature, the schema-4 identity,
284
- // the file rules, the exact on-disk file set (nothing unmanifested, no
285
- // links), the build record, and every digest. Returns the manifest.
286
- export function verifyWebArtifact(root, expected = {}, publicKey = ARTIFACT_PUBLIC_KEY) {
287
- const manifest = signedManifest(root, publicKey, 'Web')
288
- if (manifest.schema !== WEB_ARTIFACT_SCHEMA || manifest.format !== WEB_ARTIFACT_FORMAT
289
- || manifest.target !== WEB_ARTIFACT_TARGET
290
- || manifest.repository !== 'standardagents/code-rs'
291
- || !/^[0-9a-f]{40}$/.test(manifest.commit)
292
- || !validArtifactVersion(manifest.version)
293
- || ['commit', 'version', 'target'].some(name => expected[name] != null && manifest[name] !== expected[name])
294
- || manifest.signing?.algorithm !== 'ed25519') throw new Error('Web artifact identity is invalid')
295
- if (Object.hasOwn(manifest, 'backendProfile') && (manifest.backendProfile == null || manifest.backendProfile === '')) {
296
- throw new Error('Web artifact backend profile cannot be null')
297
- }
298
- const backendProfile = normalizeBackendProfile(manifest.backendProfile)
299
- if (backendProfile && !isPreviewBuild(manifest.version)) {
300
- throw new Error('Web artifact preview backend profile is not valid for this version')
301
- }
302
- if (!Array.isArray(manifest.files)) throw new Error('Web artifact file manifest is invalid')
303
- const files = webArtifactFileList(manifest.files.map(file => file?.path))
304
- verifyArtifactTree(root, files)
305
- verifyFileDigests(root, manifest, () => MAX_WEB_ASSET_BYTES, 'Web')
306
- // The build record is the identity the bundle itself reports; it must name
307
- // the signed build, not a local or foreign one.
308
- let record
309
- try { record = JSON.parse(boundedBytes(join(root, 'build.json'), 4096)) } catch { record = null }
310
- if (record?.schema !== 1 || record.commit !== manifest.commit || record.version !== manifest.version) {
311
- throw new Error('Web artifact build record does not name the signed build')
312
- }
313
- return manifest
314
- }
315
-
316
- export function requireCompatibleGlibc(manifest, runtimeVersion) {
317
- if (!manifest.target.endsWith('-unknown-linux-gnu')) return
318
- const minimum = manifest.runtime.minimumGlibc
319
- if (!/^\d+\.\d+(?:\.\d+)?$/.test(runtimeVersion ?? '')) throw new Error('Cannot determine this machine’s glibc version')
320
- const actual = runtimeVersion.split('.').map(Number)
321
- const required = minimum.split('.').map(Number)
322
- for (let index = 0; index < 3; index++) {
323
- if ((actual[index] ?? 0) > (required[index] ?? 0)) return
324
- if ((actual[index] ?? 0) < (required[index] ?? 0)) throw new Error(`This Standard build requires glibc ${minimum}; this machine has ${runtimeVersion}`)
325
- }
326
- }