osuite 2.11.2 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # OSuite SDK (v2.11.2)
1
+ # OSuite SDK (v2.13.0)
2
2
 
3
3
  **Governed action SDK for AI agents.**
4
4
 
@@ -25,8 +25,8 @@ node /absolute/path/to/osuite-sdk/sdk/cli.js doctor
25
25
  node /absolute/path/to/osuite-sdk/sdk/cli.js try
26
26
  ```
27
27
 
28
- For this version, use `npx osuite@2.11.2 connect` only after confirming availability
29
- with `npm view osuite@2.11.2 version`. A source checkout or this document alone
28
+ For this version, use `npx osuite@2.13.0 connect` only after confirming availability
29
+ with `npm view osuite@2.13.0 version`. A source checkout or this document alone
30
30
  does not establish registry publication, and npm's `latest` may differ from the
31
31
  checked-out version. The stable credential-recovery behavior and the new
32
32
  native-call operation journal are different mechanisms.
@@ -589,6 +589,22 @@ to the replacement. A client-side installation ID is not permission to rotate.
589
589
 
590
590
  ### SDK and MCP Credential Separation (Since 2.10.2)
591
591
 
592
+ For SDK/MCP integration, connect the explicit runtime rather than relying on
593
+ local-agent auto-detection. A raw workspace key does not supply the full signed
594
+ connection required by `osuite/governed-tools`.
595
+
596
+ Version 2.13.0 adds `osuite doctor --runtime sdk` and
597
+ `osuite doctor --runtime mcp`. These inspect only the selected credential bundle
598
+ and current Studio posture, report its workspace, and do not run project Hooks
599
+ or tools. They are **not available in the published 2.12.0 CLI**. Check the exact
600
+ 2.13.0 registry version before using these commands with an npm installation.
601
+ Do not use bare `doctor` or `try` to validate a particular SDK/MCP lane when
602
+ several runtime configurations coexist: the legacy commands use merged config.
603
+
604
+ A diagnostic success is not approval of a business operation, proof of resource
605
+ mediation, or a completed integration. Keep a stable business ID and private
606
+ journal, and verify the actual resource-side outcome through your wrapped path.
607
+
592
608
  SDK connections use `.osuite/.env`; MCP connections use `.osuite/mcp/.env`.
593
609
  Their installation metadata and recovery journals live beside their respective
594
610
  credential files. Connecting one runtime does not borrow another runtime's key
package/cli.js CHANGED
@@ -145,7 +145,7 @@ function loadDotenvFile(relativePath) {
145
145
 
146
146
  function loadProjectEnvironment() {
147
147
  // Enrollment selects one whole runtime bundle, never a merged global env.
148
- if (process.argv[2] === 'connect') return;
148
+ if (process.argv[2] === 'connect' || CONTROLLED_TRANSFER_CLI || NATIVE_RUNTIME_DOCTOR) return;
149
149
  [...CLI_CREDENTIAL_PATHS, '.env'].forEach((relativePath) => {
150
150
  if (process.argv[2] === 'doctor' && !inspectCredentialFile(process.cwd(), relativePath).safe) return;
151
151
  loadDotenvFile(relativePath);
@@ -174,6 +174,10 @@ function parseArgs(argv) {
174
174
 
175
175
  // Hooks run with the agent's environment, not the values this CLI loads from project .env files.
176
176
  const SHELL_ENV = { ...process.env };
177
+ const CONTROLLED_TRANSFER_CLI = ['doctor', 'mcp'].includes(process.argv[2])
178
+ && process.argv.slice(3).some(value => /^--(?:controlled-transfers|require-controlled-transfers)(?:=|$)/.test(value));
179
+ const NATIVE_RUNTIME_DOCTOR = process.argv[2] === 'doctor'
180
+ && process.argv.slice(3).some(value => /^--runtime(?:=|$)/.test(value));
177
181
  loadProjectEnvironment();
178
182
 
179
183
  function envValue(name, fallback) {
@@ -729,6 +733,10 @@ function printHelp() {
729
733
  write('');
730
734
  write(c('Useful commands', ANSI.bold));
731
735
  write(' osuite doctor Check connection, then run the project hook with a sample call');
736
+ write(' osuite doctor --runtime sdk|mcp Check only that native connection; never run project hooks');
737
+ write(' osuite doctor --controlled-transfers Read strict profile capabilities only (Node 24; --runtime sdk|mcp)');
738
+ write(' --require-controlled-transfers is an alias; this does not certify deployment qualification');
739
+ write(' osuite mcp --controlled-transfers Three controlled-ledger tools over bounded NDJSON stdio (Node 24)');
732
740
  write(' osuite try Review one fixed, harmless terminal acknowledgement');
733
741
  write(' osuite status Ping Studio and show current workspace connection');
734
742
  write(' osuite explain "git push origin main" Explain how CAVA/Decision V2 will read a command');
@@ -1183,6 +1191,37 @@ function printExplanation(command) {
1183
1191
  }
1184
1192
  }
1185
1193
 
1194
+ async function controlledTransferDiagnosis({ strict = false, runtime = 'sdk' } = {}) {
1195
+ const { probeMatoiStatus, formatMatoiStatus } = await import('./matoiDoctor.mjs');
1196
+ const { loadControlledTransferCliConfig } = await import('./controlled-transfers/cli-config.mjs');
1197
+ let status;
1198
+ try {
1199
+ const config = loadControlledTransferCliConfig({ projectRoot: process.cwd(), shellEnv: SHELL_ENV, runtime });
1200
+ status = await probeMatoiStatus({ config });
1201
+ } catch (error) {
1202
+ status = { ...await probeMatoiStatus(), code: error.code || 'INVALID_CONFIGURATION' };
1203
+ }
1204
+ write(formatMatoiStatus(status));
1205
+ if (strict && !status.configured) process.exitCode = 1;
1206
+ return status.configured === true;
1207
+ }
1208
+
1209
+ async function controlledTransferCommand(command, args) {
1210
+ const { fail } = await import('./controlled-transfers/contract.mjs');
1211
+ const allowed = command === 'doctor' ? ['_', 'controlled-transfers', 'require-controlled-transfers', 'runtime'] : ['_', 'controlled-transfers'];
1212
+ if (args._.length || Object.keys(args).some(key => !allowed.includes(key))
1213
+ || ['controlled-transfers', 'require-controlled-transfers'].some(key => Object.hasOwn(args, key) && args[key] !== true)
1214
+ || (command === 'mcp' && args['controlled-transfers'] !== true)
1215
+ || (command === 'doctor' && args.runtime !== undefined && !['sdk', 'mcp'].includes(args.runtime))) {
1216
+ fail('INVALID_CONTROLLED_TRANSFER_OPTIONS');
1217
+ }
1218
+ if (command === 'doctor') return controlledTransferDiagnosis({ strict: true, runtime: args.runtime || 'sdk' });
1219
+ const { loadControlledTransferCliConfig } = await import('./controlled-transfers/cli-config.mjs');
1220
+ const { runControlledTransferStdio } = await import('./controlled-transfers-stdio.mjs');
1221
+ const config = loadControlledTransferCliConfig({ projectRoot: process.cwd(), shellEnv: SHELL_ENV, runtime: 'mcp' });
1222
+ if (!await runControlledTransferStdio(config)) process.exitCode = 1;
1223
+ }
1224
+
1186
1225
  async function doctor() {
1187
1226
  const config = readConfig();
1188
1227
  let ok = true;
@@ -1246,6 +1285,8 @@ async function doctor() {
1246
1285
  if (!hookChecks.length) writeCheckLine('miss', 'Agent hooks', 'none in this project (fine for SDK and MCP runtimes)');
1247
1286
  const hooksOk = hookChecks.every((check) => check.ok);
1248
1287
 
1288
+ write('');
1289
+ await controlledTransferDiagnosis();
1249
1290
  write('');
1250
1291
  if (!ok || !hooksOk) {
1251
1292
  write(c('Next step', ANSI.bold));
@@ -1590,8 +1631,10 @@ async function connectProject(target = 'auto', args = {}) {
1590
1631
  write(opened
1591
1632
  ? ' 1. Studio opened in your browser. Check the code matches, then approve this terminal.'
1592
1633
  : ' 1. Open the browser handoff URL, check the code matches, then approve this terminal in Studio.');
1593
- write(' 2. OSuite prepares the runtime identity, project hook lane, and signed env for this project.');
1594
- write(' 3. Return here; the CLI will finish automatically and then you can run osuite doctor.');
1634
+ write(PROJECT_BOOTSTRAPS[runtime]
1635
+ ? ' 2. OSuite prepares the runtime identity, project hook lane, and signed env for this project.'
1636
+ : ' 2. OSuite prepares this signed SDK/MCP connection. No project Hook is installed.');
1637
+ write(` 3. Return here; the CLI will finish automatically and then you can run osuite doctor${PROJECT_BOOTSTRAPS[runtime] ? '' : ` --runtime ${runtime}`}.`);
1595
1638
  write('');
1596
1639
 
1597
1640
  let install = null;
@@ -1659,7 +1702,8 @@ async function connectProject(target = 'auto', args = {}) {
1659
1702
  write(`Saved credentials to ${result.relativePath}`);
1660
1703
  if (!PROJECT_BOOTSTRAPS[runtime]) {
1661
1704
  write(c('Connected to OSuite', ANSI.green));
1662
- write(' Run osuite doctor, then start the agent from this project root.');
1705
+ write(` Run osuite doctor --runtime ${runtime} to check this connection without invoking project Hooks.`);
1706
+ write(' Connection readiness is not business-workflow qualification. Integrate and test the actual consequential tool path.');
1663
1707
  } else if (!install?.ok) {
1664
1708
  write(c('Not connected: OSuite hook setup is not ready, so this agent is not governed.', ANSI.red));
1665
1709
  (install?.blockers || []).forEach((blocker) => write(` ${blocker}`));
@@ -1693,7 +1737,10 @@ async function connectProject(target = 'auto', args = {}) {
1693
1737
 
1694
1738
  write('');
1695
1739
  write(c('API key fallback', ANSI.bold));
1696
- if (hasApiKey) {
1740
+ if (!PROJECT_BOOTSTRAPS[runtime]) {
1741
+ write(' A raw API key alone is not equivalent to this signed SDK/MCP connection.');
1742
+ write(` Retain the complete private credential bundle and use osuite doctor --runtime ${runtime}; do not mix credentials from other runtime folders.`);
1743
+ } else if (hasApiKey) {
1697
1744
  write(' OSUITE_API_KEY is already present in this shell or project env. Browser handoff can be skipped for this project.');
1698
1745
  } else if (PROJECT_BOOTSTRAPS[runtime]) {
1699
1746
  write(' If browser handoff is unavailable, supply OSUITE_BASE_URL and OSUITE_API_KEY through your secret manager or process environment.');
@@ -1775,6 +1822,36 @@ async function main() {
1775
1822
 
1776
1823
  if (['help', '--help', '-h'].includes(command)) return printHelp();
1777
1824
  if (['version', '--version', '-v'].includes(command)) return write(pkg.version);
1825
+ if (CONTROLLED_TRANSFER_CLI) return controlledTransferCommand(command, args);
1826
+ if (NATIVE_RUNTIME_DOCTOR) {
1827
+ if (args._.length || !['sdk', 'mcp'].includes(args.runtime) || Object.keys(args).some(key => !['_', 'runtime'].includes(key))) {
1828
+ throw new Error('INVALID_RUNTIME_OPTIONS: use osuite doctor --runtime sdk or mcp');
1829
+ }
1830
+ try {
1831
+ const { diagnoseNativeRuntime } = await import('./nativeDoctor.mjs');
1832
+ const diagnosis = await diagnoseNativeRuntime({ runtime: args.runtime, projectRoot: process.cwd(), shellEnv: SHELL_ENV });
1833
+ write(`Native ${args.runtime} connection configuration and current Studio posture verified.`);
1834
+ write(`Workspace: ${diagnosis.orgId}`);
1835
+ write('No tool was executed. This is not business-workflow qualification or proof of resource enforcement.');
1836
+ write('Integrate the native wrapper, retain business IDs/journal, and verify one real resource outcome next.');
1837
+ } catch (error) {
1838
+ const code = /^[A-Z][A-Z0-9_]+$/.test(error?.code || '') ? error.code : 'DIAGNOSIS_FAILED';
1839
+ write(`Native ${args.runtime} diagnosis: ${code}`);
1840
+ write('Preserve credentials and recovery files.');
1841
+ if (code === 'CONNECTION_RECOVERY_PENDING') {
1842
+ write('If another connect process is running, wait for it to finish.');
1843
+ write('Otherwise, resume your original connect command with the same runtime, agent and explicit --base-url (if originally supplied).');
1844
+ } else if (code === 'MCP_MIGRATION_PENDING') {
1845
+ write('Resume osuite connect mcp --migrate-legacy.');
1846
+ write('If enrollment still needs recovery afterwards, use its original command with the original --base-url (if supplied).');
1847
+ } else {
1848
+ write('Review this diagnostic and your local configuration with the workspace administrator.');
1849
+ write('Do not reconnect or reissue credentials automatically; revoked access requires an explicit authorized decision.');
1850
+ }
1851
+ process.exitCode = 1;
1852
+ }
1853
+ return;
1854
+ }
1778
1855
  if (command === 'doctor') return runDoctorWithMeasurement(doctor, { config: readConfig(), emit: write });
1779
1856
  if (command === 'try') return tryWalkthrough(args);
1780
1857
  if (command === 'status') return status();
@@ -1796,6 +1873,9 @@ async function main() {
1796
1873
  }
1797
1874
 
1798
1875
  main().catch((error) => {
1799
- process.stderr.write(`${error?.message || String(error)}\n`);
1876
+ const message = CONTROLLED_TRANSFER_CLI
1877
+ ? /^[A-Z][A-Z0-9_]{0,63}$/.test(error?.code) ? `Matoi ${error.code}` : 'Matoi CONTROLLED_TRANSFER_COMMAND_FAILED'
1878
+ : error?.message || String(error);
1879
+ process.stderr.write(`${message}\n`);
1800
1880
  process.exit(1);
1801
1881
  });
@@ -0,0 +1,89 @@
1
+ import { statSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { inspectCredentialFile, readCredentialFile } from '../credentials.js';
4
+ import { MCP_ENV_PATH, MCP_MIGRATION_PATH, SDK_ENV_PATH, parseInstallationIdentity } from '../installationIdentity.js';
5
+ import { loadRuntimeConfig } from '../runtime/config.mjs';
6
+ import { configuration, ControlledTransferError, fail } from './contract.mjs';
7
+
8
+ const fields = ['BASE_URL', 'API_KEY', 'PRIVATE_KEY_BASE64', 'AGENT_ID', 'ORG_ID', 'AGENT_KEY_ID',
9
+ 'RUNTIME_ADAPTER_ID', 'SIGNATURE_MODE', 'GUARD_FAILURE_MODE', 'HOOK_MODE', 'ALLOW_INSECURE_HTTP',
10
+ 'MATOI_ISSUER_PUBLIC_KEY_BASE64', 'MATOI_TRUSTED_ISSUER_PUBLIC_KEYS_B64', 'MATOI_TIMEOUT_MS'];
11
+
12
+ function parseEnvironment(raw) {
13
+ if (Buffer.byteLength(raw) > 65536) fail('INVALID_CREDENTIAL_FILE');
14
+ const env = Object.create(null);
15
+ for (const line of raw.split(/\r?\n/)) {
16
+ if (!line.trim() || line.trim().startsWith('#')) continue;
17
+ const match = line.match(/^\s*(?:export\s+)?((?:OSUITE|DASHCLAW)_[A-Z0-9_]+)\s*=\s*(.*?)\s*$/);
18
+ if (!match) fail('INVALID_CREDENTIAL_FILE');
19
+ if (Object.hasOwn(env, match[1])) fail('INVALID_CREDENTIAL_FILE');
20
+ let value = match[2];
21
+ if (/^['"]/.test(value)) {
22
+ const quoted = value.match(/^(['"])(.*?)\1(?:\s+#.*)?$/);
23
+ if (!quoted) fail('INVALID_CREDENTIAL_FILE');
24
+ value = quoted[2];
25
+ } else value = value.replace(/\s+#.*$/, '');
26
+ env[match[1]] = value;
27
+ }
28
+ return env;
29
+ }
30
+
31
+ function selectedEnvironment(env) {
32
+ const result = Object.create(null);
33
+ for (const field of fields) {
34
+ const primary = env[`OSUITE_${field}`], legacy = env[`DASHCLAW_${field}`];
35
+ if (primary !== undefined && legacy !== undefined && primary !== legacy) fail('CREDENTIAL_SOURCE_CONFLICT');
36
+ if (primary !== undefined || legacy !== undefined) result[`OSUITE_${field}`] = primary ?? legacy;
37
+ }
38
+ return result;
39
+ }
40
+
41
+ export function loadControlledTransferCliConfig({ projectRoot = process.cwd(), shellEnv = process.env, runtime = 'sdk' } = {}) {
42
+ if (Number(process.versions.node.split('.')[0]) !== 24) fail('NODE_24_REQUIRED');
43
+ if (!['sdk', 'mcp'].includes(runtime)) fail('INVALID_CONTROLLED_TRANSFER_OPTIONS');
44
+ const envPath = runtime === 'mcp' ? MCP_ENV_PATH : SDK_ENV_PATH;
45
+ let raw;
46
+ try {
47
+ const checks = [envPath, `${envPath}.identity.json`, `${envPath}.connect.json`, `${envPath}.connect.lock`, MCP_MIGRATION_PATH]
48
+ .map(file => inspectCredentialFile(projectRoot, file));
49
+ if (checks.some(check => !check.safe)) fail('UNSAFE_CREDENTIALS');
50
+ if (checks.find(check => check.relativePath === MCP_MIGRATION_PATH)?.exists) fail('MCP_MIGRATION_PENDING');
51
+ if (checks.some(check => check.exists && /\.connect\.(json|lock)$/.test(check.relativePath))) fail('CONNECTION_RECOVERY_PENDING');
52
+ if (checks[0].exists && statSync(path.join(projectRoot, envPath)).size > 65536) fail('INVALID_CREDENTIAL_FILE');
53
+ raw = readCredentialFile(projectRoot, envPath);
54
+ parseInstallationIdentity(readCredentialFile(projectRoot, `${envPath}.identity.json`), runtime);
55
+ } catch (error) {
56
+ if (error instanceof ControlledTransferError) throw error;
57
+ fail('UNSAFE_CREDENTIALS');
58
+ }
59
+ const shell = selectedEnvironment(shellEnv);
60
+ const source = raw === null ? shell : selectedEnvironment(parseEnvironment(raw));
61
+ if (raw !== null && Object.entries(shell).some(([key, value]) => source[key] !== value)) fail('CREDENTIAL_SOURCE_CONFLICT');
62
+ // Never fill a partial credential/identity bundle from another file or from the shell.
63
+ if (['BASE_URL', 'API_KEY', 'PRIVATE_KEY_BASE64', 'AGENT_ID', 'ORG_ID'].some(key => !source[`OSUITE_${key}`])
64
+ || source.OSUITE_SIGNATURE_MODE !== 'required' || source.OSUITE_GUARD_FAILURE_MODE !== 'block'
65
+ || (source.OSUITE_HOOK_MODE !== undefined && !['enforce', 'strict'].includes(source.OSUITE_HOOK_MODE))
66
+ || (source.OSUITE_ALLOW_INSECURE_HTTP !== undefined && source.OSUITE_ALLOW_INSECURE_HTTP !== '0')
67
+ || !(runtime === 'mcp' ? ['mcp'] : ['sdk', 'framework_sdk', 'inline_sdk']).includes(source.OSUITE_RUNTIME_ADAPTER_ID)) {
68
+ fail('INVALID_CONFIGURATION');
69
+ }
70
+ const configured = loadRuntimeConfig({ env: source, host: runtime, runtimeId: source.OSUITE_RUNTIME_ADAPTER_ID });
71
+ const pin = source.OSUITE_MATOI_ISSUER_PUBLIC_KEY_BASE64;
72
+ if (pin !== undefined && !/^[A-Za-z0-9+/]+={0,2}$/.test(pin)) fail('INVALID_CONFIGURATION');
73
+ const timeout = source.OSUITE_MATOI_TIMEOUT_MS;
74
+ if (timeout !== undefined && !/^[1-9][0-9]{0,4}$/.test(timeout)) fail('INVALID_CONFIGURATION');
75
+ const history = source.OSUITE_MATOI_TRUSTED_ISSUER_PUBLIC_KEYS_B64;
76
+ let trustedIssuerPublicKeys = [];
77
+ if (history !== undefined) {
78
+ try {
79
+ if (history.length > 32768 || !/^[A-Za-z0-9+/]+={0,2}$/.test(history)) throw new Error();
80
+ const bytes = Buffer.from(history, 'base64');
81
+ if (bytes.toString('base64') !== history) throw new Error();
82
+ trustedIssuerPublicKeys = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
83
+ } catch { fail('INVALID_CONFIGURATION'); }
84
+ }
85
+ return configuration({ config: { ...configured, keyId: source.OSUITE_AGENT_KEY_ID,
86
+ issuerPublicKey: pin === undefined ? null : Buffer.from(pin, 'base64').toString('utf8'),
87
+ trustedIssuerPublicKeys,
88
+ timeoutMs: timeout === undefined ? 2500 : Number(timeout) } });
89
+ }