@1667-ai/cli 0.0.0 → 0.1.2-beta.3

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/LICENSE ADDED
@@ -0,0 +1,200 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works, alongside or as an addendum to
119
+ the NOTICE text from the Work, provided that such additional
120
+ attribution notices cannot be construed as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that a
184
+ file or class name and description of purpose be included on the
185
+ same "printed page" as the copyright notice for easier
186
+ identification within third-party archives.
187
+
188
+ Copyright [yyyy] [name of copyright owner]
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ 1667
2
+ Copyright 2026 1667.ai
3
+
4
+ This product includes software developed by 1667.ai.
package/bin/1667.js CHANGED
@@ -1,7 +1,496 @@
1
1
  #!/usr/bin/env node
2
- process.stderr.write(
3
- "1667 is not released yet.\n" +
4
- "This package name is reserved. It contains no program.\n" +
5
- "Build from source: https://github.com/1667-ai/1667\n"
6
- );
7
- process.exit(1);
2
+
3
+ import { execFileSync, spawn } from "node:child_process";
4
+ import { closeSync, lstatSync, openSync, readFileSync, readSync, realpathSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ // This file ships standalone. test/release-launcher.test.ts enforces exact
9
+ // parity with shared/release-targets.ts, the canonical typed release policy.
10
+ export const LAUNCHER_PACKAGE_NAME = "@1667-ai/cli";
11
+ export const LAUNCHER_SOURCE_URL = "https://github.com/1667-ai/1667";
12
+ // Held targets stay in this table. Dropping one would make its platform report
13
+ // as unsupported, which is a different problem with a different fix: the
14
+ // platform is supported and builds from source, and only its package is
15
+ // withheld. Whether anything still verifies that build is what the hold reason
16
+ // says, so these strings are copied from the canonical policy verbatim.
17
+ export const LAUNCHER_RELEASE_TARGETS = Object.freeze({
18
+ "darwin-arm64": Object.freeze({
19
+ packageName: "@1667-ai/darwin-arm64",
20
+ os: "darwin",
21
+ cpu: "arm64",
22
+ libc: null,
23
+ executable: "bin/1667",
24
+ minimumCpuFeature: null,
25
+ minimumMacosVersion: "13.0",
26
+ minimumGlibcVersion: null,
27
+ heldFromPublication: null
28
+ }),
29
+ "darwin-x64": Object.freeze({
30
+ packageName: "@1667-ai/darwin-x64",
31
+ os: "darwin",
32
+ cpu: "x64",
33
+ libc: null,
34
+ executable: "bin/1667",
35
+ minimumCpuFeature: "sse4.2",
36
+ minimumMacosVersion: "13.0",
37
+ minimumGlibcVersion: null,
38
+ heldFromPublication: null
39
+ }),
40
+ "linux-arm64": Object.freeze({
41
+ packageName: "@1667-ai/linux-arm64",
42
+ os: "linux",
43
+ cpu: "arm64",
44
+ libc: "glibc",
45
+ executable: "bin/1667",
46
+ minimumCpuFeature: null,
47
+ minimumMacosVersion: null,
48
+ minimumGlibcVersion: "2.17",
49
+ heldFromPublication: null
50
+ }),
51
+ "linux-x64": Object.freeze({
52
+ packageName: "@1667-ai/linux-x64",
53
+ os: "linux",
54
+ cpu: "x64",
55
+ libc: "glibc",
56
+ executable: "bin/1667",
57
+ minimumCpuFeature: "sse4.2",
58
+ minimumMacosVersion: null,
59
+ minimumGlibcVersion: "2.17",
60
+ heldFromPublication: null
61
+ }),
62
+ "windows-x64": Object.freeze({
63
+ packageName: "@1667-ai/windows-x64",
64
+ os: "win32",
65
+ cpu: "x64",
66
+ libc: null,
67
+ executable: "bin/1667.exe",
68
+ minimumCpuFeature: null,
69
+ minimumMacosVersion: null,
70
+ minimumGlibcVersion: null,
71
+ heldFromPublication: "CI does not build the Windows platform work at present, "
72
+ + "so it is unverified, and maintainers have not approved it for publication"
73
+ })
74
+ });
75
+ const BUILD_MANIFEST_KEYS = new Set([
76
+ "schemaVersion",
77
+ "product",
78
+ "productVersion",
79
+ "sourceCommit",
80
+ "buildTimestamp",
81
+ "packageName",
82
+ "artifactTarget"
83
+ ]);
84
+ const MAX_JSON_BYTES = 64 * 1024;
85
+ const MAX_HOST_PROBE_BYTES = 1024 * 1024;
86
+ const CPU_INFO_CHUNK_BYTES = 64 * 1024;
87
+ const MAX_CPU_INFO_LINE_BYTES = 64 * 1024;
88
+ const HOST_PROBE_TIMEOUT_MS = 2_000;
89
+
90
+ export function resolveLaunchPlan(options = {}) {
91
+ const { target, policy } = resolveLaunchTarget(options);
92
+ return resolvePackageLaunchPlan(options, target, policy);
93
+ }
94
+
95
+ export function prepareLaunch(options = {}, observeHost = observeHostCompatibility) {
96
+ const { target, policy } = resolveLaunchTarget(options);
97
+ assertHostCompatibility(target, policy, observeHost(target));
98
+ return resolvePackageLaunchPlan(options, target, policy);
99
+ }
100
+
101
+ function resolveLaunchTarget(options) {
102
+ const platform = options.platform ?? process.platform;
103
+ const arch = options.arch ?? process.arch;
104
+ const target = selectTarget(platform, arch);
105
+ const policy = LAUNCHER_RELEASE_TARGETS[target];
106
+ // A held target has no published package, so no install can supply one. Refuse
107
+ // before touching the filesystem: what a user is told must not depend on what
108
+ // a stray directory happens to contain.
109
+ if (policy.heldFromPublication !== null) {
110
+ throw new Error(heldTargetRefusal(target, policy));
111
+ }
112
+ return { target, policy };
113
+ }
114
+
115
+ function resolvePackageLaunchPlan(options, target, policy) {
116
+ const args = options.args ?? process.argv.slice(2);
117
+ const launcherRoot = realpathSync(
118
+ options.launcherRoot
119
+ ?? path.dirname(path.dirname(fileURLToPath(import.meta.url)))
120
+ );
121
+
122
+ const launcherPackage = readBoundedJson(path.join(launcherRoot, "package.json"));
123
+ const launcherBuild = parseBuildManifest(
124
+ readBoundedJson(path.join(launcherRoot, "build-manifest.json")),
125
+ LAUNCHER_PACKAGE_NAME,
126
+ "launcher"
127
+ );
128
+ if (launcherPackage.name !== LAUNCHER_PACKAGE_NAME
129
+ || launcherPackage.version !== launcherBuild.productVersion) {
130
+ throw new Error("Launcher package and build manifest disagree");
131
+ }
132
+ const dependencyVersion = launcherPackage.optionalDependencies?.[policy.packageName];
133
+ if (dependencyVersion !== launcherPackage.version) {
134
+ throw new Error(`Launcher does not pin ${policy.packageName} at its exact version`);
135
+ }
136
+
137
+ let platformRoot;
138
+ try {
139
+ platformRoot = resolveLocalPlatformRoot(launcherRoot, policy.packageName);
140
+ } catch {
141
+ throw new Error(
142
+ `Missing ${policy.packageName}@${launcherPackage.version}; reinstall 1667 for ${target}`
143
+ );
144
+ }
145
+ const platformPackagePath = path.join(platformRoot, "package.json");
146
+ const platformPackage = readBoundedJson(platformPackagePath);
147
+ const platformBuild = parseBuildManifest(
148
+ readBoundedJson(path.join(platformRoot, "build-manifest.json")),
149
+ policy.packageName,
150
+ target
151
+ );
152
+ if (platformPackage.name !== policy.packageName
153
+ || platformPackage.version !== launcherPackage.version
154
+ || platformBuild.productVersion !== launcherBuild.productVersion
155
+ || platformBuild.sourceCommit !== launcherBuild.sourceCommit
156
+ || platformBuild.buildTimestamp !== launcherBuild.buildTimestamp) {
157
+ throw new Error("Launcher and platform package identities disagree");
158
+ }
159
+ const libcMatches = policy.libc === null
160
+ ? !Object.hasOwn(platformPackage, "libc")
161
+ : singleValue(platformPackage.libc, policy.libc);
162
+ if (!singleValue(platformPackage.os, policy.os)
163
+ || !singleValue(platformPackage.cpu, policy.cpu)
164
+ || !libcMatches) {
165
+ throw new Error(`${policy.packageName} declares the wrong target`);
166
+ }
167
+
168
+ const executable = path.join(platformRoot, policy.executable);
169
+ const stat = lstatSync(executable);
170
+ if (!stat.isFile() || stat.isSymbolicLink()) {
171
+ throw new Error(`${policy.packageName} executable is not a regular file`);
172
+ }
173
+ return Object.freeze({
174
+ launcherRoot,
175
+ platformRoot,
176
+ executable,
177
+ args: Object.freeze([...args]),
178
+ target,
179
+ packageName: policy.packageName,
180
+ productVersion: launcherBuild.productVersion,
181
+ sourceCommit: launcherBuild.sourceCommit
182
+ });
183
+ }
184
+
185
+ function resolveLocalPlatformRoot(launcherRoot, packageName) {
186
+ const peerRoot = path.resolve(
187
+ launcherRoot,
188
+ ...LAUNCHER_PACKAGE_NAME.split("/").map(() => "..")
189
+ );
190
+ const candidates = [path.join(launcherRoot, "node_modules", packageName)];
191
+ if (path.basename(peerRoot) === "node_modules") {
192
+ candidates.push(path.join(peerRoot, packageName));
193
+ }
194
+ const resolved = [];
195
+ for (const candidate of new Set(candidates)) {
196
+ try {
197
+ const info = lstatSync(candidate);
198
+ if (!info.isDirectory() || info.isSymbolicLink()) continue;
199
+ if (realpathSync(candidate) !== candidate) continue;
200
+ readBoundedJson(path.join(candidate, "package.json"));
201
+ resolved.push(candidate);
202
+ } catch {
203
+ // A missing or unsafe documented npm layout is not a candidate.
204
+ }
205
+ }
206
+ if (resolved.length !== 1) {
207
+ throw new Error(`Expected one local ${packageName} package`);
208
+ }
209
+ return resolved[0];
210
+ }
211
+
212
+ export function selectTarget(platform, arch) {
213
+ const key = `${platform === "win32" ? "windows" : platform}-${arch}`;
214
+ if (!Object.hasOwn(LAUNCHER_RELEASE_TARGETS, key)) {
215
+ throw new Error(`Unsupported 1667 platform: ${platform}-${arch}`);
216
+ }
217
+ return key;
218
+ }
219
+
220
+ /**
221
+ * Kept byte-identical with `heldTargetRefusal` in shared/release-targets.ts; a
222
+ * test asserts the two produce the same string for the same target.
223
+ */
224
+ export function heldTargetRefusal(target, policy) {
225
+ return `${policy.packageName} is not published yet: ${policy.heldFromPublication}. `
226
+ + `The ${target} target is supported and builds from source: ${LAUNCHER_SOURCE_URL}`;
227
+ }
228
+
229
+ export function assertHostCompatibility(target, policy, observation) {
230
+ if (policy.minimumCpuFeature === "sse4.2") {
231
+ if (observation.cpuSupportsSse42 === null) {
232
+ throw new Error(`Could not verify SSE4.2 support for the ${target} release.`);
233
+ }
234
+ if (!observation.cpuSupportsSse42) {
235
+ throw new Error(`The ${target} release requires an x64 CPU with SSE4.2.`);
236
+ }
237
+ }
238
+ assertMinimumHostVersion(target, "macOS", observation.macosVersion, policy.minimumMacosVersion);
239
+ assertMinimumHostVersion(target, "glibc", observation.glibcVersion, policy.minimumGlibcVersion);
240
+ }
241
+
242
+ export function linuxCpuSupportsSse42(cpuInfo) {
243
+ const parser = linuxCpuInfoParser();
244
+ for (const line of cpuInfo.split("\n")) {
245
+ if (Buffer.byteLength(line, "utf8") > MAX_CPU_INFO_LINE_BYTES) return null;
246
+ consumeLinuxCpuInfoLine(parser, line);
247
+ }
248
+ return finishLinuxCpuInfo(parser);
249
+ }
250
+
251
+ export function darwinCpuSupportsSse42(features, arm64Capability) {
252
+ if (arm64Capability?.trim() === "1") return true;
253
+ if (features === null) return null;
254
+ return features.trim().split(/\s+/u).includes("SSE4.2");
255
+ }
256
+
257
+ export function runLauncher(options = {}, observeHost) {
258
+ const plan = prepareLaunch(options, observeHost);
259
+ const child = spawn(plan.executable, plan.args, {
260
+ stdio: "inherit",
261
+ shell: false,
262
+ windowsHide: true
263
+ });
264
+ const forwardedSignals = new Map();
265
+ for (const signal of ["SIGINT", "SIGTERM"]) {
266
+ const forward = () => child.kill(signal);
267
+ forwardedSignals.set(signal, forward);
268
+ process.once(signal, forward);
269
+ }
270
+ const removeForwarders = () => {
271
+ for (const [signal, forward] of forwardedSignals) {
272
+ process.removeListener(signal, forward);
273
+ }
274
+ forwardedSignals.clear();
275
+ };
276
+ child.once("error", (error) => {
277
+ removeForwarders();
278
+ process.stderr.write(`1667: could not start ${plan.packageName}: ${error.message}\n`);
279
+ process.exitCode = 1;
280
+ });
281
+ child.once("exit", (code, signal) => {
282
+ removeForwarders();
283
+ if (signal !== null) process.kill(process.pid, signal);
284
+ else process.exitCode = code ?? 1;
285
+ });
286
+ return child;
287
+ }
288
+
289
+ function observeHostCompatibility(target) {
290
+ const [platform, arch] = target.split("-");
291
+ let cpuSupportsSse42 = null;
292
+ if (arch === "x64" && platform === "linux") {
293
+ cpuSupportsSse42 = linuxCpuFileSupportsSse42("/proc/cpuinfo");
294
+ } else if (arch === "x64" && platform === "darwin") {
295
+ cpuSupportsSse42 = darwinCpuSupportsSse42(
296
+ runHostProbe("/usr/sbin/sysctl", ["-n", "machdep.cpu.features"]),
297
+ runHostProbe("/usr/sbin/sysctl", ["-n", "hw.optional.arm64"])
298
+ );
299
+ }
300
+ return Object.freeze({
301
+ cpuSupportsSse42,
302
+ macosVersion: platform === "darwin"
303
+ ? runHostProbe("/usr/bin/sw_vers", ["-productVersion"])
304
+ : null,
305
+ glibcVersion: platform === "linux" ? runtimeGlibcVersion() : null
306
+ });
307
+ }
308
+
309
+ function assertMinimumHostVersion(target, name, observed, minimum) {
310
+ if (minimum === null) return;
311
+ const comparison = compareNumericVersions(observed, minimum);
312
+ if (comparison === null) {
313
+ throw new Error(`Could not verify the ${name} version for the ${target} release.`);
314
+ }
315
+ if (comparison < 0) {
316
+ throw new Error(`The ${target} release requires ${name} ${minimum} or newer.`);
317
+ }
318
+ }
319
+
320
+ function compareNumericVersions(observed, minimum) {
321
+ if (typeof observed !== "string"
322
+ || !/^[0-9]+(?:\.[0-9]+)*$/u.test(observed.trim())) {
323
+ return null;
324
+ }
325
+ const observedParts = observed.trim().split(".").map(Number);
326
+ const minimumParts = minimum.split(".").map(Number);
327
+ const length = Math.max(observedParts.length, minimumParts.length);
328
+ for (let index = 0; index < length; index += 1) {
329
+ const difference = (observedParts[index] ?? 0) - (minimumParts[index] ?? 0);
330
+ if (difference !== 0) return Math.sign(difference);
331
+ }
332
+ return 0;
333
+ }
334
+
335
+ function runtimeGlibcVersion() {
336
+ try {
337
+ const report = process.report.getReport();
338
+ if (report === null || typeof report !== "object") return null;
339
+ const header = report.header;
340
+ if (header === null || typeof header !== "object") return null;
341
+ const version = header.glibcVersionRuntime;
342
+ return typeof version === "string" && version.trim() !== ""
343
+ ? version.trim()
344
+ : null;
345
+ } catch {
346
+ return null;
347
+ }
348
+ }
349
+
350
+ export function linuxCpuFileSupportsSse42(file) {
351
+ let descriptor;
352
+ try {
353
+ descriptor = openSync(file, "r");
354
+ const bytes = Buffer.alloc(CPU_INFO_CHUNK_BYTES);
355
+ let pending = "";
356
+ const parser = linuxCpuInfoParser();
357
+ while (true) {
358
+ const count = readSync(descriptor, bytes, 0, bytes.length, null);
359
+ if (count === 0) break;
360
+ const lines = `${pending}${bytes.subarray(0, count).toString("utf8")}`
361
+ .split("\n");
362
+ pending = lines.pop() ?? "";
363
+ if (Buffer.byteLength(pending, "utf8") > MAX_CPU_INFO_LINE_BYTES) {
364
+ return null;
365
+ }
366
+ for (const line of lines) {
367
+ if (Buffer.byteLength(line, "utf8") > MAX_CPU_INFO_LINE_BYTES) {
368
+ return null;
369
+ }
370
+ consumeLinuxCpuInfoLine(parser, line);
371
+ if (parser.unsupported) return false;
372
+ }
373
+ }
374
+ consumeLinuxCpuInfoLine(parser, pending);
375
+ return finishLinuxCpuInfo(parser);
376
+ } catch {
377
+ return null;
378
+ } finally {
379
+ if (descriptor !== undefined) closeSync(descriptor);
380
+ }
381
+ }
382
+
383
+ function linuxCpuInfoParser() {
384
+ return {
385
+ sawProcessor: false,
386
+ inProcessor: false,
387
+ processorHasFlags: false,
388
+ unsupported: false,
389
+ unverifiable: false
390
+ };
391
+ }
392
+
393
+ function consumeLinuxCpuInfoLine(parser, line) {
394
+ if (line.trim() === "") {
395
+ finishLinuxCpuInfoRecord(parser);
396
+ return;
397
+ }
398
+ if (/^\s*processor\s*:/u.test(line)) {
399
+ finishLinuxCpuInfoRecord(parser);
400
+ parser.sawProcessor = true;
401
+ parser.inProcessor = true;
402
+ return;
403
+ }
404
+ const match = /^\s*flags\s*:\s*(.*?)\s*$/u.exec(line);
405
+ if (match === null || !parser.inProcessor) return;
406
+ parser.processorHasFlags = true;
407
+ if (!match[1].split(/\s+/u).includes("sse4_2")) {
408
+ parser.unsupported = true;
409
+ }
410
+ }
411
+
412
+ function finishLinuxCpuInfoRecord(parser) {
413
+ if (parser.inProcessor && !parser.processorHasFlags) {
414
+ parser.unverifiable = true;
415
+ }
416
+ parser.inProcessor = false;
417
+ parser.processorHasFlags = false;
418
+ }
419
+
420
+ function finishLinuxCpuInfo(parser) {
421
+ finishLinuxCpuInfoRecord(parser);
422
+ if (parser.unsupported) return false;
423
+ return parser.sawProcessor && !parser.unverifiable ? true : null;
424
+ }
425
+
426
+ function runHostProbe(executable, args) {
427
+ try {
428
+ const output = execFileSync(executable, args, {
429
+ encoding: "utf8",
430
+ maxBuffer: MAX_HOST_PROBE_BYTES,
431
+ shell: false,
432
+ stdio: ["ignore", "pipe", "ignore"],
433
+ timeout: HOST_PROBE_TIMEOUT_MS,
434
+ windowsHide: true
435
+ }).trim();
436
+ return output === "" ? null : output;
437
+ } catch {
438
+ return null;
439
+ }
440
+ }
441
+
442
+ function parseBuildManifest(value, packageName, artifactTarget) {
443
+ const record = exactRecord(value, BUILD_MANIFEST_KEYS, "Package build manifest");
444
+ if (record.schemaVersion !== 1
445
+ || record.product !== "1667"
446
+ || record.packageName !== packageName
447
+ || record.artifactTarget !== artifactTarget
448
+ || typeof record.productVersion !== "string"
449
+ || typeof record.sourceCommit !== "string"
450
+ || typeof record.buildTimestamp !== "string") {
451
+ throw new Error(`${packageName} has an invalid build manifest`);
452
+ }
453
+ return record;
454
+ }
455
+
456
+ function readBoundedJson(file) {
457
+ const stat = lstatSync(file);
458
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size <= 0 || stat.size > MAX_JSON_BYTES) {
459
+ throw new Error(`${file} is not a bounded regular JSON file`);
460
+ }
461
+ return JSON.parse(readFileSync(file, "utf8"));
462
+ }
463
+
464
+ function exactRecord(value, keys, label) {
465
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
466
+ throw new Error(`${label} must be an object`);
467
+ }
468
+ const actual = Object.keys(value);
469
+ if (actual.length !== keys.size || actual.some((key) => !keys.has(key))) {
470
+ throw new Error(`${label} has unknown or missing fields`);
471
+ }
472
+ return value;
473
+ }
474
+
475
+ function singleValue(value, expected) {
476
+ return Array.isArray(value) && value.length === 1 && value[0] === expected;
477
+ }
478
+
479
+ function isMainModule() {
480
+ if (process.argv[1] === undefined) return false;
481
+ try {
482
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
483
+ } catch {
484
+ return false;
485
+ }
486
+ }
487
+
488
+ if (isMainModule()) {
489
+ try {
490
+ runLauncher();
491
+ } catch (error) {
492
+ const message = error instanceof Error ? error.message : String(error);
493
+ process.stderr.write(`1667: ${message}\n`);
494
+ process.exitCode = 1;
495
+ }
496
+ }
@@ -0,0 +1 @@
1
+ {"artifactTarget":"launcher","buildTimestamp":"2026-07-30T11:23:55.000Z","packageName":"@1667-ai/cli","product":"1667","productVersion":"0.1.2-beta.3","schemaVersion":1,"sourceCommit":"8ba3d19c1cb438731edba34dfbbe7139e7a64a10"}
package/package.json CHANGED
@@ -1,15 +1 @@
1
- {
2
- "name": "@1667-ai/cli",
3
- "version": "0.0.0",
4
- "description": "A full-screen terminal environment for writing fiction with language models. This version reserves the name; it is not a release.",
5
- "keywords": ["cli", "tui", "terminal", "writing", "fiction", "llm"],
6
- "license": "Apache-2.0",
7
- "repository": { "type": "git", "url": "git+https://github.com/1667-ai/1667.git" },
8
- "homepage": "https://github.com/1667-ai/1667",
9
- "bugs": { "url": "https://github.com/1667-ai/1667/issues" },
10
- "type": "module",
11
- "bin": { "1667": "bin/1667.js" },
12
- "files": ["bin/1667.js", "README.md"],
13
- "engines": { "node": ">=22" },
14
- "publishConfig": { "access": "public" }
15
- }
1
+ {"bin":{"1667":"bin/1667.js"},"files":["bin/1667.js","build-manifest.json","sbom.spdx.json","LICENSE","NOTICE"],"license":"Apache-2.0","name":"@1667-ai/cli","optionalDependencies":{"@1667-ai/darwin-arm64":"0.1.2-beta.3","@1667-ai/darwin-x64":"0.1.2-beta.3","@1667-ai/linux-arm64":"0.1.2-beta.3","@1667-ai/linux-x64":"0.1.2-beta.3"},"private":false,"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/1667-ai/1667.git"},"type":"module","version":"0.1.2-beta.3"}
package/sbom.spdx.json ADDED
@@ -0,0 +1 @@
1
+ {"SPDXID":"SPDXRef-DOCUMENT","comment":"Bill of materials for the 1667 launcher package. The launcher embeds no language runtime and bundles no third-party code; it selects and executes the platform package pinned at the same exact version.","creationInfo":{"created":"2026-07-30T11:23:55Z","creators":["Organization: 1667","Tool: 1667-release-sbom-1"]},"dataLicense":"CC0-1.0","documentDescribes":["SPDXRef-Package-1667-0.1.2-beta.3"],"documentNamespace":"https://1667.invalid/spdx/@1667-ai%2fcli/0.1.2-beta.3/8ba3d19c1cb438731edba34dfbbe7139e7a64a10","name":"@1667-ai/cli@0.1.2-beta.3","packages":[{"SPDXID":"SPDXRef-Package-1667-0.1.2-beta.3","builtDate":"2026-07-30T11:23:55Z","comment":"Built from tag v0.1.2-beta.3 at a clean working tree.","copyrightText":"NOASSERTION","downloadLocation":"git+https://github.com/1667-ai/1667.git@8ba3d19c1cb438731edba34dfbbe7139e7a64a10","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceLocator":"pkg:npm/%401667-ai/cli@0.1.2-beta.3","referenceType":"purl"}],"filesAnalyzed":false,"licenseConcluded":"Apache-2.0","licenseDeclared":"Apache-2.0","name":"1667","packageFileName":"bin/1667.js","primaryPackagePurpose":"APPLICATION","sourceInfo":"Launcher published as @1667-ai/cli, built from git+https://github.com/1667-ai/1667.git at commit 8ba3d19c1cb438731edba34dfbbe7139e7a64a10. Plain JavaScript executed by the host Node.js; no runtime is embedded and no third-party code is bundled.","supplier":"Organization: 1667","versionInfo":"0.1.2-beta.3"},{"SPDXID":"SPDXRef-Package-1667-ai-darwin-arm64-0.1.2-beta.3","comment":"Exact-version pin selected on darwin/arm64. Its own document lists the runtime and dependencies it embeds; no digest is asserted here because the tarball is packed after this document.","copyrightText":"NOASSERTION","downloadLocation":"https://registry.npmjs.org/@1667-ai/darwin-arm64/-/darwin-arm64-0.1.2-beta.3.tgz","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceLocator":"pkg:npm/%401667-ai/darwin-arm64@0.1.2-beta.3","referenceType":"purl"}],"filesAnalyzed":false,"licenseConcluded":"Apache-2.0","licenseDeclared":"Apache-2.0","name":"@1667-ai/darwin-arm64","primaryPackagePurpose":"APPLICATION","supplier":"Organization: 1667","versionInfo":"0.1.2-beta.3"},{"SPDXID":"SPDXRef-Package-1667-ai-darwin-x64-0.1.2-beta.3","comment":"Exact-version pin selected on darwin/x64. Its own document lists the runtime and dependencies it embeds; no digest is asserted here because the tarball is packed after this document.","copyrightText":"NOASSERTION","downloadLocation":"https://registry.npmjs.org/@1667-ai/darwin-x64/-/darwin-x64-0.1.2-beta.3.tgz","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceLocator":"pkg:npm/%401667-ai/darwin-x64@0.1.2-beta.3","referenceType":"purl"}],"filesAnalyzed":false,"licenseConcluded":"Apache-2.0","licenseDeclared":"Apache-2.0","name":"@1667-ai/darwin-x64","primaryPackagePurpose":"APPLICATION","supplier":"Organization: 1667","versionInfo":"0.1.2-beta.3"},{"SPDXID":"SPDXRef-Package-1667-ai-linux-arm64-0.1.2-beta.3","comment":"Exact-version pin selected on linux/arm64 (glibc). Its own document lists the runtime and dependencies it embeds; no digest is asserted here because the tarball is packed after this document.","copyrightText":"NOASSERTION","downloadLocation":"https://registry.npmjs.org/@1667-ai/linux-arm64/-/linux-arm64-0.1.2-beta.3.tgz","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceLocator":"pkg:npm/%401667-ai/linux-arm64@0.1.2-beta.3","referenceType":"purl"}],"filesAnalyzed":false,"licenseConcluded":"Apache-2.0","licenseDeclared":"Apache-2.0","name":"@1667-ai/linux-arm64","primaryPackagePurpose":"APPLICATION","supplier":"Organization: 1667","versionInfo":"0.1.2-beta.3"},{"SPDXID":"SPDXRef-Package-1667-ai-linux-x64-0.1.2-beta.3","comment":"Exact-version pin selected on linux/x64 (glibc). Its own document lists the runtime and dependencies it embeds; no digest is asserted here because the tarball is packed after this document.","copyrightText":"NOASSERTION","downloadLocation":"https://registry.npmjs.org/@1667-ai/linux-x64/-/linux-x64-0.1.2-beta.3.tgz","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceLocator":"pkg:npm/%401667-ai/linux-x64@0.1.2-beta.3","referenceType":"purl"}],"filesAnalyzed":false,"licenseConcluded":"Apache-2.0","licenseDeclared":"Apache-2.0","name":"@1667-ai/linux-x64","primaryPackagePurpose":"APPLICATION","supplier":"Organization: 1667","versionInfo":"0.1.2-beta.3"}],"relationships":[{"relatedSpdxElement":"SPDXRef-Package-1667-0.1.2-beta.3","relationshipType":"DESCRIBES","spdxElementId":"SPDXRef-DOCUMENT"},{"relatedSpdxElement":"SPDXRef-Package-1667-0.1.2-beta.3","relationshipType":"OPTIONAL_DEPENDENCY_OF","spdxElementId":"SPDXRef-Package-1667-ai-darwin-arm64-0.1.2-beta.3"},{"relatedSpdxElement":"SPDXRef-Package-1667-0.1.2-beta.3","relationshipType":"OPTIONAL_DEPENDENCY_OF","spdxElementId":"SPDXRef-Package-1667-ai-darwin-x64-0.1.2-beta.3"},{"relatedSpdxElement":"SPDXRef-Package-1667-0.1.2-beta.3","relationshipType":"OPTIONAL_DEPENDENCY_OF","spdxElementId":"SPDXRef-Package-1667-ai-linux-arm64-0.1.2-beta.3"},{"relatedSpdxElement":"SPDXRef-Package-1667-0.1.2-beta.3","relationshipType":"OPTIONAL_DEPENDENCY_OF","spdxElementId":"SPDXRef-Package-1667-ai-linux-x64-0.1.2-beta.3"}],"spdxVersion":"SPDX-2.3"}
package/README.md DELETED
@@ -1,28 +0,0 @@
1
- # 1667
2
-
3
- A full-screen terminal environment for writing fiction with language models.
4
-
5
- Source: <https://github.com/1667-ai/1667>
6
-
7
- ## This version is not a release
8
-
9
- Version 0.0.0 is a placeholder that reserves this package name. It
10
- contains no program. Running it prints an explanation and exits non-zero.
11
-
12
- 1667 is pre-release. Build it from source:
13
-
14
- ```sh
15
- git clone https://github.com/1667-ai/1667.git
16
- cd 1667 && npm ci && npm run build
17
- ```
18
-
19
- ## What 1667 is
20
-
21
- - A keyboard-driven terminal interface for drafting long-form fiction.
22
- - A story model with alternative takes: any passage can have siblings, and the
23
- selected path through them is the story line.
24
- - A direct connection to OpenAI-compatible or Anthropic Messages endpoints.
25
- - An embedded backend that stores stories in a project directory.
26
-
27
- When a release is published, this package becomes a launcher that selects the
28
- native executable for the host platform. See the repository for current status.