osuite 2.12.0 → 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/CONTROLLED_TRANSFERS.md +134 -9
- package/GOVERNED_TOOLS.md +1 -1
- package/README.md +19 -3
- package/cli.js +43 -5
- package/credentials.js +5 -1
- package/governed-tools/journal.mjs +9 -3
- package/nativeDoctor.mjs +83 -0
- package/package.json +2 -1
package/CONTROLLED_TRANSFERS.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# Matoi Controlled Transfers
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
**Available starting in `osuite@2.12.0`.** This additive entry is not present in
|
|
4
|
+
`osuite@2.11.2`. Confirm the chosen registry version with
|
|
5
|
+
`npm view osuite@2.12.0 version`. Version 2.12.0 was released with the server profile disabled by default;
|
|
6
|
+
SDK publication does not enroll a workspace or qualify a customer deployment.
|
|
7
|
+
A matching server, explicit operator setup and deployment acceptance are still
|
|
8
|
+
required before customer rollout.
|
|
7
9
|
|
|
8
10
|
The additive ESM entry `osuite/controlled-transfers` speaks the
|
|
9
11
|
`matoi.controlled-transfer.v1` semantic profile to the resource-owned **controlled ledger**.
|
|
10
|
-
Its default full lease remains v1;
|
|
12
|
+
Its default full lease remains v1; the SDK also reads explicitly requested
|
|
11
13
|
compact `matoi.controlled-transfer.lease.v2` leases, as described below.
|
|
12
14
|
It requires **Node 24**. The ordinary SDK exports, Hook, runtime requirements,
|
|
13
15
|
installation settings and signing transport are unchanged.
|
|
@@ -52,6 +54,18 @@ is complete. Initial ledger balances do not represent an actual bank deposit.
|
|
|
52
54
|
real Studio review, execute and verify its receipt, then test rejection and
|
|
53
55
|
recovery. Doctor success reports configuration, not deployment certification.
|
|
54
56
|
|
|
57
|
+
**Fresh self-host operator prerequisite:** a successful local-password dashboard
|
|
58
|
+
login or SDK/MCP enrollment does not itself create a current workspace
|
|
59
|
+
owner/admin membership. Configuration can therefore return
|
|
60
|
+
`403 HUMAN_ADMINISTRATOR_REQUIRED` after those earlier steps succeed. The
|
|
61
|
+
current workspace bootstrap/creation APIs are SaaS-only; the fresh self-host
|
|
62
|
+
first-owner path still needs a documented and qualified provisioning procedure.
|
|
63
|
+
Do not bypass the check, insert an invented reviewer, or mistake a token's admin
|
|
64
|
+
label for membership. Keep the profile disabled until an eligible operator and
|
|
65
|
+
the complete resource-side workflow have been verified. This does not prevent
|
|
66
|
+
ordinary SDK/MCP connection setup, but it prevents claiming this profile is
|
|
67
|
+
turnkey on the local-password-only installation path.
|
|
68
|
+
|
|
55
69
|
Configuration requests have the following exact fields. Tenant and administrator
|
|
56
70
|
identity come from the authenticated session, never these JSON bodies.
|
|
57
71
|
|
|
@@ -63,14 +77,125 @@ identity come from the authenticated session, never these JSON bodies.
|
|
|
63
77
|
| `authority` | `grantId`, `active`, and optionally `allowedEffects`, `budgetMinor` | Revoke/reactivate or update current authority without widening the original boundary |
|
|
64
78
|
| `state` | `grantId`, `state` | Update owner-controlled workflow state; relevant changes require reassessment |
|
|
65
79
|
|
|
66
|
-
The workflow grammar and exact effect example are in the
|
|
67
|
-
[implementation contract](../docs/superpowers/plans/2026-10-31-matoi-controlled-transfer-implementation.md).
|
|
68
80
|
Expiry is an integer Unix time in milliseconds, at most 24 hours ahead; prepared
|
|
69
81
|
leases last at most five minutes and cannot outlive the grant. An operator must
|
|
70
82
|
source each allowed `paymentId` from its business records, not let the agent mint
|
|
71
83
|
new authorized payments. A deployment must also prevent direct access to the
|
|
72
84
|
underlying ledger; this configuration API alone does not prove route coverage.
|
|
73
85
|
|
|
86
|
+
### Single-Transfer Operator Example
|
|
87
|
+
|
|
88
|
+
After completing the prerequisites above, use a fresh, owned test ledger for
|
|
89
|
+
this example. From a current owner/admin session, send these **three separate POST requests**
|
|
90
|
+
in order to `/api/matoi/transfers/configuration`, each with
|
|
91
|
+
`Content-Type: application/json`. Keep browser requests same-origin; do not use
|
|
92
|
+
an agent API key or put workspace/administrator identity in the request body.
|
|
93
|
+
|
|
94
|
+
First initialize storage:
|
|
95
|
+
|
|
96
|
+
<!-- controlled-transfer-initialize:start -->
|
|
97
|
+
```json
|
|
98
|
+
{"kind":"initialize"}
|
|
99
|
+
```
|
|
100
|
+
<!-- controlled-transfer-initialize:end -->
|
|
101
|
+
|
|
102
|
+
Then provision the source account with 250 synthetic minor units:
|
|
103
|
+
|
|
104
|
+
<!-- controlled-transfer-source-account:start -->
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"kind": "account", "accountId": "treasury",
|
|
108
|
+
"asset": "USD", "network": "internal-ledger", "decimals": 2,
|
|
109
|
+
"balanceMinor": "250", "debitLimitMinor": "250"
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
<!-- controlled-transfer-source-account:end -->
|
|
113
|
+
|
|
114
|
+
Provision the distinct destination account; its zero debit limit permits receipt,
|
|
115
|
+
not spending:
|
|
116
|
+
|
|
117
|
+
<!-- controlled-transfer-destination-account:start -->
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"kind": "account", "accountId": "vendor-a",
|
|
121
|
+
"asset": "USD", "network": "internal-ledger", "decimals": 2,
|
|
122
|
+
"balanceMinor": "0", "debitLimitMinor": "0"
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
<!-- controlled-transfer-destination-account:end -->
|
|
126
|
+
|
|
127
|
+
These create new accounts; they are not account resets or top-ups. Do not repeat
|
|
128
|
+
provisioning to restore spent capacity. Do not retry configuration POSTs automatically;
|
|
129
|
+
after a timeout or unclear response, stop and have the operator verify existing
|
|
130
|
+
configuration and audit history before deciding what to do next.
|
|
131
|
+
|
|
132
|
+
The following JSON is the finite `plan`, not a complete configuration request.
|
|
133
|
+
It needs only one `transfer` node and empty `state`; each operand uses `literal`.
|
|
134
|
+
`allowedEffects` repeats the exact resolved effect with `operation: "transfer"`
|
|
135
|
+
instead of the workflow's `op`. Amounts and budgets are integer strings; decimals
|
|
136
|
+
is an integer. Use an owner-authorized payment ID and change both occurrences
|
|
137
|
+
consistently. Both accounts must match the effect's asset, network and decimals.
|
|
138
|
+
|
|
139
|
+
<!-- controlled-transfer-plan:start -->
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"workflow": {
|
|
143
|
+
"version": 1,
|
|
144
|
+
"body": {
|
|
145
|
+
"op": "transfer",
|
|
146
|
+
"paymentId": { "literal": "payment-42" },
|
|
147
|
+
"sourceAccount": { "literal": "treasury" },
|
|
148
|
+
"destination": { "literal": "vendor-a" },
|
|
149
|
+
"asset": { "literal": "USD" },
|
|
150
|
+
"network": { "literal": "internal-ledger" },
|
|
151
|
+
"amountMinor": { "literal": "250" },
|
|
152
|
+
"decimals": { "literal": 2 }
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"state": {},
|
|
156
|
+
"allowedEffects": [{
|
|
157
|
+
"operation": "transfer", "paymentId": "payment-42",
|
|
158
|
+
"sourceAccount": "treasury", "destination": "vendor-a",
|
|
159
|
+
"asset": "USD", "network": "internal-ledger",
|
|
160
|
+
"amountMinor": "250", "decimals": 2
|
|
161
|
+
}],
|
|
162
|
+
"budgetMinor": "250"
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
<!-- controlled-transfer-plan:end -->
|
|
166
|
+
|
|
167
|
+
Parse that JSON as `plan` in your operator script. Set `enrolledAgentId` and
|
|
168
|
+
`enrolledKeyId` to the actual current SDK/MCP enrollment's agent ID and active
|
|
169
|
+
key ID, not invented labels or the raw API-key secret. Construct the grant just
|
|
170
|
+
before sending so `expiresAt` is a fresh numeric Unix-millisecond timestamp,
|
|
171
|
+
strictly in the future and no more than 24 hours ahead of the server clock:
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
const grant = {
|
|
175
|
+
...plan,
|
|
176
|
+
kind: 'grant',
|
|
177
|
+
agent_id: enrolledAgentId,
|
|
178
|
+
keyId: enrolledKeyId,
|
|
179
|
+
grantId: 'owner-grant-42',
|
|
180
|
+
expiresAt: Date.now() + 10 * 60 * 1000,
|
|
181
|
+
};
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Send `JSON.stringify(grant)` as one further POST body to the same configuration
|
|
185
|
+
route through the authenticated administrator flow. Registration neither enrolls
|
|
186
|
+
the agent nor approves or executes a payment. Next use the SDK configuration and
|
|
187
|
+
`prepare('invoice-batch-42', 'owner-grant-42')` example below, retain its original
|
|
188
|
+
operation ID/preparation, complete the **real native Studio review** with the
|
|
189
|
+
required eligible people, and only then deliberately request ordinal 0 execution.
|
|
190
|
+
A pending review is not authorization. A lost execution acknowledgement requires
|
|
191
|
+
`status`-only recovery, not an automatic resend or a new operation/payment ID.
|
|
192
|
+
|
|
193
|
+
One independently confirmed commit changes these fresh balances to treasury `0`
|
|
194
|
+
and vendor-a `250`, with grant spend `250` and one payment receipt. Verify the
|
|
195
|
+
exact effect/receipt and resource state; approval or a derived view alone is not
|
|
196
|
+
completion. This recipe does not complete product qualification, establish
|
|
197
|
+
customer onboarding success, or cover a bank, blockchain or another resource.
|
|
198
|
+
|
|
74
199
|
## Configuration
|
|
75
200
|
|
|
76
201
|
```js
|
|
@@ -499,9 +624,9 @@ they are not evidence of real financial writes, native Studio review, or
|
|
|
499
624
|
deployment qualification. Owner/PostgreSQL/live route acceptance is a separate
|
|
500
625
|
integration gate.
|
|
501
626
|
|
|
502
|
-
## Transport And Rotation
|
|
627
|
+
## Transport And Rotation Since 2.12.0
|
|
503
628
|
|
|
504
|
-
The `2.12.0`
|
|
629
|
+
The published `2.12.0` client does not by itself establish a qualified
|
|
505
630
|
server deployment. When fresh capabilities advertise
|
|
506
631
|
`executionTransport: 'bound-reference-v1'`, the execute POST sends the verified
|
|
507
632
|
`preparationDigest` instead of repeating the complete signed `lease`. The client
|
package/GOVERNED_TOOLS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Native Tool Compatibility And Recovery
|
|
2
2
|
|
|
3
3
|
This opt-in API is introduced in 2.11.0; it is not part of 2.10.2. Confirm the
|
|
4
|
-
chosen version with `npm view osuite@2.
|
|
4
|
+
chosen version with `npm view osuite@2.12.0 version` before installing. A source
|
|
5
5
|
checkout alone does not establish npm availability or server compatibility;
|
|
6
6
|
consult the verified release record before enabling it for a workspace.
|
|
7
7
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# OSuite SDK (v2.
|
|
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.
|
|
29
|
-
with `npm view osuite@2.
|
|
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' || CONTROLLED_TRANSFER_CLI) 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);
|
|
@@ -176,6 +176,8 @@ function parseArgs(argv) {
|
|
|
176
176
|
const SHELL_ENV = { ...process.env };
|
|
177
177
|
const CONTROLLED_TRANSFER_CLI = ['doctor', 'mcp'].includes(process.argv[2])
|
|
178
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));
|
|
179
181
|
loadProjectEnvironment();
|
|
180
182
|
|
|
181
183
|
function envValue(name, fallback) {
|
|
@@ -731,6 +733,7 @@ function printHelp() {
|
|
|
731
733
|
write('');
|
|
732
734
|
write(c('Useful commands', ANSI.bold));
|
|
733
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');
|
|
734
737
|
write(' osuite doctor --controlled-transfers Read strict profile capabilities only (Node 24; --runtime sdk|mcp)');
|
|
735
738
|
write(' --require-controlled-transfers is an alias; this does not certify deployment qualification');
|
|
736
739
|
write(' osuite mcp --controlled-transfers Three controlled-ledger tools over bounded NDJSON stdio (Node 24)');
|
|
@@ -1628,8 +1631,10 @@ async function connectProject(target = 'auto', args = {}) {
|
|
|
1628
1631
|
write(opened
|
|
1629
1632
|
? ' 1. Studio opened in your browser. Check the code matches, then approve this terminal.'
|
|
1630
1633
|
: ' 1. Open the browser handoff URL, check the code matches, then approve this terminal in Studio.');
|
|
1631
|
-
write(
|
|
1632
|
-
|
|
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}`}.`);
|
|
1633
1638
|
write('');
|
|
1634
1639
|
|
|
1635
1640
|
let install = null;
|
|
@@ -1697,7 +1702,8 @@ async function connectProject(target = 'auto', args = {}) {
|
|
|
1697
1702
|
write(`Saved credentials to ${result.relativePath}`);
|
|
1698
1703
|
if (!PROJECT_BOOTSTRAPS[runtime]) {
|
|
1699
1704
|
write(c('Connected to OSuite', ANSI.green));
|
|
1700
|
-
write(
|
|
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.');
|
|
1701
1707
|
} else if (!install?.ok) {
|
|
1702
1708
|
write(c('Not connected: OSuite hook setup is not ready, so this agent is not governed.', ANSI.red));
|
|
1703
1709
|
(install?.blockers || []).forEach((blocker) => write(` ${blocker}`));
|
|
@@ -1731,7 +1737,10 @@ async function connectProject(target = 'auto', args = {}) {
|
|
|
1731
1737
|
|
|
1732
1738
|
write('');
|
|
1733
1739
|
write(c('API key fallback', ANSI.bold));
|
|
1734
|
-
if (
|
|
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) {
|
|
1735
1744
|
write(' OSUITE_API_KEY is already present in this shell or project env. Browser handoff can be skipped for this project.');
|
|
1736
1745
|
} else if (PROJECT_BOOTSTRAPS[runtime]) {
|
|
1737
1746
|
write(' If browser handoff is unavailable, supply OSUITE_BASE_URL and OSUITE_API_KEY through your secret manager or process environment.');
|
|
@@ -1814,6 +1823,35 @@ async function main() {
|
|
|
1814
1823
|
if (['help', '--help', '-h'].includes(command)) return printHelp();
|
|
1815
1824
|
if (['version', '--version', '-v'].includes(command)) return write(pkg.version);
|
|
1816
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
|
+
}
|
|
1817
1855
|
if (command === 'doctor') return runDoctorWithMeasurement(doctor, { config: readConfig(), emit: write });
|
|
1818
1856
|
if (command === 'try') return tryWalkthrough(args);
|
|
1819
1857
|
if (command === 'status') return status();
|
package/credentials.js
CHANGED
|
@@ -164,8 +164,12 @@ export function prepareCredentialFile(projectRoot, relativePath) {
|
|
|
164
164
|
return target;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
export function writeCredentialFile(projectRoot, relativePath, body) {
|
|
167
|
+
export function writeCredentialFile(projectRoot, relativePath, body, options = {}) {
|
|
168
168
|
const target = prepareCredentialFile(projectRoot, relativePath);
|
|
169
|
+
// Interactive callers must not adopt a newer operator edit at this handoff.
|
|
170
|
+
if (Object.hasOwn(options, 'expectedStat') && !sameFile(options.expectedStat, target.stat)) {
|
|
171
|
+
throw new Error('Credential destination changed since it was read; refusing to replace it.');
|
|
172
|
+
}
|
|
169
173
|
atomicWrite(target, String(body), 0o600, { credential: true });
|
|
170
174
|
return { relativePath: target.relativePath, status: 'written' };
|
|
171
175
|
}
|
|
@@ -99,8 +99,8 @@ function maybeStat(path) {
|
|
|
99
99
|
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function checkFile(stat) {
|
|
103
|
-
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !==
|
|
102
|
+
function checkFile(stat, expectedLinks = 1) {
|
|
103
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== expectedLinks
|
|
104
104
|
|| stat.uid !== process.getuid() || (stat.mode & 0o077)) fail('JOURNAL_PERMISSIONS');
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -258,7 +258,13 @@ export class OperationJournal {
|
|
|
258
258
|
const current = privateDirectory(this.#directory.path, false);
|
|
259
259
|
if (!sameFile(current.stat, this.#directory.stat)) fail('JOURNAL_PERMISSIONS');
|
|
260
260
|
for (const suffix of ['', '-wal', '-shm', '-journal']) {
|
|
261
|
-
|
|
261
|
+
let stat = maybeStat(`${this.#path}${suffix}`);
|
|
262
|
+
if (suffix && stat?.nlink === 0) {
|
|
263
|
+
// SQLite can retire a sidecar during lstat. Recheck once, retaining all
|
|
264
|
+
// type, ownership and mode checks on both observations.
|
|
265
|
+
checkFile(stat, 0);
|
|
266
|
+
stat = maybeStat(`${this.#path}${suffix}`);
|
|
267
|
+
}
|
|
262
268
|
if (stat) {
|
|
263
269
|
checkFile(stat);
|
|
264
270
|
if (!suffix && this.#file && !sameFile(stat, this.#file)) fail('JOURNAL_PERMISSIONS');
|
package/nativeDoctor.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createPrivateKey } from 'node:crypto';
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { inspectCredentialFile, readCredentialFile } from './credentials.js';
|
|
5
|
+
import { MCP_ENV_PATH, MCP_MIGRATION_PATH, SDK_ENV_PATH, parseInstallationIdentity } from './installationIdentity.js';
|
|
6
|
+
import { loadRuntimeConfig } from './runtime/config.mjs';
|
|
7
|
+
import { createApiClient, safeId, validatedBaseUrl } from './runtime/protocol.mjs';
|
|
8
|
+
import { resolveRemotePosture } from './runtime/posture.mjs';
|
|
9
|
+
|
|
10
|
+
function fail(code) { throw Object.assign(new Error(code), { code }); }
|
|
11
|
+
function parse(raw) {
|
|
12
|
+
if (Buffer.byteLength(raw) > 65536) fail('INVALID_CREDENTIAL_FILE');
|
|
13
|
+
const env = Object.create(null);
|
|
14
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
15
|
+
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
16
|
+
const match = line.match(/^\s*(?:export\s+)?((?:OSUITE|DASHCLAW)_[A-Z0-9_]+)\s*=\s*(.*?)\s*$/);
|
|
17
|
+
if (!match || Object.hasOwn(env, match[1])) fail('INVALID_CREDENTIAL_FILE');
|
|
18
|
+
let value = match[2];
|
|
19
|
+
if (/^['"]/.test(value)) {
|
|
20
|
+
const quoted = value.match(/^(['"])(.*?)\1(?:\s+#.*)?$/);
|
|
21
|
+
if (!quoted) fail('INVALID_CREDENTIAL_FILE');
|
|
22
|
+
value = quoted[2];
|
|
23
|
+
} else value = value.replace(/\s+#.*$/, '');
|
|
24
|
+
env[match[1]] = value;
|
|
25
|
+
}
|
|
26
|
+
return env;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function loadNativeDoctorConfig({ projectRoot = process.cwd(), runtime, shellEnv = process.env }) {
|
|
30
|
+
if (!['sdk', 'mcp'].includes(runtime)) fail('INVALID_RUNTIME_OPTIONS');
|
|
31
|
+
const envPath = runtime === 'mcp' ? MCP_ENV_PATH : SDK_ENV_PATH;
|
|
32
|
+
try {
|
|
33
|
+
const files = [envPath, `${envPath}.identity.json`, `${envPath}.connect.json`, `${envPath}.connect.lock`, MCP_MIGRATION_PATH];
|
|
34
|
+
const checks = files.map(file => inspectCredentialFile(projectRoot, file));
|
|
35
|
+
if (checks.some(check => !check.safe)) fail('UNSAFE_CREDENTIALS');
|
|
36
|
+
if (checks.some(check => check.exists && /\.connect\.(json|lock)$/.test(check.relativePath))) fail('CONNECTION_RECOVERY_PENDING');
|
|
37
|
+
if (checks.at(-1).exists) fail('MCP_MIGRATION_PENDING');
|
|
38
|
+
if (checks[0].exists && statSync(path.join(projectRoot, envPath)).size > 65536) fail('INVALID_CREDENTIAL_FILE');
|
|
39
|
+
parseInstallationIdentity(readCredentialFile(projectRoot, `${envPath}.identity.json`), runtime);
|
|
40
|
+
const raw = readCredentialFile(projectRoot, envPath);
|
|
41
|
+
// Choose one complete bundle. Never borrow a missing field from another lane.
|
|
42
|
+
const source = raw === null ? shellEnv : parse(raw);
|
|
43
|
+
for (const [name, value] of Object.entries(source)) {
|
|
44
|
+
if (name.startsWith('OSUITE_') && source[name.replace(/^OSUITE_/, 'DASHCLAW_')] !== undefined
|
|
45
|
+
&& value !== source[name.replace(/^OSUITE_/, 'DASHCLAW_')]) fail('CREDENTIAL_SOURCE_CONFLICT');
|
|
46
|
+
}
|
|
47
|
+
for (const field of ['AGENT_ID', 'RUNTIME_ADAPTER_ID']) {
|
|
48
|
+
const value = source[`OSUITE_${field}`] ?? source[`DASHCLAW_${field}`];
|
|
49
|
+
if (typeof value !== 'string' || !value.trim()) fail('INVALID_CONFIGURATION');
|
|
50
|
+
}
|
|
51
|
+
if (Object.hasOwn(source, 'OSUITE_ORG_ID') || Object.hasOwn(source, 'DASHCLAW_ORG_ID')) {
|
|
52
|
+
if (!safeId(source.OSUITE_ORG_ID ?? source.DASHCLAW_ORG_ID)) fail('INVALID_CONFIGURATION');
|
|
53
|
+
}
|
|
54
|
+
const config = loadRuntimeConfig({ env: source, host: runtime, runtimeId: runtime });
|
|
55
|
+
if (config.runtimeId !== runtime || !safeId(config.agentId) || !config.apiKey || !validatedBaseUrl(config.baseUrl)
|
|
56
|
+
|| config.allowInsecureHttp || config.signatureMode !== 'required' || config.ruleRolloutCapability
|
|
57
|
+
|| (config.provider && config.provider !== runtime)) fail('INVALID_CONFIGURATION');
|
|
58
|
+
if (createPrivateKey(Buffer.from(config.privateKeyBase64, 'base64')).asymmetricKeyType !== 'rsa') fail('INVALID_CONFIGURATION');
|
|
59
|
+
return { ...config, provider: runtime };
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (/^[A-Z][A-Z0-9_]+$/.test(error?.code || '')) throw error;
|
|
62
|
+
fail('INVALID_CONFIGURATION');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function diagnoseNativeRuntime(options) {
|
|
67
|
+
const config = loadNativeDoctorConfig(options);
|
|
68
|
+
// Diagnostic-only scratch state: no reusable grant/cache is persisted or exposed.
|
|
69
|
+
const values = new Map();
|
|
70
|
+
const store = {
|
|
71
|
+
read: key => values.get(key),
|
|
72
|
+
write: (key, value) => { values.set(key, value); return value; },
|
|
73
|
+
update: (key, fn) => { const value = fn(values.get(key)); values.set(key, value); return value; },
|
|
74
|
+
};
|
|
75
|
+
const remote = await resolveRemotePosture(config, { store, api: createApiClient(config, { maxResponseBytes: 1048576 }) });
|
|
76
|
+
if (!remote.available || remote.blocked || remote.source !== 'remote') fail('CURRENT_POSTURE_UNAVAILABLE');
|
|
77
|
+
if (!['enforce', 'strict'].includes(remote.posture.mode) || !remote.posture.require_signature
|
|
78
|
+
|| remote.posture.on_guard_unavailable !== 'block' || remote.posture.require_assumption_capture
|
|
79
|
+
|| !['enforce', 'strict'].includes(config.mode) || config.guardFailureMode !== 'block') fail('NATIVE_POSTURE_INCOMPATIBLE');
|
|
80
|
+
const orgId = store.read('posture')?.document?.org_id;
|
|
81
|
+
if (!safeId(orgId)) fail('CURRENT_POSTURE_UNAVAILABLE');
|
|
82
|
+
return { runtime: options.runtime, orgId, ready: true };
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osuite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "OSuite governed action SDK for AI agents. Approve, replay, prove, and verify runtime decisions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"controlled-transfers/*.mjs",
|
|
45
45
|
"CONTROLLED_TRANSFERS.md",
|
|
46
46
|
"matoiDoctor.mjs",
|
|
47
|
+
"nativeDoctor.mjs",
|
|
47
48
|
"projectHooks.js",
|
|
48
49
|
"reviewSurface.js",
|
|
49
50
|
"osuite.js",
|