@thyn-ai/sqai-cli 0.1.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/LICENSE +202 -0
- package/dist/index.js +419 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/doctor.ts
|
|
4
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
5
|
+
import { MojoRuntime } from "algenta-sdk";
|
|
6
|
+
|
|
7
|
+
// src/shared.ts
|
|
8
|
+
import { existsSync, readFileSync } from "fs";
|
|
9
|
+
import { createRequire } from "module";
|
|
10
|
+
import { dirname, join } from "path";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
var OK = "\u2713";
|
|
13
|
+
var FAIL = "\u2717";
|
|
14
|
+
var SKIP = "\u2022";
|
|
15
|
+
function line(text) {
|
|
16
|
+
process.stdout.write(`${text}
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
function errorLine(text) {
|
|
20
|
+
process.stderr.write(`${text}
|
|
21
|
+
`);
|
|
22
|
+
}
|
|
23
|
+
function printJson(payload) {
|
|
24
|
+
process.stdout.write(`${JSON.stringify(payload, null, 2)}
|
|
25
|
+
`);
|
|
26
|
+
}
|
|
27
|
+
function message(error) {
|
|
28
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
|
+
}
|
|
30
|
+
function cliVersion() {
|
|
31
|
+
try {
|
|
32
|
+
const packagePath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
33
|
+
const parsed = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
34
|
+
return parsed.version ?? "unknown";
|
|
35
|
+
} catch {
|
|
36
|
+
return "unknown";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function sdkVersion() {
|
|
40
|
+
try {
|
|
41
|
+
const require_ = createRequire(import.meta.url);
|
|
42
|
+
let dir = dirname(require_.resolve("@thyn-ai/sqai"));
|
|
43
|
+
for (let depth = 0; depth < 6; depth += 1) {
|
|
44
|
+
const candidate = join(dir, "package.json");
|
|
45
|
+
if (existsSync(candidate)) {
|
|
46
|
+
const parsed = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
47
|
+
if (parsed.name === "@thyn-ai/sqai" && parsed.version) {
|
|
48
|
+
return parsed.version;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const parent = dirname(dir);
|
|
52
|
+
if (parent === dir) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
dir = parent;
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
return "unknown";
|
|
60
|
+
}
|
|
61
|
+
function findTestedPair(startDir) {
|
|
62
|
+
let dir = startDir;
|
|
63
|
+
for (; ; ) {
|
|
64
|
+
const candidate = join(dir, "contracts", "tested-pair.json");
|
|
65
|
+
if (existsSync(candidate)) {
|
|
66
|
+
return candidate;
|
|
67
|
+
}
|
|
68
|
+
const parent = dirname(dir);
|
|
69
|
+
if (parent === dir) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
dir = parent;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function hashPrefix(hash) {
|
|
76
|
+
const body = hash.startsWith("sha256:") ? hash.slice("sha256:".length) : hash;
|
|
77
|
+
return body.slice(0, 12);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/doctor.ts
|
|
81
|
+
function isReadOnlyDeterministic(entry) {
|
|
82
|
+
return entry.read_only && (entry.deterministic || entry.deterministic_when_seeded === true);
|
|
83
|
+
}
|
|
84
|
+
function dispatchModule(entry) {
|
|
85
|
+
const separator = entry.name.lastIndexOf(".");
|
|
86
|
+
return entry.category === "simulation" ? entry.name.slice(separator + 1) : entry.name.slice(0, separator);
|
|
87
|
+
}
|
|
88
|
+
async function doctorCommand(flags) {
|
|
89
|
+
const checks = [];
|
|
90
|
+
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
91
|
+
checks.push({
|
|
92
|
+
name: "node",
|
|
93
|
+
ok: nodeMajor >= 20,
|
|
94
|
+
detail: nodeMajor >= 20 ? process.version : `${process.version} (requires >=20)`
|
|
95
|
+
});
|
|
96
|
+
let sdk = null;
|
|
97
|
+
try {
|
|
98
|
+
sdk = await import("@thyn-ai/sqai");
|
|
99
|
+
checks.push({ name: "sdk", ok: true, detail: `@thyn-ai/sqai ${sdkVersion()} imports cleanly` });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
checks.push({ name: "sdk", ok: false, detail: `@thyn-ai/sqai import failed: ${message(error)}` });
|
|
102
|
+
}
|
|
103
|
+
let contract = null;
|
|
104
|
+
if (sdk) {
|
|
105
|
+
try {
|
|
106
|
+
contract = sdk.createSQAI({ mode: "local" }).capabilities();
|
|
107
|
+
checks.push({
|
|
108
|
+
name: "contract",
|
|
109
|
+
ok: true,
|
|
110
|
+
detail: `${contract.capabilities.length} capabilities, ${contract.capability_contract_hash}, algenta-sdk ${contract.algenta_sdk_version}, algenta-core ${contract.algenta_core_version}`
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
checks.push({ name: "contract", ok: false, detail: `contract load failed: ${message(error)}` });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const pairPath = findTestedPair(process.cwd());
|
|
117
|
+
if (!pairPath) {
|
|
118
|
+
checks.push({
|
|
119
|
+
name: "tested-pair",
|
|
120
|
+
ok: true,
|
|
121
|
+
skipped: true,
|
|
122
|
+
detail: "skipped (not inside the sqai repo)"
|
|
123
|
+
});
|
|
124
|
+
} else if (contract) {
|
|
125
|
+
try {
|
|
126
|
+
const pair = JSON.parse(readFileSync2(pairPath, "utf-8"));
|
|
127
|
+
const mismatches = [];
|
|
128
|
+
if (pair["capability_contract_hash"] !== contract.capability_contract_hash) {
|
|
129
|
+
mismatches.push("capability_contract_hash");
|
|
130
|
+
}
|
|
131
|
+
if (pair["algenta_sdk"] !== contract.algenta_sdk_version) {
|
|
132
|
+
mismatches.push("algenta_sdk");
|
|
133
|
+
}
|
|
134
|
+
if (pair["algenta_core"] !== contract.algenta_core_version) {
|
|
135
|
+
mismatches.push("algenta_core");
|
|
136
|
+
}
|
|
137
|
+
if ((pair["runtime_bundle_version"] ?? "") !== (contract.runtime_bundle.version ?? "")) {
|
|
138
|
+
mismatches.push("runtime_bundle_version");
|
|
139
|
+
}
|
|
140
|
+
checks.push({
|
|
141
|
+
name: "tested-pair",
|
|
142
|
+
ok: mismatches.length === 0,
|
|
143
|
+
detail: mismatches.length === 0 ? "consistent with the embedded contract" : `MISMATCH vs embedded contract: ${mismatches.join(", ")}`
|
|
144
|
+
});
|
|
145
|
+
} catch (error) {
|
|
146
|
+
checks.push({ name: "tested-pair", ok: false, detail: `unreadable: ${message(error)}` });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let runtimeAvailable = false;
|
|
150
|
+
let liveModules = null;
|
|
151
|
+
let runtimeDetail = "unavailable (checks skipped)";
|
|
152
|
+
try {
|
|
153
|
+
const runtime = new MojoRuntime();
|
|
154
|
+
const health = await runtime.health();
|
|
155
|
+
runtimeAvailable = health.runtime_available;
|
|
156
|
+
if (runtimeAvailable) {
|
|
157
|
+
runtimeDetail = `available \u2014 engine ${health.engine}, ${health.module_count} modules`;
|
|
158
|
+
if (flags.parity) {
|
|
159
|
+
liveModules = (await runtime.listModules()).map((descriptor) => descriptor.name);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
runtimeAvailable = false;
|
|
164
|
+
}
|
|
165
|
+
checks.push({
|
|
166
|
+
name: "runtime",
|
|
167
|
+
ok: true,
|
|
168
|
+
skipped: !runtimeAvailable,
|
|
169
|
+
detail: runtimeAvailable ? runtimeDetail : "unavailable (checks skipped)"
|
|
170
|
+
});
|
|
171
|
+
let parity = null;
|
|
172
|
+
if (flags.parity && contract) {
|
|
173
|
+
const violations = [];
|
|
174
|
+
for (const entry of contract.capabilities) {
|
|
175
|
+
if ((entry.typescript || entry.ai_sdk) && !isReadOnlyDeterministic(entry)) {
|
|
176
|
+
violations.push(`${entry.name} (exposed but not read-only deterministic)`);
|
|
177
|
+
}
|
|
178
|
+
if (entry.ai_sdk && !entry.typescript) {
|
|
179
|
+
violations.push(`${entry.name} (ai_sdk without typescript)`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
let missing = [];
|
|
183
|
+
let extra = [];
|
|
184
|
+
if (runtimeAvailable && liveModules) {
|
|
185
|
+
const contractModules = /* @__PURE__ */ new Set();
|
|
186
|
+
for (const entry of contract.capabilities) {
|
|
187
|
+
if (entry.ai_sdk && isReadOnlyDeterministic(entry)) {
|
|
188
|
+
contractModules.add(dispatchModule(entry));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const live = new Set(liveModules);
|
|
192
|
+
missing = [...contractModules].filter((module) => !live.has(module)).sort();
|
|
193
|
+
extra = [...live].filter((module) => !contractModules.has(module)).sort();
|
|
194
|
+
}
|
|
195
|
+
parity = {
|
|
196
|
+
invariant_ok: violations.length === 0,
|
|
197
|
+
violations,
|
|
198
|
+
runtime: runtimeAvailable ? "available" : "unavailable",
|
|
199
|
+
missing_modules: missing,
|
|
200
|
+
extra_modules: extra
|
|
201
|
+
};
|
|
202
|
+
const strictFailure = flags.strict && !runtimeAvailable;
|
|
203
|
+
const parityOk = violations.length === 0 && missing.length === 0 && extra.length === 0 && !strictFailure;
|
|
204
|
+
let detail;
|
|
205
|
+
if (strictFailure) {
|
|
206
|
+
detail = "runtime unreachable (--parity --strict requires a live runtime)";
|
|
207
|
+
} else if (!parityOk) {
|
|
208
|
+
const parts = [];
|
|
209
|
+
if (violations.length > 0) parts.push(`${violations.length} invariant violation(s)`);
|
|
210
|
+
if (missing.length > 0) parts.push(`missing modules: ${missing.join(", ")}`);
|
|
211
|
+
if (extra.length > 0) parts.push(`extra modules: ${extra.join(", ")}`);
|
|
212
|
+
detail = parts.join("; ");
|
|
213
|
+
} else {
|
|
214
|
+
detail = runtimeAvailable ? `invariant holds for ${contract.capabilities.length} capabilities; live modules match` : `invariant holds for ${contract.capabilities.length} capabilities; runtime unavailable (live diff skipped)`;
|
|
215
|
+
}
|
|
216
|
+
checks.push({ name: "parity", ok: parityOk, detail });
|
|
217
|
+
} else if (flags.parity) {
|
|
218
|
+
checks.push({ name: "parity", ok: false, detail: "cannot run: contract failed to load" });
|
|
219
|
+
}
|
|
220
|
+
const ok = checks.every((check) => check.ok);
|
|
221
|
+
const exitCode = ok ? 0 : 1;
|
|
222
|
+
if (flags.json) {
|
|
223
|
+
printJson({
|
|
224
|
+
command: "doctor",
|
|
225
|
+
ok,
|
|
226
|
+
version: cliVersion(),
|
|
227
|
+
checks,
|
|
228
|
+
...contract ? {
|
|
229
|
+
contract: {
|
|
230
|
+
capability_count: contract.capabilities.length,
|
|
231
|
+
capability_contract_hash: contract.capability_contract_hash,
|
|
232
|
+
algenta_sdk_version: contract.algenta_sdk_version,
|
|
233
|
+
algenta_core_version: contract.algenta_core_version,
|
|
234
|
+
runtime_bundle_version: contract.runtime_bundle.version
|
|
235
|
+
}
|
|
236
|
+
} : {},
|
|
237
|
+
...parity ? { parity } : {},
|
|
238
|
+
exit_code: exitCode
|
|
239
|
+
});
|
|
240
|
+
return exitCode;
|
|
241
|
+
}
|
|
242
|
+
for (const check of checks) {
|
|
243
|
+
const mark = check.skipped ? SKIP : check.ok ? OK : FAIL;
|
|
244
|
+
line(`${mark} ${check.name}: ${check.detail}`);
|
|
245
|
+
}
|
|
246
|
+
line(ok ? `${OK} doctor: ok` : `${FAIL} doctor: FAILED`);
|
|
247
|
+
return exitCode;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/runtime.ts
|
|
251
|
+
import { RuntimeProvisioner, SqaiError, createSQAI } from "@thyn-ai/sqai";
|
|
252
|
+
function buildProvisioner() {
|
|
253
|
+
const contract = createSQAI({ mode: "local" }).capabilities();
|
|
254
|
+
return { provisioner: new RuntimeProvisioner({ contract, autoInstall: true }), contract };
|
|
255
|
+
}
|
|
256
|
+
function printStatusHuman(status) {
|
|
257
|
+
if (status.runtime_available) {
|
|
258
|
+
line(`${OK} runtime: available \u2014 engine ${status.engine}, ${status.module_count} modules`);
|
|
259
|
+
} else {
|
|
260
|
+
line(`${SKIP} runtime: unavailable`);
|
|
261
|
+
}
|
|
262
|
+
line(`${SKIP} platform: ${status.platform}`);
|
|
263
|
+
line(`${SKIP} managed by this process: ${status.managed ? "yes" : "no"}`);
|
|
264
|
+
}
|
|
265
|
+
function printSqaiErrorHuman(error) {
|
|
266
|
+
line(`${FAIL} ${error.code}: ${error.message}`);
|
|
267
|
+
const entries = Object.entries(error.details).sort(
|
|
268
|
+
([left], [right]) => left === "reason" ? -1 : right === "reason" ? 1 : 0
|
|
269
|
+
);
|
|
270
|
+
for (const [key, value] of entries) {
|
|
271
|
+
line(` ${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function runtimeCommand(sub, flags) {
|
|
275
|
+
const { provisioner, contract } = buildProvisioner();
|
|
276
|
+
if (sub === "status") {
|
|
277
|
+
const status = await provisioner.status();
|
|
278
|
+
if (flags.json) {
|
|
279
|
+
printJson({ command: "runtime status", ok: true, status, exit_code: 0 });
|
|
280
|
+
} else {
|
|
281
|
+
printStatusHuman(status);
|
|
282
|
+
}
|
|
283
|
+
return 0;
|
|
284
|
+
}
|
|
285
|
+
if (sub === "install") {
|
|
286
|
+
try {
|
|
287
|
+
await provisioner.ensure();
|
|
288
|
+
const status = await provisioner.status();
|
|
289
|
+
if (flags.json) {
|
|
290
|
+
printJson({ command: "runtime install", ok: true, status, exit_code: 0 });
|
|
291
|
+
} else {
|
|
292
|
+
line(`${OK} runtime installed and healthy`);
|
|
293
|
+
printStatusHuman(status);
|
|
294
|
+
}
|
|
295
|
+
return 0;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
const sqaiError = error instanceof SqaiError ? error : new SqaiError("runtime_provision_failed", message(error));
|
|
298
|
+
if (flags.json) {
|
|
299
|
+
printJson({
|
|
300
|
+
command: "runtime install",
|
|
301
|
+
ok: false,
|
|
302
|
+
error: {
|
|
303
|
+
code: sqaiError.code,
|
|
304
|
+
message: sqaiError.message,
|
|
305
|
+
retryable: sqaiError.retryable,
|
|
306
|
+
details: sqaiError.details
|
|
307
|
+
},
|
|
308
|
+
exit_code: 1
|
|
309
|
+
});
|
|
310
|
+
} else {
|
|
311
|
+
printSqaiErrorHuman(sqaiError);
|
|
312
|
+
}
|
|
313
|
+
return 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (sub === "verify") {
|
|
317
|
+
const status = await provisioner.status();
|
|
318
|
+
const bundle = contract.runtime_bundle;
|
|
319
|
+
const platforms = Object.entries(bundle.platforms).map(([platform, info]) => ({
|
|
320
|
+
platform,
|
|
321
|
+
sha256: info.sha256
|
|
322
|
+
}));
|
|
323
|
+
if (flags.json) {
|
|
324
|
+
printJson({
|
|
325
|
+
command: "runtime verify",
|
|
326
|
+
ok: true,
|
|
327
|
+
status,
|
|
328
|
+
runtime_bundle: {
|
|
329
|
+
version: bundle.version || "unmanaged",
|
|
330
|
+
platforms
|
|
331
|
+
},
|
|
332
|
+
contract_hash: contract.capability_contract_hash,
|
|
333
|
+
exit_code: 0
|
|
334
|
+
});
|
|
335
|
+
} else {
|
|
336
|
+
printStatusHuman(status);
|
|
337
|
+
line(`${SKIP} contract runtime bundle: ${bundle.version || "unmanaged (no bundle published yet)"}`);
|
|
338
|
+
if (platforms.length === 0) {
|
|
339
|
+
line(`${SKIP} bundle platforms: none published`);
|
|
340
|
+
}
|
|
341
|
+
for (const entry of platforms) {
|
|
342
|
+
line(`${SKIP} bundle ${entry.platform}: sha256 ${entry.sha256.slice(0, 12)}\u2026`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
await provisioner.stop();
|
|
348
|
+
if (flags.json) {
|
|
349
|
+
printJson({ command: "runtime stop", ok: true, exit_code: 0 });
|
|
350
|
+
} else {
|
|
351
|
+
line(`${OK} runtime stop requested (v1 policy is leave-running; spawn management lands with the bundle pipeline)`);
|
|
352
|
+
}
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/index.ts
|
|
357
|
+
var USAGE = `sqai \u2014 deterministic, read-only structured data for AI agents
|
|
358
|
+
|
|
359
|
+
Usage:
|
|
360
|
+
sqai doctor [--parity] [--strict] [--json] environment, contract, and parity checks
|
|
361
|
+
sqai runtime <status|install|verify|stop> [--json]
|
|
362
|
+
sqai --version CLI + @thyn-ai/sqai versions + contract hash
|
|
363
|
+
sqai help show this help
|
|
364
|
+
`;
|
|
365
|
+
var RUNTIME_SUBCOMMANDS = /* @__PURE__ */ new Set(["status", "install", "verify", "stop"]);
|
|
366
|
+
async function versionCommand(json) {
|
|
367
|
+
let contractHash = "unknown";
|
|
368
|
+
try {
|
|
369
|
+
const sdk = await import("@thyn-ai/sqai");
|
|
370
|
+
contractHash = sdk.createSQAI({ mode: "local" }).capabilities().capability_contract_hash;
|
|
371
|
+
} catch {
|
|
372
|
+
}
|
|
373
|
+
if (json) {
|
|
374
|
+
printJson({
|
|
375
|
+
command: "version",
|
|
376
|
+
sqai: cliVersion(),
|
|
377
|
+
"@thyn-ai/sqai": sdkVersion(),
|
|
378
|
+
contract_hash: contractHash,
|
|
379
|
+
exit_code: 0
|
|
380
|
+
});
|
|
381
|
+
} else {
|
|
382
|
+
line(`sqai ${cliVersion()} (@thyn-ai/sqai ${sdkVersion()}, contract ${hashPrefix(contractHash)})`);
|
|
383
|
+
}
|
|
384
|
+
return 0;
|
|
385
|
+
}
|
|
386
|
+
async function main(argv) {
|
|
387
|
+
const flags = new Set(argv.filter((arg) => arg.startsWith("-")));
|
|
388
|
+
const positional = argv.filter((arg) => !arg.startsWith("-"));
|
|
389
|
+
const json = flags.has("--json");
|
|
390
|
+
const command = positional[0];
|
|
391
|
+
if (flags.has("--version") || flags.has("-v") || command === "version") {
|
|
392
|
+
return versionCommand(json);
|
|
393
|
+
}
|
|
394
|
+
if (!command || command === "help" || flags.has("--help") || flags.has("-h")) {
|
|
395
|
+
line(USAGE);
|
|
396
|
+
return 0;
|
|
397
|
+
}
|
|
398
|
+
if (command === "doctor") {
|
|
399
|
+
return doctorCommand({ parity: flags.has("--parity"), strict: flags.has("--strict"), json });
|
|
400
|
+
}
|
|
401
|
+
if (command === "runtime") {
|
|
402
|
+
const sub = positional[1];
|
|
403
|
+
if (!sub || !RUNTIME_SUBCOMMANDS.has(sub)) {
|
|
404
|
+
errorLine(`Unknown runtime subcommand '${sub ?? ""}'. Expected status|install|verify|stop.`);
|
|
405
|
+
return 2;
|
|
406
|
+
}
|
|
407
|
+
return runtimeCommand(sub, { json });
|
|
408
|
+
}
|
|
409
|
+
errorLine(`Unknown command '${command}'.`);
|
|
410
|
+
errorLine(USAGE);
|
|
411
|
+
return 2;
|
|
412
|
+
}
|
|
413
|
+
main(process.argv.slice(2)).then((code) => {
|
|
414
|
+
process.exitCode = code;
|
|
415
|
+
}).catch((error) => {
|
|
416
|
+
errorLine(`sqai failed: ${message(error)}`);
|
|
417
|
+
process.exitCode = 1;
|
|
418
|
+
});
|
|
419
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/doctor.ts","../src/shared.ts","../src/runtime.ts","../src/index.ts"],"sourcesContent":["/** sqai doctor — environment, contract, tested-pair, and parity checks.\n *\n * Parity invariant: every capability exposed to the TypeScript/AI-SDK channel\n * must be read_only AND (deterministic OR deterministic_when_seeded). With a\n * live runtime, doctor also diffs the contract's library modules against\n * list_modules. Drift or an invariant violation exits non-zero; an unreachable\n * runtime skips the live checks and stays exit 0 unless --parity --strict. */\n\nimport { readFileSync } from \"node:fs\";\nimport { MojoRuntime } from \"algenta-sdk\";\nimport type { CapabilityContract, CapabilityEntry } from \"@thyn-ai/sqai\";\n\nimport {\n FAIL,\n OK,\n SKIP,\n cliVersion,\n findTestedPair,\n line,\n message,\n printJson,\n sdkVersion,\n} from \"./shared.js\";\n\nexport interface DoctorFlags {\n parity: boolean;\n strict: boolean;\n json: boolean;\n}\n\ninterface DoctorCheck {\n name: string;\n ok: boolean;\n skipped?: boolean;\n detail: string;\n}\n\ninterface ParityReport {\n invariant_ok: boolean;\n violations: string[];\n runtime: \"available\" | \"unavailable\";\n missing_modules: string[];\n extra_modules: string[];\n}\n\nfunction isReadOnlyDeterministic(entry: CapabilityEntry): boolean {\n return entry.read_only && (entry.deterministic || entry.deterministic_when_seeded === true);\n}\n\n/** The runtime module a capability dispatches to: simulate.<engine> runs as\n * execute(<engine>, \"run\", …) — the module is the function part. */\nfunction dispatchModule(entry: CapabilityEntry): string {\n const separator = entry.name.lastIndexOf(\".\");\n return entry.category === \"simulation\"\n ? entry.name.slice(separator + 1)\n : entry.name.slice(0, separator);\n}\n\nexport async function doctorCommand(flags: DoctorFlags): Promise<number> {\n const checks: DoctorCheck[] = [];\n\n // 1. Node version.\n const nodeMajor = Number(process.versions.node.split(\".\")[0]);\n checks.push({\n name: \"node\",\n ok: nodeMajor >= 20,\n detail: nodeMajor >= 20 ? process.version : `${process.version} (requires >=20)`,\n });\n\n // 2. @thyn-ai/sqai import.\n let sdk: typeof import(\"@thyn-ai/sqai\") | null = null;\n try {\n sdk = await import(\"@thyn-ai/sqai\");\n checks.push({ name: \"sdk\", ok: true, detail: `@thyn-ai/sqai ${sdkVersion()} imports cleanly` });\n } catch (error) {\n checks.push({ name: \"sdk\", ok: false, detail: `@thyn-ai/sqai import failed: ${message(error)}` });\n }\n\n // 3. Embedded contract.\n let contract: CapabilityContract | null = null;\n if (sdk) {\n try {\n contract = sdk.createSQAI({ mode: \"local\" }).capabilities();\n checks.push({\n name: \"contract\",\n ok: true,\n detail:\n `${contract.capabilities.length} capabilities, ${contract.capability_contract_hash}, ` +\n `algenta-sdk ${contract.algenta_sdk_version}, algenta-core ${contract.algenta_core_version}`,\n });\n } catch (error) {\n checks.push({ name: \"contract\", ok: false, detail: `contract load failed: ${message(error)}` });\n }\n }\n\n // 4. tested-pair.json consistency (only inside the repo).\n const pairPath = findTestedPair(process.cwd());\n if (!pairPath) {\n checks.push({\n name: \"tested-pair\",\n ok: true,\n skipped: true,\n detail: \"skipped (not inside the sqai repo)\",\n });\n } else if (contract) {\n try {\n const pair = JSON.parse(readFileSync(pairPath, \"utf-8\")) as Record<string, string>;\n const mismatches: string[] = [];\n if (pair[\"capability_contract_hash\"] !== contract.capability_contract_hash) {\n mismatches.push(\"capability_contract_hash\");\n }\n if (pair[\"algenta_sdk\"] !== contract.algenta_sdk_version) {\n mismatches.push(\"algenta_sdk\");\n }\n if (pair[\"algenta_core\"] !== contract.algenta_core_version) {\n mismatches.push(\"algenta_core\");\n }\n if ((pair[\"runtime_bundle_version\"] ?? \"\") !== (contract.runtime_bundle.version ?? \"\")) {\n mismatches.push(\"runtime_bundle_version\");\n }\n checks.push({\n name: \"tested-pair\",\n ok: mismatches.length === 0,\n detail:\n mismatches.length === 0\n ? \"consistent with the embedded contract\"\n : `MISMATCH vs embedded contract: ${mismatches.join(\", \")}`,\n });\n } catch (error) {\n checks.push({ name: \"tested-pair\", ok: false, detail: `unreadable: ${message(error)}` });\n }\n }\n\n // 5. Live runtime probe (informational unless --parity).\n let runtimeAvailable = false;\n let liveModules: string[] | null = null;\n let runtimeDetail = \"unavailable (checks skipped)\";\n try {\n const runtime = new MojoRuntime();\n const health = await runtime.health();\n runtimeAvailable = health.runtime_available;\n if (runtimeAvailable) {\n runtimeDetail = `available — engine ${health.engine}, ${health.module_count} modules`;\n if (flags.parity) {\n liveModules = (await runtime.listModules()).map(descriptor => descriptor.name);\n }\n }\n } catch {\n runtimeAvailable = false;\n }\n checks.push({\n name: \"runtime\",\n ok: true,\n skipped: !runtimeAvailable,\n detail: runtimeAvailable ? runtimeDetail : \"unavailable (checks skipped)\",\n });\n\n // 6. --parity: invariant + live module diff.\n let parity: ParityReport | null = null;\n if (flags.parity && contract) {\n const violations: string[] = [];\n for (const entry of contract.capabilities) {\n if ((entry.typescript || entry.ai_sdk) && !isReadOnlyDeterministic(entry)) {\n violations.push(`${entry.name} (exposed but not read-only deterministic)`);\n }\n if (entry.ai_sdk && !entry.typescript) {\n violations.push(`${entry.name} (ai_sdk without typescript)`);\n }\n }\n\n let missing: string[] = [];\n let extra: string[] = [];\n if (runtimeAvailable && liveModules) {\n const contractModules = new Set<string>();\n for (const entry of contract.capabilities) {\n if (entry.ai_sdk && isReadOnlyDeterministic(entry)) {\n contractModules.add(dispatchModule(entry));\n }\n }\n const live = new Set(liveModules);\n missing = [...contractModules].filter(module => !live.has(module)).sort();\n extra = [...live].filter(module => !contractModules.has(module)).sort();\n }\n\n parity = {\n invariant_ok: violations.length === 0,\n violations,\n runtime: runtimeAvailable ? \"available\" : \"unavailable\",\n missing_modules: missing,\n extra_modules: extra,\n };\n\n const strictFailure = flags.strict && !runtimeAvailable;\n const parityOk =\n violations.length === 0 && missing.length === 0 && extra.length === 0 && !strictFailure;\n let detail: string;\n if (strictFailure) {\n detail = \"runtime unreachable (--parity --strict requires a live runtime)\";\n } else if (!parityOk) {\n const parts: string[] = [];\n if (violations.length > 0) parts.push(`${violations.length} invariant violation(s)`);\n if (missing.length > 0) parts.push(`missing modules: ${missing.join(\", \")}`);\n if (extra.length > 0) parts.push(`extra modules: ${extra.join(\", \")}`);\n detail = parts.join(\"; \");\n } else {\n detail = runtimeAvailable\n ? `invariant holds for ${contract.capabilities.length} capabilities; live modules match`\n : `invariant holds for ${contract.capabilities.length} capabilities; runtime unavailable (live diff skipped)`;\n }\n checks.push({ name: \"parity\", ok: parityOk, detail });\n } else if (flags.parity) {\n checks.push({ name: \"parity\", ok: false, detail: \"cannot run: contract failed to load\" });\n }\n\n const ok = checks.every(check => check.ok);\n const exitCode = ok ? 0 : 1;\n\n if (flags.json) {\n printJson({\n command: \"doctor\",\n ok,\n version: cliVersion(),\n checks,\n ...(contract\n ? {\n contract: {\n capability_count: contract.capabilities.length,\n capability_contract_hash: contract.capability_contract_hash,\n algenta_sdk_version: contract.algenta_sdk_version,\n algenta_core_version: contract.algenta_core_version,\n runtime_bundle_version: contract.runtime_bundle.version,\n },\n }\n : {}),\n ...(parity ? { parity } : {}),\n exit_code: exitCode,\n });\n return exitCode;\n }\n\n for (const check of checks) {\n const mark = check.skipped ? SKIP : check.ok ? OK : FAIL;\n line(`${mark} ${check.name}: ${check.detail}`);\n }\n line(ok ? `${OK} doctor: ok` : `${FAIL} doctor: FAILED`);\n return exitCode;\n}\n","/** Shared CLI plumbing: output helpers, version discovery, repo detection. */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport const OK = \"✓\";\nexport const FAIL = \"✗\";\nexport const SKIP = \"•\";\n\nexport function line(text: string): void {\n process.stdout.write(`${text}\\n`);\n}\n\nexport function errorLine(text: string): void {\n process.stderr.write(`${text}\\n`);\n}\n\n/** --json mode always prints exactly one JSON object to stdout. */\nexport function printJson(payload: Record<string, unknown>): void {\n process.stdout.write(`${JSON.stringify(payload, null, 2)}\\n`);\n}\n\nexport function message(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function cliVersion(): string {\n try {\n const packagePath = fileURLToPath(new URL(\"../package.json\", import.meta.url));\n const parsed = JSON.parse(readFileSync(packagePath, \"utf-8\")) as { version?: string };\n return parsed.version ?? \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\n/** Resolve the INSTALLED @thyn-ai/sqai version (its package.json is not exported,\n * so resolve the entry point and walk up to the package root). */\nexport function sdkVersion(): string {\n try {\n const require_ = createRequire(import.meta.url);\n let dir = dirname(require_.resolve(\"@thyn-ai/sqai\"));\n for (let depth = 0; depth < 6; depth += 1) {\n const candidate = join(dir, \"package.json\");\n if (existsSync(candidate)) {\n const parsed = JSON.parse(readFileSync(candidate, \"utf-8\")) as {\n name?: string;\n version?: string;\n };\n if (parsed.name === \"@thyn-ai/sqai\" && parsed.version) {\n return parsed.version;\n }\n }\n const parent = dirname(dir);\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n } catch {\n // fall through\n }\n return \"unknown\";\n}\n\n/** Find contracts/tested-pair.json walking up from cwd — present only when\n * running inside the sqai repo. */\nexport function findTestedPair(startDir: string): string | null {\n let dir = startDir;\n for (;;) {\n const candidate = join(dir, \"contracts\", \"tested-pair.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(dir);\n if (parent === dir) {\n return null;\n }\n dir = parent;\n }\n}\n\nexport function hashPrefix(hash: string): string {\n const body = hash.startsWith(\"sha256:\") ? hash.slice(\"sha256:\".length) : hash;\n return body.slice(0, 12);\n}\n","/** sqai runtime — status | install | verify | stop.\n *\n * Delegates to @thyn-ai/sqai's RuntimeProvisioner, which now implements the full\n * download → verify (pinned sha256 + RS256 manifest against the embedded\n * trust root) → extract → spawn path. Until a bundle is published for a\n * platform, install is EXPECTED to fail there — every failure prints\n * structured remediation (code, message, details incl. details.reason),\n * never a stack trace. */\n\nimport { RuntimeProvisioner, SqaiError, createSQAI, type RuntimeStatus } from \"@thyn-ai/sqai\";\n\nimport { FAIL, OK, SKIP, line, message, printJson } from \"./shared.js\";\n\nexport type RuntimeSubcommand = \"status\" | \"install\" | \"verify\" | \"stop\";\n\nexport interface RuntimeFlags {\n json: boolean;\n}\n\nfunction buildProvisioner(): { provisioner: RuntimeProvisioner; contract: ReturnType<ReturnType<typeof createSQAI>[\"capabilities\"]> } {\n const contract = createSQAI({ mode: \"local\" }).capabilities();\n return { provisioner: new RuntimeProvisioner({ contract, autoInstall: true }), contract };\n}\n\nfunction printStatusHuman(status: RuntimeStatus): void {\n if (status.runtime_available) {\n line(`${OK} runtime: available — engine ${status.engine}, ${status.module_count} modules`);\n } else {\n line(`${SKIP} runtime: unavailable`);\n }\n line(`${SKIP} platform: ${status.platform}`);\n line(`${SKIP} managed by this process: ${status.managed ? \"yes\" : \"no\"}`);\n}\n\nfunction printSqaiErrorHuman(error: SqaiError): void {\n line(`${FAIL} ${error.code}: ${error.message}`);\n // The provisioner's structured failures carry a machine-readable\n // details.reason (e.g. bundle_sha256_mismatch, rollback_protected) — print\n // it first so remediation reads top-down.\n const entries = Object.entries(error.details).sort(([left], [right]) =>\n left === \"reason\" ? -1 : right === \"reason\" ? 1 : 0,\n );\n for (const [key, value] of entries) {\n line(` ${key}: ${typeof value === \"string\" ? value : JSON.stringify(value)}`);\n }\n}\n\nexport async function runtimeCommand(sub: RuntimeSubcommand, flags: RuntimeFlags): Promise<number> {\n const { provisioner, contract } = buildProvisioner();\n\n if (sub === \"status\") {\n const status = await provisioner.status();\n if (flags.json) {\n printJson({ command: \"runtime status\", ok: true, status, exit_code: 0 });\n } else {\n printStatusHuman(status);\n }\n return 0;\n }\n\n if (sub === \"install\") {\n try {\n await provisioner.ensure();\n const status = await provisioner.status();\n if (flags.json) {\n printJson({ command: \"runtime install\", ok: true, status, exit_code: 0 });\n } else {\n line(`${OK} runtime installed and healthy`);\n printStatusHuman(status);\n }\n return 0;\n } catch (error) {\n const sqaiError =\n error instanceof SqaiError\n ? error\n : new SqaiError(\"runtime_provision_failed\", message(error));\n if (flags.json) {\n printJson({\n command: \"runtime install\",\n ok: false,\n error: {\n code: sqaiError.code,\n message: sqaiError.message,\n retryable: sqaiError.retryable,\n details: sqaiError.details,\n },\n exit_code: 1,\n });\n } else {\n printSqaiErrorHuman(sqaiError);\n }\n return 1;\n }\n }\n\n if (sub === \"verify\") {\n const status = await provisioner.status();\n const bundle = contract.runtime_bundle;\n const platforms = Object.entries(bundle.platforms).map(([platform, info]) => ({\n platform,\n sha256: info.sha256,\n }));\n if (flags.json) {\n printJson({\n command: \"runtime verify\",\n ok: true,\n status,\n runtime_bundle: {\n version: bundle.version || \"unmanaged\",\n platforms,\n },\n contract_hash: contract.capability_contract_hash,\n exit_code: 0,\n });\n } else {\n printStatusHuman(status);\n line(`${SKIP} contract runtime bundle: ${bundle.version || \"unmanaged (no bundle published yet)\"}`);\n if (platforms.length === 0) {\n line(`${SKIP} bundle platforms: none published`);\n }\n for (const entry of platforms) {\n line(`${SKIP} bundle ${entry.platform}: sha256 ${entry.sha256.slice(0, 12)}…`);\n }\n }\n return 0;\n }\n\n // stop\n await provisioner.stop();\n if (flags.json) {\n printJson({ command: \"runtime stop\", ok: true, exit_code: 0 });\n } else {\n line(`${OK} runtime stop requested (v1 policy is leave-running; spawn management lands with the bundle pipeline)`);\n }\n return 0;\n}\n","/** sqai — the SQAI command-line interface.\n *\n * sqai doctor [--parity] [--strict] [--json]\n * sqai runtime status|install|verify|stop [--json]\n * sqai --version\n *\n * Human output is concise checkmark lines; --json prints one JSON object.\n * Plain process.argv parsing — no argument-parsing dependency. */\n\nimport { doctorCommand } from \"./doctor.js\";\nimport { runtimeCommand, type RuntimeSubcommand } from \"./runtime.js\";\nimport { cliVersion, errorLine, hashPrefix, line, message, printJson, sdkVersion } from \"./shared.js\";\n\nconst USAGE = `sqai — deterministic, read-only structured data for AI agents\n\nUsage:\n sqai doctor [--parity] [--strict] [--json] environment, contract, and parity checks\n sqai runtime <status|install|verify|stop> [--json]\n sqai --version CLI + @thyn-ai/sqai versions + contract hash\n sqai help show this help\n`;\n\nconst RUNTIME_SUBCOMMANDS: ReadonlySet<string> = new Set([\"status\", \"install\", \"verify\", \"stop\"]);\n\nasync function versionCommand(json: boolean): Promise<number> {\n let contractHash = \"unknown\";\n try {\n const sdk = await import(\"@thyn-ai/sqai\");\n contractHash = sdk.createSQAI({ mode: \"local\" }).capabilities().capability_contract_hash;\n } catch {\n // keep \"unknown\" — --version must not crash on a broken substrate\n }\n if (json) {\n printJson({\n command: \"version\",\n sqai: cliVersion(),\n \"@thyn-ai/sqai\": sdkVersion(),\n contract_hash: contractHash,\n exit_code: 0,\n });\n } else {\n line(`sqai ${cliVersion()} (@thyn-ai/sqai ${sdkVersion()}, contract ${hashPrefix(contractHash)})`);\n }\n return 0;\n}\n\nasync function main(argv: string[]): Promise<number> {\n const flags = new Set(argv.filter(arg => arg.startsWith(\"-\")));\n const positional = argv.filter(arg => !arg.startsWith(\"-\"));\n const json = flags.has(\"--json\");\n const command = positional[0];\n\n if (flags.has(\"--version\") || flags.has(\"-v\") || command === \"version\") {\n return versionCommand(json);\n }\n if (!command || command === \"help\" || flags.has(\"--help\") || flags.has(\"-h\")) {\n line(USAGE);\n return 0;\n }\n if (command === \"doctor\") {\n return doctorCommand({ parity: flags.has(\"--parity\"), strict: flags.has(\"--strict\"), json });\n }\n if (command === \"runtime\") {\n const sub = positional[1];\n if (!sub || !RUNTIME_SUBCOMMANDS.has(sub)) {\n errorLine(`Unknown runtime subcommand '${sub ?? \"\"}'. Expected status|install|verify|stop.`);\n return 2;\n }\n return runtimeCommand(sub as RuntimeSubcommand, { json });\n }\n\n errorLine(`Unknown command '${command}'.`);\n errorLine(USAGE);\n return 2;\n}\n\nmain(process.argv.slice(2))\n .then(code => {\n process.exitCode = code;\n })\n .catch(error => {\n // Structured last resort — never a stack trace.\n errorLine(`sqai failed: ${message(error)}`);\n process.exitCode = 1;\n });\n"],"mappings":";;;AAQA,SAAS,gBAAAA,qBAAoB;AAC7B,SAAS,mBAAmB;;;ACP5B,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B,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AAK,QAAQ,KAAK,MAAM,CAAC,CAAC,EACvB,KAAK,UAAQ;AACZ,UAAQ,WAAW;AACrB,CAAC,EACA,MAAM,WAAS;AAEd,YAAU,gBAAgB,QAAQ,KAAK,CAAC,EAAE;AAC1C,UAAQ,WAAW;AACrB,CAAC;","names":["readFileSync","readFileSync"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thyn-ai/sqai-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SQAI command-line interface — doctor, runtime provisioning, and contract inspection.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"sqai": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"NOTICE"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"algenta-sdk": "1.0.5",
|
|
21
|
+
"@thyn-ai/sqai": "^0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.10.2",
|
|
25
|
+
"tsup": "^8.3.5",
|
|
26
|
+
"typescript": "~5.6.3",
|
|
27
|
+
"vitest": "^3.2.4"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/thyn-ai/sqai.git",
|
|
32
|
+
"directory": "packages/cli"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://sqai.com",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"sqai",
|
|
37
|
+
"cli",
|
|
38
|
+
"algenta",
|
|
39
|
+
"deterministic",
|
|
40
|
+
"structured-data"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"lint": "tsc --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|