osuite 2.10.2 → 2.11.1
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/GOVERNED_TOOLS.md +210 -0
- package/README.md +52 -12
- package/cli.js +19 -3
- package/governed-tools/authority.mjs +134 -0
- package/governed-tools/contract.mjs +170 -0
- package/governed-tools/examples/native-client.mjs +47 -0
- package/governed-tools/executor.mjs +190 -0
- package/governed-tools/journal.mjs +448 -0
- package/governed-tools/mcp.mjs +95 -0
- package/governed-tools.mjs +10 -0
- package/package.json +8 -1
- package/projectHooks.js +150 -5
- package/runtime/admission.mjs +15 -8
- package/runtime/config.mjs +1 -1
- package/runtime/hook.mjs +36 -12
- package/runtime/mcp.mjs +30 -13
- package/runtime/posture.mjs +111 -26
- package/runtime/protocol.mjs +23 -3
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Native Tool Compatibility And Recovery
|
|
2
|
+
|
|
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.11.1 version` before installing. A source
|
|
5
|
+
checkout alone does not establish npm availability or server compatibility;
|
|
6
|
+
consult the verified release record before enabling it for a workspace.
|
|
7
|
+
|
|
8
|
+
`osuite/governed-tools` is ESM and requires **Node 24 on POSIX**. It uses built-in
|
|
9
|
+
SQLite; it adds no production dependency. Existing `osuite` imports, CommonJS,
|
|
10
|
+
CLI, advisory MCP tools and Hook support are unchanged. Nothing is installed or
|
|
11
|
+
activated in a host by importing it.
|
|
12
|
+
|
|
13
|
+
## What Changes In An Application
|
|
14
|
+
|
|
15
|
+
Keep your native tool name, JSON arguments, callback and successful result.
|
|
16
|
+
Configure a trusted mapping and a private journal once; give each business
|
|
17
|
+
operation a stable ID. The wrapper calls the original callback only after
|
|
18
|
+
current Studio admission. It does not ask the model to use a different tool.
|
|
19
|
+
|
|
20
|
+
Provision a new journal deliberately: construct once with
|
|
21
|
+
`initializeJournal: true`, then close it without running a tool. Normal
|
|
22
|
+
application starts use `false` (the default). A missing or uninitialized journal
|
|
23
|
+
then fails rather than quietly recreating operation history. Never leave the
|
|
24
|
+
initialization flag enabled as a restart/recovery shortcut.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { createGovernedTools } from 'osuite/governed-tools';
|
|
28
|
+
|
|
29
|
+
const tools = createGovernedTools({
|
|
30
|
+
config: {
|
|
31
|
+
baseUrl: process.env.OSUITE_BASE_URL,
|
|
32
|
+
orgId: process.env.OSUITE_ORG_ID,
|
|
33
|
+
agentId: process.env.OSUITE_AGENT_ID,
|
|
34
|
+
runtimeId: 'sdk',
|
|
35
|
+
provider: 'sdk',
|
|
36
|
+
apiKey: process.env.OSUITE_API_KEY,
|
|
37
|
+
privateKeyBase64: process.env.OSUITE_PRIVATE_KEY_BASE64,
|
|
38
|
+
mode: 'enforce',
|
|
39
|
+
signatureMode: 'required',
|
|
40
|
+
guardFailureMode: 'block',
|
|
41
|
+
},
|
|
42
|
+
namespace: 'billing-service',
|
|
43
|
+
journalPath: '/absolute/private-directory/billing.sqlite',
|
|
44
|
+
initializeJournal: false,
|
|
45
|
+
bindings: {
|
|
46
|
+
'ledger.append': {
|
|
47
|
+
revision: 'ledger-mapping-1',
|
|
48
|
+
describe: args => ({
|
|
49
|
+
action_type: 'api',
|
|
50
|
+
declared_goal: 'Append the specified billing ledger record',
|
|
51
|
+
systems_touched: ['billing-ledger'],
|
|
52
|
+
reversible: false,
|
|
53
|
+
input_summary: { target: args.target, amount: args.amount },
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const result = await tools.run(
|
|
61
|
+
job.operationId,
|
|
62
|
+
{ name: 'ledger.append', arguments: job.arguments },
|
|
63
|
+
({ arguments: args }) => ledger.append(args),
|
|
64
|
+
{ waitMs: 30000, signal: abortController.signal },
|
|
65
|
+
);
|
|
66
|
+
// The actual ledger result, not an OSuite-generated substitute.
|
|
67
|
+
consumeNativeResult(result);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error.code === 'AWAITING_APPROVAL') {
|
|
70
|
+
showExistingReview(error.status.actionId, error.status.reviewUrl);
|
|
71
|
+
// Resume this same operation later; do not create a replacement ID.
|
|
72
|
+
} else {
|
|
73
|
+
showExplicitFailure(error.code, error.status);
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
tools.close();
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The description is an application-maintained semantic mapping, **not authority**.
|
|
81
|
+
Validate it against the real tool implementation. Include the consequential
|
|
82
|
+
target, operation, destination, amount/data boundary and relevant constraints;
|
|
83
|
+
the sample is not a universal banking policy. A signature proves who supplied
|
|
84
|
+
the mapping, not that the mapping is semantically complete. Studio still owns
|
|
85
|
+
the allow/hold/deny decision. Do not put secrets in `input_summary`: that bounded
|
|
86
|
+
description is sent to Studio even though full native arguments stay local.
|
|
87
|
+
|
|
88
|
+
Use a separately enrolled SDK/MCP identity with a current signing key. A Hook
|
|
89
|
+
credential is not interchangeable with an SDK credential. The new `sdk`/`mcp`
|
|
90
|
+
posture endpoint must be deployed server-side. Older servers fail explicitly;
|
|
91
|
+
there is no unsigned, offline, observe-mode or raw-client fallback. A configured
|
|
92
|
+
mandatory scoped policy is never ignored to make this wrapper work.
|
|
93
|
+
This profile does not implement assumption-capture workflows; a posture that
|
|
94
|
+
requires them is refused rather than silently reported as satisfied. Posture
|
|
95
|
+
is current client configuration, not a resource capability or proof that every
|
|
96
|
+
unsigned request to the server is prohibited. Actual signed action responses
|
|
97
|
+
and fresh admission are checked separately.
|
|
98
|
+
|
|
99
|
+
## Connected MCP Client
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { wrapMcpClient } from 'osuite/governed-tools';
|
|
103
|
+
const governed = wrapMcpClient(alreadyConnectedMcpClient, tools);
|
|
104
|
+
const result = await governed.operation(job.operationId).callTool(
|
|
105
|
+
{ name: 'ledger.append', arguments: job.arguments },
|
|
106
|
+
nativeResultSchema,
|
|
107
|
+
{ signal: abortController.signal, timeout: 10000 },
|
|
108
|
+
);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The supplied client's receiver, schema, allowed options and original returned
|
|
112
|
+
result are preserved. Its timeout is the native call timeout, not a new approval
|
|
113
|
+
wait budget. The adapter defaults to returning a held status promptly; invoke
|
|
114
|
+
the same operation after review. `governed.status(id)` reads existing status and
|
|
115
|
+
never executes or redeems an approval.
|
|
116
|
+
|
|
117
|
+
This bounded profile supports ordinary `callTool` with explicit `name` and
|
|
118
|
+
object `arguments`, and only `signal` / `timeout` options. Names and operation
|
|
119
|
+
IDs are 1-128 ASCII identifier characters (`A-Z`, `a-z`, digits, `_`, `.`, `-`),
|
|
120
|
+
must start with an alphanumeric character or `_`, and cannot contain `..`.
|
|
121
|
+
Inputs must be lossless JSON, at most 32 KiB, depth 16 and 8,192 nodes. Unsupported
|
|
122
|
+
accessors, proxy objects and prototype-sensitive keys (`__proto__`, `prototype`,
|
|
123
|
+
`constructor`) are rejected even when a native client might accept them.
|
|
124
|
+
Unsupported
|
|
125
|
+
metadata, tasks, streams, progress callbacks and arbitrary MCP requests are
|
|
126
|
+
rejected, not silently stripped. OAuth, discovery and connection setup remain
|
|
127
|
+
with your existing MCP client. This is not a universal MCP gateway certification.
|
|
128
|
+
|
|
129
|
+
## Recovery Contract
|
|
130
|
+
|
|
131
|
+
An operation ID means one business intention, not equality of arguments or a
|
|
132
|
+
JSON-RPC request number. Persist it in your existing job record. Different IDs
|
|
133
|
+
with identical arguments remain different legitimate operations. Reusing an ID
|
|
134
|
+
with changed input or mapping is a conflict. Changing the namespace or identity
|
|
135
|
+
creates a different scope: never use that as a recovery shortcut.
|
|
136
|
+
|
|
137
|
+
| State / error | Required application behavior |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `AWAITING_APPROVAL` | Show the existing review; resume the same ID and exact input. |
|
|
140
|
+
| `ALREADY_COMPLETED` | Do not execute again. Load business output from your own store. |
|
|
141
|
+
| `OPERATION_BUSY` | Another caller owns the transition; read status, do not invent an ID. |
|
|
142
|
+
| `OUTCOME_UNKNOWN` | Inspect the resource separately; do not automatically resend. |
|
|
143
|
+
| `POLICY_DENIED` / expiry / cancellation | Respect the terminal refusal. A new intention needs explicit operator action. |
|
|
144
|
+
| `CURRENT_AUTHORITY_UNAVAILABLE` | Restore current server/identity configuration; never fall back to ungoverned execution. |
|
|
145
|
+
| `JOURNAL_MISSING` / invalid journal | Restore the correct durable journal; do not initialize an empty replacement to replay old IDs. |
|
|
146
|
+
| `ABORTED` | The local waiter stopped. This does not revoke approval or undo a dispatched effect. |
|
|
147
|
+
|
|
148
|
+
Since 2.11.1, `error.recovery` and `status.recovery` expose a bounded `nextStep`,
|
|
149
|
+
`preserveOperationId: true`, and an explanatory `message` for the UI. They contain
|
|
150
|
+
no native arguments or result payloads. Show them alongside the stable error
|
|
151
|
+
code; do not treat them as a grant, a promise of resumability, or an automatic
|
|
152
|
+
retry instruction. `retryAutomatically` remains false on errors. After an
|
|
153
|
+
unknown dispatch, `reconcile_without_resend` means inspect the resource, not
|
|
154
|
+
call the wrapper with a new ID.
|
|
155
|
+
|
|
156
|
+
Restart can resume a held review. It cannot infer that a request was not sent
|
|
157
|
+
from a timeout, missing response, crashed process, or lost completion report.
|
|
158
|
+
Only an exact server record that is still pending can repair an uncertain
|
|
159
|
+
initial creation into a held state. Redemption/dispatch fences are not reset.
|
|
160
|
+
A successful GET showing approval is not a grant to send: a fresh signed POST
|
|
161
|
+
must validate and redeem the original request.
|
|
162
|
+
|
|
163
|
+
There is no distributed transaction with an arbitrary SaaS. The journal commits
|
|
164
|
+
the dispatch fence before invoking the callback. This prevents automatic local
|
|
165
|
+
resend but can leave a request uncertain if the process dies between those two
|
|
166
|
+
steps. Third-party resource reconciliation and business idempotency remain
|
|
167
|
+
application responsibilities. A new machine must retain the same journal and
|
|
168
|
+
scope; deleting or restoring an old journal is not supported recovery.
|
|
169
|
+
|
|
170
|
+
## Results And Storage
|
|
171
|
+
|
|
172
|
+
Successful native output is returned unchanged and is **not persisted**. A later
|
|
173
|
+
duplicate cannot reconstruct it. The journal stores bounded IDs, commitments,
|
|
174
|
+
states and an optional result digest. Opaque/non-JSON native returns can have a
|
|
175
|
+
null digest; neither a return nor a digest is independent resource verification.
|
|
176
|
+
MCP `isError: true` is returned unchanged but leaves the operation uncertain,
|
|
177
|
+
since native errors can occur after partial effects. Exceptions are sanitized;
|
|
178
|
+
arbitrary error strings, credentials and full outputs are not stored.
|
|
179
|
+
|
|
180
|
+
Outcome reporting is separate. If Studio loses the reporting acknowledgement,
|
|
181
|
+
the native result remains the return value and `reportState` is `uncertain`.
|
|
182
|
+
Do not replay the tool to repair a report. `close()` prevents new work; an
|
|
183
|
+
already-started native call is allowed to record its outcome before SQLite closes.
|
|
184
|
+
|
|
185
|
+
Use an owner-only directory and a durable local filesystem. Unsafe ownership,
|
|
186
|
+
permissions, symlinks/hardlinks and invalid database paths are rejected. SQLite
|
|
187
|
+
uses transactional CAS and full durability. The default limit is 10,000 retained
|
|
188
|
+
operations; exhaustion stops new work. Normal opening never creates a missing
|
|
189
|
+
database. Explicit initialization is a provisioning action, not recovery.
|
|
190
|
+
Do not delete completed or unknown rows
|
|
191
|
+
to make room: they are replay tombstones. Plan scoped lifecycle/retention with
|
|
192
|
+
the operator, retain the WAL correctly, and never share this database over an
|
|
193
|
+
unqualified network filesystem. Windows ACL qualification is not included.
|
|
194
|
+
|
|
195
|
+
## Honest Coverage And Cost
|
|
196
|
+
|
|
197
|
+
Status reports `coverage: wrapped-call-only` and
|
|
198
|
+
`admissionPath: studio-current-action`. The raw client, alternative credentials,
|
|
199
|
+
direct resource access and a compromised application can bypass this wrapper.
|
|
200
|
+
It is not a resource-side enforcement boundary or a ZeroGate Action Pass path.
|
|
201
|
+
There is no claim that old Azure gate latency applies here. Current posture,
|
|
202
|
+
guard/action requests, durable writes and reporting all have real costs.
|
|
203
|
+
Studio responses are bounded to 1 MiB; larger responses refuse admission rather
|
|
204
|
+
than silently dropping evidence. Short configuration-cache contention can cause
|
|
205
|
+
bounded fresh configuration reads (at most six), never a repeated action POST
|
|
206
|
+
or tool invocation. A persistent cache lock is not removed automatically.
|
|
207
|
+
|
|
208
|
+
Production gateway deployment requires separate resource IAM, credentials,
|
|
209
|
+
network fencing, availability and recovery qualification. This release does not
|
|
210
|
+
enable Hook, modify the existing ZeroGate/Matoi algorithms or deploy that gateway.
|
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
# OSuite SDK (v2.
|
|
1
|
+
# OSuite SDK (v2.11.1)
|
|
2
2
|
|
|
3
3
|
**Governed action SDK for AI agents.**
|
|
4
4
|
|
|
5
5
|
The OSuite SDK helps teams route approvals, record governed decisions, and produce replayable evidence for AI agent activity.
|
|
6
6
|
|
|
7
|
+
The opt-in Node 24 `osuite/governed-tools` entry preserves native tool calls
|
|
8
|
+
and adds durable approval recovery. See [Native Tool Compatibility](GOVERNED_TOOLS.md).
|
|
9
|
+
It was introduced in 2.11.0 and does not enable Hook or a gateway.
|
|
10
|
+
|
|
7
11
|
## Installation
|
|
8
12
|
|
|
9
13
|
### Node.js
|
|
@@ -13,7 +17,7 @@ npm install osuite
|
|
|
13
17
|
|
|
14
18
|
### Connect And Verify
|
|
15
19
|
|
|
16
|
-
For
|
|
20
|
+
For a checked-out SDK source tree, run from the project you want to connect:
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
23
|
node /absolute/path/to/osuite-sdk/sdk/cli.js connect
|
|
@@ -21,11 +25,11 @@ node /absolute/path/to/osuite-sdk/sdk/cli.js doctor
|
|
|
21
25
|
node /absolute/path/to/osuite-sdk/sdk/cli.js try
|
|
22
26
|
```
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
For this version, use `npx osuite@2.11.1 connect` after confirming availability
|
|
29
|
+
with `npm view osuite@2.11.1 version`. A source checkout or this document alone
|
|
30
|
+
does not establish registry publication, and npm's `latest` may differ from the
|
|
31
|
+
checked-out version. The stable credential-recovery behavior and the new
|
|
32
|
+
native-call operation journal are different mechanisms.
|
|
29
33
|
|
|
30
34
|
The alternative installer follows npm's published `latest`:
|
|
31
35
|
|
|
@@ -40,7 +44,7 @@ credential paths are refused. The client durably saves a recovery journal before
|
|
|
40
44
|
acknowledging a replacement, so reconnect does not revoke the old key before the
|
|
41
45
|
new credential can be recovered. Historical exposure still requires key rotation.
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
Since 2.10.1, new hook installations need Node.js 18 or newer and Git for repository
|
|
44
48
|
safety checks. Python is not required for the packaged Node hooks or MCP bridge.
|
|
45
49
|
Existing Python installations remain legacy until explicitly migrated. Custom
|
|
46
50
|
registrations and intentionally disabled hooks are preserved, not silently
|
|
@@ -59,9 +63,45 @@ acknowledgement only after an eligible human approves and the server freshly
|
|
|
59
63
|
redeems that exact grant. A missing, denied or unconfirmed grant does not execute.
|
|
60
64
|
Slack and email notifications require configured workspace channels.
|
|
61
65
|
|
|
66
|
+
## Failure Handling In 2.11.1
|
|
67
|
+
|
|
68
|
+
The Hook's local guard-failure default is now `block`, including non-strict
|
|
69
|
+
profiles. Invalid or oversized input, malformed responses, signing failures,
|
|
70
|
+
redirects and request/authentication rejections are not availability fallbacks.
|
|
71
|
+
An explicit non-strict `GUARD_FAILURE_MODE=allow` (or a verified administrator
|
|
72
|
+
posture) can permit an **ungoverned** action only for a classified transport
|
|
73
|
+
failure or HTTP 500/502/503/504. Strict and scoped mandatory profiles never use
|
|
74
|
+
that fallback. An outage allowance is not an approval or an admission receipt.
|
|
75
|
+
|
|
76
|
+
Current posture rejection is retained in the local authenticated cache. A late
|
|
77
|
+
response that started before the rejection cannot clear it; a fresh valid
|
|
78
|
+
server response is required. An independent rejection marker survives contention
|
|
79
|
+
on the configuration cache lock. Authentication/revocation/conflict errors in
|
|
80
|
+
guard, admission and approval reads also invalidate cached posture. Preserve the private state directory: deleting
|
|
81
|
+
or restoring old state is not a supported recovery path.
|
|
82
|
+
|
|
83
|
+
The native-tool wrapper has no offline fallback. Its errors and status now
|
|
84
|
+
include `recovery.nextStep` and `recovery.message`. These are presentation hints,
|
|
85
|
+
not authority to execute or resend. Keep the same operation ID after a held
|
|
86
|
+
review, and reconcile uncertain outcomes with the resource without replaying
|
|
87
|
+
the write. Successful native results remain unchanged.
|
|
88
|
+
|
|
89
|
+
A Hook returning an explicit refusal and a host losing the Hook process are
|
|
90
|
+
different cases. A host may continue after a callback crash, unsupported output
|
|
91
|
+
or host-enforced timeout. This patch hardens OSuite's handled error paths; it
|
|
92
|
+
does not change vendor host behavior or make endpoint Hooks unbypassable. Use
|
|
93
|
+
mandatory resource-side enforcement where that guarantee is required.
|
|
94
|
+
|
|
95
|
+
New Claude Code pre-tool registrations include `onFailure: block`, supported
|
|
96
|
+
by Claude Code 2.1.295 and later and tested on 2.1.300. Existing custom or disabled
|
|
97
|
+
registrations are preserved; `doctor` warns when the failure policy is absent.
|
|
98
|
+
That setting is not a guarantee for older Claude versions or other hosts.
|
|
99
|
+
|
|
62
100
|
## The Governance Loop
|
|
63
101
|
|
|
64
|
-
The SDK transports requests; it does not execute your tool.
|
|
102
|
+
The default SDK transports requests; it does not execute your tool. The opt-in
|
|
103
|
+
native-tool wrapper invokes only the callback explicitly supplied to it.
|
|
104
|
+
A guard evaluation or
|
|
65
105
|
`waitForApproval()` result is not execution authorization on its own. A secure
|
|
66
106
|
integration must preserve all four steps:
|
|
67
107
|
|
|
@@ -535,7 +575,7 @@ identity; use an explicit new `--agent-id` if retaining the old project director
|
|
|
535
575
|
Preserve historical records and signing keys instead of reassigning past actions
|
|
536
576
|
to the replacement. A client-side installation ID is not permission to rotate.
|
|
537
577
|
|
|
538
|
-
### SDK and MCP Credential Separation (2.10.2
|
|
578
|
+
### SDK and MCP Credential Separation (Since 2.10.2)
|
|
539
579
|
|
|
540
580
|
SDK connections use `.osuite/.env`; MCP connections use `.osuite/mcp/.env`.
|
|
541
581
|
Their installation metadata and recovery journals live beside their respective
|
|
@@ -559,8 +599,8 @@ rather than deleting its marker or copying credentials. Update the MCP launcher'
|
|
|
559
599
|
credential-file reference to `.osuite/mcp/.env` before restarting it or creating an
|
|
560
600
|
SDK connection. The command does not rewrite vendor launchers or enable hooks.
|
|
561
601
|
|
|
562
|
-
|
|
563
|
-
|
|
602
|
+
Use version 2.10.2 or newer for this credential migration. It does not install or
|
|
603
|
+
activate the separate native-tool execution wrapper.
|
|
564
604
|
|
|
565
605
|
`doctor` separates hook configuration, project enablement, credentials, connectivity, telemetry, and an enforced policy outcome. Observation-only mode, an unavailable guard (whether fail-open or fail-closed), or telemetry without a matching policy outcome does not pass the governance check. Hook warnings are printed even when the probe otherwise succeeds. The probe never executes its sample tool command and does not prove the host loaded the hooks: start or restart the runtime and verify its actual hook invocation separately.
|
|
566
606
|
|
package/cli.js
CHANGED
|
@@ -695,11 +695,19 @@ function writeCheckLine(status, label, detail) {
|
|
|
695
695
|
|
|
696
696
|
// A telemetry-only result must never count as successful governance.
|
|
697
697
|
async function verifyProjectHooks(runtimes) {
|
|
698
|
-
const installations = findHookInstallations(process.cwd(), runtimes);
|
|
698
|
+
const installations = findHookInstallations(process.cwd(), runtimes, { diagnose: true });
|
|
699
699
|
const checks = [];
|
|
700
700
|
for (const installation of installations) {
|
|
701
|
+
const { diagnostics } = installation;
|
|
702
|
+
writeCheckLine(diagnostics.status === 'current' ? 'ok' : 'warn', 'Hook freshness', `${installation.label}: ${diagnostics.status === 'current'
|
|
703
|
+
? 'managed Node runtime and launcher bytes match this CLI; not a registry/latest-version or native-host verification'
|
|
704
|
+
: 'Not verified against this CLI\'s packaged Node runtime; probe success cannot establish installation freshness'}`);
|
|
705
|
+
diagnostics.warnings.forEach(warning => writeCheckLine('warn', 'Install warning', `${installation.label}: ${warning}`));
|
|
706
|
+
if (diagnostics.status !== 'current') {
|
|
707
|
+
writeCheckLine('warn', 'Install next step', `Upgrade the OSuite CLI, then run osuite connect ${installation.runtime}; review preserved custom differences before replacing files. Disabled hooks remain disabled.`);
|
|
708
|
+
}
|
|
701
709
|
const check = await runHookCheck({ projectRoot: process.cwd(), installation, shellEnv: SHELL_ENV });
|
|
702
|
-
check.steps.forEach((step) => writeCheckLine(step.ok ? 'ok' : 'fail', step.label, `${installation.label}: ${step.detail}`));
|
|
710
|
+
check.steps.forEach((step) => writeCheckLine(step.ok ? 'ok' : step.warning ? 'warn' : 'fail', step.label, `${installation.label}: ${step.detail}`));
|
|
703
711
|
(check.warnings || []).forEach((warning) => writeCheckLine('warn', 'Hook warning', `${installation.label}: ${warning}`));
|
|
704
712
|
checks.push({ installation, ...check });
|
|
705
713
|
}
|
|
@@ -1181,6 +1189,7 @@ async function doctor() {
|
|
|
1181
1189
|
|
|
1182
1190
|
write(c('OSuite Doctor', `${ANSI.bold}${ANSI.cyan}`));
|
|
1183
1191
|
write(c('Checking the local developer entry point.', ANSI.dim));
|
|
1192
|
+
write(c('Project diagnosis does not enumerate system-managed, plugin, or global hook copies.', ANSI.dim));
|
|
1184
1193
|
write('');
|
|
1185
1194
|
|
|
1186
1195
|
const credentialChecks = [...CLI_CREDENTIAL_PATHS.flatMap((file) => [file, `${file}.identity.json`, `${file}.connect.json`, `${file}.connect.lock`]), MCP_MIGRATION_PATH, '.env']
|
|
@@ -1246,7 +1255,13 @@ async function doctor() {
|
|
|
1246
1255
|
write(' export OSUITE_API_KEY=<workspace-api-key>');
|
|
1247
1256
|
}
|
|
1248
1257
|
hookChecks.filter((check) => !check.ok).forEach((check) => {
|
|
1249
|
-
|
|
1258
|
+
if (!check.installation.hostEnabled) {
|
|
1259
|
+
write(` ${check.installation.label} hooks remain disabled by project settings; doctor did not enable or reinstall anything.`);
|
|
1260
|
+
} else if (check.installation.diagnostics.canProbe === false && !check.installation.problems.length) {
|
|
1261
|
+
write(` ${check.installation.label} direct hook probe is not verified. Review the WARN lines above, then run osuite doctor again.`);
|
|
1262
|
+
} else {
|
|
1263
|
+
write(` ${check.installation.label} is not governed yet. Fix the FAIL line above, then run osuite doctor again.`);
|
|
1264
|
+
}
|
|
1250
1265
|
});
|
|
1251
1266
|
process.exitCode = 1;
|
|
1252
1267
|
return false;
|
|
@@ -1255,6 +1270,7 @@ async function doctor() {
|
|
|
1255
1270
|
write(c('Your OSuite CLI is ready.', ANSI.green));
|
|
1256
1271
|
hookChecks.forEach((check) => {
|
|
1257
1272
|
write(` ${check.installation.label} direct hook probe was governed and reached OSuite; verify host invocation after starting the runtime.`);
|
|
1273
|
+
if (check.installation.diagnostics.status !== 'current') write(` ${check.installation.label} installation freshness remains not verified; the probe does not certify a current Node installation.`);
|
|
1258
1274
|
});
|
|
1259
1275
|
return true;
|
|
1260
1276
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { canonicalJson, createApiClient } from '../runtime/protocol.mjs';
|
|
4
|
+
import { resolveRemotePosture } from '../runtime/posture.mjs';
|
|
5
|
+
import { createStateStore } from '../runtime/state.mjs';
|
|
6
|
+
import { admitAction, actionAdmission, cavaFingerprint } from '../runtime/admission.mjs';
|
|
7
|
+
import { matchesStoredAction, reject } from './contract.mjs';
|
|
8
|
+
|
|
9
|
+
export function createStudioAuthority(config, journalPath) {
|
|
10
|
+
const responseLimits = { maxResponseBytes: 1048576 };
|
|
11
|
+
const baseApi = createApiClient(config, responseLimits);
|
|
12
|
+
const store = createStateStore({ ...config, stateDir: path.join(path.dirname(journalPath), 'posture') });
|
|
13
|
+
|
|
14
|
+
async function current(aborted) {
|
|
15
|
+
let remote;
|
|
16
|
+
const deadline = performance.now() + 2000;
|
|
17
|
+
for (let attempt = 0; attempt < 6; attempt++) {
|
|
18
|
+
if (aborted()) reject('ABORTED');
|
|
19
|
+
let readStatus = null;
|
|
20
|
+
remote = await resolveRemotePosture(config, { store, api: { async request(method, endpoint, ...args) {
|
|
21
|
+
const response = await baseApi.request(method, endpoint, ...args);
|
|
22
|
+
if (method === 'GET') readStatus = response.status;
|
|
23
|
+
return response;
|
|
24
|
+
} } });
|
|
25
|
+
if (remote.source === 'remote' || readStatus !== 200 || attempt === 5 || performance.now() >= deadline) break;
|
|
26
|
+
// A concurrent cache writer can supersede a valid response or hold its
|
|
27
|
+
// short lock. Reread current configuration, never replay an action POST.
|
|
28
|
+
await delay(10 * (attempt + 1));
|
|
29
|
+
}
|
|
30
|
+
const pinned = config.ruleRollout, actual = remote.ruleRollout;
|
|
31
|
+
const preservesConfiguredFloor = !pinned?.enabled || (actual?.enabled === true
|
|
32
|
+
&& canonicalJson(actual.scope) === canonicalJson(pinned.scope)
|
|
33
|
+
&& actual.credential_id === pinned.credential_id
|
|
34
|
+
&& actual.connection_generation >= pinned.connection_generation && actual.version >= pinned.version
|
|
35
|
+
&& (actual.version !== pinned.version || canonicalJson(actual) === canonicalJson(pinned)));
|
|
36
|
+
if (!remote.available || remote.blocked || remote.source !== 'remote'
|
|
37
|
+
|| !preservesConfiguredFloor
|
|
38
|
+
|| !['enforce', 'strict'].includes(remote.posture.mode)
|
|
39
|
+
|| remote.posture.require_assumption_capture !== false
|
|
40
|
+
|| remote.posture.require_signature !== true || remote.posture.on_guard_unavailable !== 'block') {
|
|
41
|
+
reject('CURRENT_AUTHORITY_UNAVAILABLE');
|
|
42
|
+
}
|
|
43
|
+
const effective = { ...config, mode: remote.posture.mode, guardFailureMode: 'block', signatureMode: 'required',
|
|
44
|
+
approvalWaitMs: 0, ruleRollout: remote.ruleRollout };
|
|
45
|
+
return { api: createApiClient(effective, responseLimits), effective };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function read(record) {
|
|
49
|
+
const response = await baseApi.request('GET', `/api/actions/${encodeURIComponent(record.actionId)}`);
|
|
50
|
+
if (!response.ok) return { available: false, status: response.status };
|
|
51
|
+
if (!matchesStoredAction(response.body, record, config)) return { available: false, status: response.status, mismatch: true };
|
|
52
|
+
return { available: true, body: response.body, action: response.body.action || response.body };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function admit(invocation, journal, owner, aborted) {
|
|
56
|
+
const record = journal.get(invocation.record.scope, invocation.record.operationId);
|
|
57
|
+
const phase = record.state === 'held' ? 'redeeming' : 'requesting';
|
|
58
|
+
const { api, effective } = await current(aborted);
|
|
59
|
+
if (aborted()) reject('ABORTED');
|
|
60
|
+
const session = await api.request('POST', '/api/runtime-sessions', {
|
|
61
|
+
runtime_session_id: record.sessionId, agent_id: config.agentId, runtime_adapter_id: config.runtimeId,
|
|
62
|
+
runtime_family: 'sdk_tool_runtime', adapter_mode: 'sdk_wrapper', client_name: 'osuite/governed-tools',
|
|
63
|
+
governance_posture: effective.mode, signature_mode: 'required', status: 'active',
|
|
64
|
+
});
|
|
65
|
+
const actualSession = session.body?.session || session.body?.runtime_session;
|
|
66
|
+
if (!session.ok || actualSession?.runtime_session_id !== record.sessionId
|
|
67
|
+
|| actualSession?.org_id !== config.orgId || actualSession?.agent_id !== config.agentId
|
|
68
|
+
|| actualSession?.runtime_adapter_id !== config.runtimeId) reject('CURRENT_AUTHORITY_UNAVAILABLE');
|
|
69
|
+
let claimed = false, receivedAt = null;
|
|
70
|
+
const claim = () => {
|
|
71
|
+
if (claimed) reject('OUTCOME_UNKNOWN');
|
|
72
|
+
if (aborted()) reject('ABORTED');
|
|
73
|
+
if (!journal.claim(record.scope, record.operationId, [record.state], phase, owner)) reject('OPERATION_BUSY');
|
|
74
|
+
claimed = true;
|
|
75
|
+
};
|
|
76
|
+
const settle = (state, patch = {}) => journal.settle(record.scope, record.operationId, owner, phase, state, patch);
|
|
77
|
+
try {
|
|
78
|
+
const result = await admitAction(invocation.context, {
|
|
79
|
+
config: effective,
|
|
80
|
+
api: { async request(method, endpoint, body, options) {
|
|
81
|
+
if (aborted()) reject('ABORTED');
|
|
82
|
+
if (method === 'POST' && endpoint === '/api/actions') claim();
|
|
83
|
+
const response = await api.request(method, endpoint, body, options);
|
|
84
|
+
if (method === 'POST' && endpoint === '/api/actions') {
|
|
85
|
+
receivedAt = performance.now();
|
|
86
|
+
if (!response.ok || !matchesStoredAction(response.body, record, config)
|
|
87
|
+
|| !cavaFingerprint(response.body)) {
|
|
88
|
+
settle(phase === 'redeeming' ? 'uncertain_redemption' : 'uncertain_request');
|
|
89
|
+
reject('OUTCOME_UNKNOWN');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return response;
|
|
93
|
+
} },
|
|
94
|
+
beforeRelease: async payload => {
|
|
95
|
+
if (aborted() || !matchesStoredAction(payload, record, config)) return false;
|
|
96
|
+
// A held operation must redeem its original one-use grant, even when
|
|
97
|
+
// a current guard decision has become less restrictive meanwhile.
|
|
98
|
+
return phase !== 'redeeming' || (Boolean(record.fingerprint) && actionAdmission(payload, 'require_approval', invocation.context,
|
|
99
|
+
{ actionId: record.actionId, fingerprint: record.fingerprint }).authorized);
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
if (result.authorized) return { phase, receivedAt, response: result.response };
|
|
103
|
+
if (result.reason === 'policy_block') {
|
|
104
|
+
if (!claimed) claim();
|
|
105
|
+
settle('denied'); reject('POLICY_DENIED');
|
|
106
|
+
}
|
|
107
|
+
if (result.decision === 'require_approval' && result.response?.action?.status === 'pending_approval') {
|
|
108
|
+
if (!settle('held', { fingerprint: cavaFingerprint(result.response) })) reject('OUTCOME_UNKNOWN');
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
if (claimed) settle(phase === 'redeeming' ? 'uncertain_redemption' : 'uncertain_request');
|
|
112
|
+
reject(claimed ? 'OUTCOME_UNKNOWN' : 'CURRENT_AUTHORITY_UNAVAILABLE');
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (claimed) settle(phase === 'redeeming' ? 'uncertain_redemption' : 'uncertain_request');
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function report(record, state, resultDigest) {
|
|
120
|
+
const response = await baseApi.request('PATCH', `/api/actions/${encodeURIComponent(record.actionId)}`, {
|
|
121
|
+
status: state === 'completed' ? 'completed' : 'failed',
|
|
122
|
+
timestamp_end: new Date().toISOString(),
|
|
123
|
+
output_summary: JSON.stringify({ schema_version: 'osuite.native_tool_observation.v1',
|
|
124
|
+
observation: state === 'completed' ? 'native_return' : 'outcome_unknown',
|
|
125
|
+
result_digest: resultDigest, result_retained: false, independent_resource_verification: false }),
|
|
126
|
+
...(state === 'uncertain' ? { error_message: 'Native call outcome is uncertain; no automatic resend.' } : {}),
|
|
127
|
+
});
|
|
128
|
+
return response.ok && matchesStoredAction(response.body, record, config)
|
|
129
|
+
&& response.body.action?.status === (state === 'completed' ? 'completed' : 'failed')
|
|
130
|
+
&& typeof response.body.action?.timestamp_end === 'string';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return { admit, read, report };
|
|
134
|
+
}
|