osuite 2.10.0 → 2.10.2

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.10.0)
1
+ # OSuite SDK (v2.10.2 Release Candidate)
2
2
 
3
3
  **Governed action SDK for AI agents.**
4
4
 
@@ -11,88 +11,73 @@ The OSuite SDK helps teams route approvals, record governed decisions, and produ
11
11
  npm install osuite
12
12
  ```
13
13
 
14
- ### One-command runtime connect
15
- ```bash
16
- curl -fsSL https://studio.osuite.ai/install.sh | bash
17
- ```
18
-
19
- The installer detects Codex, Claude Code, SDK, or MCP-style projects, opens a browser handoff, and writes the approved runtime environment into the project (`.codex/.env`, `.claude/.env`, or `.osuite/.env`). API keys remain available as a fallback, but the normal path is terminal start -> Studio approval -> terminal auto-finish.
14
+ ### Connect And Verify
20
15
 
21
- It needs Node.js 18 or newer, and Python 3.8 or newer for the Codex and Claude Code hooks (the SDK and MCP lanes do not need Python). It checks both first and says how to install what is missing. When the global npm folder is not writable, it installs the CLI into `~/.osuite/npm` instead of asking for `sudo`.
16
+ For the checked-out 2.10.2 candidate source, run from the project you want to connect:
22
17
 
23
- ### Python
24
18
  ```bash
25
- pip install requests
19
+ node /absolute/path/to/osuite-sdk/sdk/cli.js connect
20
+ node /absolute/path/to/osuite-sdk/sdk/cli.js doctor
21
+ node /absolute/path/to/osuite-sdk/sdk/cli.js try
26
22
  ```
27
23
 
28
- ## The Governance Loop
24
+ After the owner publishes 2.10.2 to npm, the equivalent pinned command is
25
+ `npx osuite@2.10.2 connect`. A source release does not mean that npm's `latest`
26
+ already contains it. Check `npm view osuite version` before relying on the new
27
+ installation-identity or acknowledged-recovery behavior. npm's latest was 2.10.1
28
+ when checked on 2026-10-22; this checkout is not a registry publication.
29
29
 
30
- OSuite v2 is designed around a single 4-step loop.
30
+ The alternative installer follows npm's published `latest`:
31
31
 
32
- ### Node.js
33
- ```javascript
34
- import { OSuite } from 'osuite';
32
+ ```bash
33
+ curl -fsSL https://studio.osuite.ai/install.sh | bash
34
+ ```
35
35
 
36
- const osuite = new OSuite({
37
- baseUrl: process.env.OSUITE_BASE_URL,
38
- apiKey: process.env.OSUITE_API_KEY,
39
- agentId: 'my-agent'
40
- });
36
+ The CLI detects Codex, Claude Code, Cursor, SDK, or MCP-style projects, opens a browser
37
+ handoff, and safely stores the approved runtime environment. Credential files
38
+ are owner-only on POSIX and explicitly ignored by Git. Tracked or symlinked
39
+ credential paths are refused. The client durably saves a recovery journal before
40
+ acknowledging a replacement, so reconnect does not revoke the old key before the
41
+ new credential can be recovered. Historical exposure still requires key rotation.
42
+
43
+ New 2.10.1 hook installations need Node.js 18 or newer and Git for repository
44
+ safety checks. Python is not required for the packaged Node hooks or MCP bridge.
45
+ Existing Python installations remain legacy until explicitly migrated. Custom
46
+ registrations and intentionally disabled hooks are preserved, not silently
47
+ re-enabled. `doctor` reports a direct hook probe; it is not proof that every host
48
+ tool or alternative resource path is governed. Windows file ACL and live vendor
49
+ host qualification are separate from POSIX tests.
50
+
51
+ Select `osuite connect cursor` explicitly when a project contains multiple host
52
+ configurations. Cursor uses its native flat hook protocol, not Claude's hook
53
+ response schema. It starts in observation mode; switch the agent posture in
54
+ Studio before relying on interception. Node 18.20.8 is the oldest tested runtime;
55
+ use a supported Node LTS release, preferably Node 24, for new installations.
56
+
57
+ `osuite try` opens one harmless, synthetic review. It prints one fixed local
58
+ acknowledgement only after an eligible human approves and the server freshly
59
+ redeems that exact grant. A missing, denied or unconfirmed grant does not execute.
60
+ Slack and email notifications require configured workspace channels.
41
61
 
42
- // 1. Ask permission
43
- const res = await osuite.guard({ action_type: 'deploy' });
62
+ ## The Governance Loop
44
63
 
45
- // 2. Log intent
46
- const { action_id } = await osuite.createAction({ action_type: 'deploy' });
64
+ The SDK transports requests; it does not execute your tool. A guard evaluation or
65
+ `waitForApproval()` result is not execution authorization on its own. A secure
66
+ integration must preserve all four steps:
47
67
 
48
- // 3. Log evidence
49
- await osuite.recordAssumption({ action_id, assumption: 'Tests passed' });
68
+ 1. Describe and sign the exact proposed action, including its target and effects.
69
+ 2. Stop on a refusal or hold; an agent credential cannot approve its own request.
70
+ 3. Immediately before dispatch, re-evaluate and redeem the same action through
71
+ the admission path. Check exact identity, current scope, expiry and receipt;
72
+ do not execute merely because a log exists or a prior GET showed approval.
73
+ 4. Execute once, then report the actual result. A timeout after dispatch is an
74
+ unknown outcome, not permission to resend the write. Reconcile it separately.
50
75
 
51
- // 4. Update result
52
- await osuite.updateOutcome(action_id, { status: 'completed' });
53
- ```
54
-
55
- ### Python
56
- ```python
57
- import os
58
- import requests
59
-
60
- base_url = os.environ["OSUITE_BASE_URL"].rstrip("/")
61
- api_key = os.environ["OSUITE_API_KEY"]
62
- headers = {
63
- "content-type": "application/json",
64
- "x-api-key": api_key,
65
- }
66
-
67
- # 1. Ask permission
68
- res = requests.post(
69
- f"{base_url}/api/guard",
70
- headers=headers,
71
- json={"agent_id": "my-agent", "action_type": "deploy"},
72
- ).json()
73
-
74
- # 2. Log intent
75
- action = requests.post(
76
- f"{base_url}/api/actions",
77
- headers=headers,
78
- json={"agent_id": "my-agent", "action_type": "deploy"},
79
- ).json()
80
- action_id = action["action_id"]
81
-
82
- # 3. Log evidence
83
- requests.post(
84
- f"{base_url}/api/assumptions",
85
- headers=headers,
86
- json={"action_id": action_id, "assumption": "Tests passed"},
87
- )
88
-
89
- # 4. Update result
90
- requests.patch(
91
- f"{base_url}/api/actions/{action_id}",
92
- headers=headers,
93
- json={"status": "completed"},
94
- )
95
- ```
76
+ The packaged Node hooks implement this ordering for their documented runtime
77
+ profiles. `tryFlow.js` is the deliberately constrained walkthrough, not an
78
+ arbitrary side-effect executor. See `runtime/admission.mjs` and its independent
79
+ tests before implementing another host integration. A cooperative endpoint
80
+ hook is not a replacement for downstream IAM or mandatory resource mediation.
96
81
 
97
82
  ---
98
83
 
@@ -106,7 +91,7 @@ The v2 SDK exposes the core governance loop plus first-class PCAA, replay, proof
106
91
  - `updateOutcome(id, outcome)` -- Result recording ("X finished with Y")
107
92
  - `recordAssumption(assumption)` -- Integrity tracking ("I believe Z while doing X")
108
93
  - `waitForApproval(id)` -- Polling helper for human-in-the-loop approvals
109
- - `approveAction(id, decision, reasoning?)` -- Submit approval decisions from code
94
+ - `approveAction(id, decision, reasoning?)` -- Transport an approval request; default SaaS policy requires an eligible signed-in person and rejects agent-key self-approval.
110
95
  - `getPendingApprovals()` -- List actions awaiting human review
111
96
 
112
97
  ### Decision Integrity
@@ -508,6 +493,7 @@ npm install -g osuite
508
493
  osuite # branded welcome and command map
509
494
  osuite connect auto # detect the current project and start browser handoff
510
495
  osuite doctor # check env, Studio health, runtime, and signature posture
496
+ osuite try # review a fixed local acknowledgement (CLI 2.10.1+)
511
497
  osuite status # show the current Studio connection
512
498
  osuite init codex # install .codex hook files into the current project
513
499
  osuite init claude # install .claude hook files into the current project
@@ -522,19 +508,65 @@ osuite approve <actionId> # approve from the CLI where the workspace allows
522
508
  osuite deny <actionId> # deny a specific action
523
509
  ```
524
510
 
525
- For local CLI agents, `osuite connect auto` opens the browser handoff in your browser (or prints the link with `--no-browser`, in CI, over SSH, or without a terminal), waits as long as the one-time code is valid (about 10 minutes), and installs the project hook lane when it can detect Codex or Claude Code. If browser handoff is unavailable, copy `.codex/.env.example` or `.claude/.env.example` to `.env`, fill `OSUITE_API_KEY`, and run the agent from the same project root. The CLI is intentionally more than an API wrapper:
511
+ For local CLI agents, `osuite connect auto` opens the browser handoff in your browser (or prints the link with `--no-browser`, in CI, over SSH, or without a terminal), waits as long as the one-time code is valid (about 10 minutes), and installs the project hook lane when it can detect Codex or Claude Code. If browser handoff is unavailable, use your runtime secret manager or an owner-only, untracked and explicitly ignored project environment file. Do not commit credentials or put them into a broadly readable file. The CLI is intentionally more than an API wrapper:
526
512
  - `doctor` tells a developer what is missing before they connect an agent.
513
+ - `try` waits for explicit approval of a synthetic action, prints one fixed local acknowledgement, and records its outcome. It never executes a supplied command or calls an external tool. A stricter workspace denial remains a denial. Missing, denied, expired or ambiguous approval produces no acknowledgement; an uncertain outcome is not retried automatically. Slack/email notifications require workspace configuration.
527
514
  - `explain` gives a local CAVA preview before a command reaches OSuite.
528
515
  - `adapters` explains the three Runtime Coverage tiers: reference adapters, managed OSuite adapters, and enterprise custom adapters.
529
516
  - `adapter init/test` lets an enterprise team map a private runtime event into a CAVA-ready action object before registering it in Studio.
530
517
  - `approvals` provides a readable approval inbox instead of raw JSON.
531
518
  - `review` renders a PCAA/CAVA/Decision V2 review card with action understanding, evidence confidence, control posture, and score dimensions when present.
532
519
 
533
- Project installation refuses settings, credentials, or hook paths whose symlinks resolve outside the project's real root, including linked parent directories. Existing settings are merged; `disableAllHooks: true` and explicit Codex hook-disable flags stay disabled even with `--force`. Disabled setup is reported as not ready, not as a successful connection.
520
+ Project installation refuses settings or hook paths whose symlinks resolve outside the project's real root, including linked parent directories. Credential storage also refuses any symlink, hardlink or Git-tracked destination; successful POSIX writes use mode `0600` and exact ignore entries. A browser approval alone does not retire the previous runtime credential: the versioned connection protocol waits for durable local storage and acknowledgement. If interrupted, resume the same `osuite connect` command rather than deleting its recovery journal. Manual API keys and other runtime connections are not replaced. Existing settings are merged; `disableAllHooks: true` and explicit Codex hook-disable flags stay disabled even with `--force`. Disabled setup is reported as not ready, not as a successful connection.
521
+
522
+ Fresh project/runtime installations now keep two separate random identifiers in
523
+ an ignored, protected `.env.identity.json` beside the runtime's credential file:
524
+ an installation identifier and the default agent identifier. Neither identifies
525
+ a person or attests hardware. Different project/runtime installations on the same
526
+ computer remain different installations, not additional licensed developers.
527
+ Do not copy identity/credential files between devices. Existing configured agent
528
+ identifiers and interrupted connection journals are preserved.
529
+
530
+ Replacing an existing connection requires its current credential, including when
531
+ only one legacy connection has that name. An omitted, incorrect or revoked key
532
+ cannot implicitly reclaim the identity. If a device/credential is lost, an
533
+ authorized administrator retires that connection and approves a new unique
534
+ identity; use an explicit new `--agent-id` if retaining the old project directory.
535
+ Preserve historical records and signing keys instead of reassigning past actions
536
+ to the replacement. A client-side installation ID is not permission to rotate.
537
+
538
+ ### SDK and MCP Credential Separation (2.10.2 Candidate)
539
+
540
+ SDK connections use `.osuite/.env`; MCP connections use `.osuite/mcp/.env`.
541
+ Their installation metadata and recovery journals live beside their respective
542
+ credential files. Connecting one runtime does not borrow another runtime's key
543
+ from a merged project configuration. If an interrupted journal conflicts with
544
+ the current credential bundle, the CLI stops before storage or acknowledgement;
545
+ inspect the current connection instead of deleting the journal to force a retry.
546
+
547
+ For an older MCP installation stored at the SDK path, stop that local MCP client
548
+ and run this explicit, local-only migration from its project directory:
549
+
550
+ ```sh
551
+ osuite connect mcp --migrate-legacy
552
+ ```
553
+
554
+ This moves the verified MCP bundle, including any identity and recovery state,
555
+ without issuing a key, contacting Studio, or acknowledging an enrollment. It
556
+ refuses ambiguous runtime ownership or an occupied destination. An interrupted
557
+ move leaves a durable marker; inspect the files and rerun the same migration,
558
+ rather than deleting its marker or copying credentials. Update the MCP launcher's
559
+ credential-file reference to `.osuite/mcp/.env` before restarting it or creating an
560
+ SDK connection. The command does not rewrite vendor launchers or enable hooks.
561
+
562
+ This section describes the unpublished 2.10.2 candidate. Do not use a previous
563
+ published CLI version to perform the new migration.
534
564
 
535
565
  `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.
536
566
 
537
- When an agent calls `waitForApproval()`, it prints the action ID and replay link to stdout. Approve from any terminal or the dashboard, and the agent unblocks instantly.
567
+ Onboarding diagnostics are opt-in: `OSUITE_ONBOARDING_METRICS=1 osuite doctor` reports only the first diagnostic pass/fail result and, when supplied by the installer, its start timestamp. It sends no command text, filesystem paths or diagnostic log. Reconnection or a later passing check does not erase the first failure. Without the opt-in, no diagnostic measurement is sent. Reporting failure never changes the doctor result. Aggregate dashboards distinguish reported samples from all connected agents.
568
+
569
+ When an agent calls `waitForApproval()`, it prints the action ID and replay link to stdout. Approval is rechecked on the next poll; dashboard access and approval authority are still required. An approval does not override a later policy denial or revocation.
538
570
 
539
571
  ### Runtime Coverage tiers
540
572
 
@@ -0,0 +1,116 @@
1
+ import crypto from 'node:crypto';
2
+ import { acquireCredentialLock, readCredentialFile, writeCredentialFile } from './credentials.js';
3
+
4
+ const digest = (value) => crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex');
5
+ const isDigest = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
6
+ const isTime = (value) => typeof value === 'string' && Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
7
+
8
+ function readJournal(cwd, file) {
9
+ const stored = readCredentialFile(cwd, file);
10
+ if (stored === null) return { version: 2, attempts: [] };
11
+ const journal = JSON.parse(stored);
12
+ const credentials = new Set();
13
+ if (journal?.version !== 2 || !Array.isArray(journal.attempts) || journal.attempts.length > 128) throw new Error('Invalid measurement journal');
14
+ for (const attempt of journal.attempts) {
15
+ if (!attempt || !isDigest(attempt.credential) || credentials.has(attempt.credential)
16
+ || !(attempt.scope === null || isDigest(attempt.scope))
17
+ || !['started', 'finished'].includes(attempt.state) || typeof attempt.reported !== 'boolean'
18
+ || (attempt.state === 'finished' && typeof attempt.passed !== 'boolean')
19
+ || (attempt.reported && (attempt.state !== 'finished' || !attempt.scope))
20
+ || (attempt.install_started_at !== undefined && !isTime(attempt.install_started_at))) throw new Error('Invalid measurement attempt');
21
+ credentials.add(attempt.credential);
22
+ }
23
+ return journal;
24
+ }
25
+
26
+ // Opt-in only. Reconnection and a later successful doctor must not erase a first failure.
27
+ export async function runDoctorWithMeasurement(run, {
28
+ config, cwd = process.cwd(), env = process.env, fetchImpl = fetch,
29
+ emit = () => {},
30
+ } = {}) {
31
+ if (env.OSUITE_ONBOARDING_METRICS !== '1') return run();
32
+ emit('Opt-in diagnostics: only the first pass/fail result and optional installer timestamp are reported; no commands or local paths.');
33
+ let journal; let file; let attempt; let baseUrl; let apiKey; let agentId; let release; let first = false;
34
+ const unlock = () => { try { release?.(); } catch { /* Measurement cleanup must not change the doctor's result. */ } };
35
+ const save = () => writeCredentialFile(cwd, file, `${JSON.stringify(journal)}\n`);
36
+ try {
37
+ const url = new URL(config?.baseUrl);
38
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash
39
+ || typeof config?.apiKey !== 'string' || !config.apiKey.trim()
40
+ || typeof config?.agentId !== 'string' || !config.agentId.trim()) throw new Error('Connected runtime required');
41
+ baseUrl = url.href.replace(/\/$/, ''); apiKey = config.apiKey.trim(); agentId = config.agentId;
42
+ file = `.osuite/diagnostics/v2-${digest([baseUrl, agentId])}.json`;
43
+ release = acquireCredentialLock(cwd, file);
44
+ // Old state has no credential/workspace binding. Never guess its tenant.
45
+ for (const base of new Set([config.baseUrl, baseUrl])) {
46
+ if (readCredentialFile(cwd, `.osuite/diagnostics/${digest([base, agentId])}.json`) !== null) throw new Error('Unscoped legacy measurement');
47
+ }
48
+ journal = readJournal(cwd, file);
49
+ const credential = digest(apiKey);
50
+ attempt = journal.attempts.find((value) => value.credential === credential);
51
+ if (!attempt) {
52
+ if (journal.attempts.length >= 128) throw new Error('Measurement journal is full');
53
+ attempt = { credential, scope: null, state: 'started', reported: false,
54
+ ...(isTime(env.OSUITE_INSTALL_STARTED_AT) ? { install_started_at: env.OSUITE_INSTALL_STARTED_AT } : {}) };
55
+ journal.attempts.push(attempt);
56
+ save();
57
+ first = true;
58
+ }
59
+ } catch {
60
+ unlock();
61
+ emit('Diagnostic measurement is unavailable; the doctor check will still run.');
62
+ return run();
63
+ }
64
+ try {
65
+ let verified = false;
66
+ try {
67
+ const response = await fetchImpl(`${baseUrl}/api/onboarding/measurement`, {
68
+ method: 'GET', redirect: 'error', signal: AbortSignal.timeout(3000), headers: { 'x-api-key': apiKey },
69
+ });
70
+ if (!response.ok) throw new Error('Identity unavailable');
71
+ const identity = await response.json();
72
+ if (identity?.version !== 1 || typeof identity.org_id !== 'string' || !identity.org_id.trim()
73
+ || identity.org_id.length > 256 || identity.agent_id !== agentId) throw new Error('Identity mismatch');
74
+ const scope = digest([baseUrl, identity.org_id, identity.agent_id]);
75
+ if (attempt.scope && attempt.scope !== scope) throw new Error('Credential identity changed');
76
+ attempt.scope = scope;
77
+ save();
78
+ verified = true;
79
+ } catch {
80
+ emit('Diagnostic identity is unverified; the first result will remain local and unmeasured.');
81
+ }
82
+ const result = await run();
83
+ try {
84
+ if (first) {
85
+ attempt.state = 'finished'; attempt.passed = result === true;
86
+ save();
87
+ }
88
+ if (!verified) return result;
89
+ const index = journal.attempts.findIndex((value) => value.scope === attempt.scope);
90
+ const original = journal.attempts[index];
91
+ // A rotated but unresolved earlier credential might belong to this cohort.
92
+ // Keep the sample unavailable until that binding can actually be verified.
93
+ if (journal.attempts.slice(0, index).some((value) => value.scope === null)) {
94
+ emit('An earlier diagnostic identity is unresolved; no later result was reported as first.');
95
+ return result;
96
+ }
97
+ if (original.state !== 'finished' || original.reported) return result;
98
+ const payload = {
99
+ version: 1, event: 'doctor_first_result', passed: original.passed,
100
+ source: original.install_started_at ? 'installer' : 'manual_cli',
101
+ ...(original.install_started_at ? { install_started_at: original.install_started_at } : {}),
102
+ };
103
+ const response = await fetchImpl(`${baseUrl}/api/onboarding/measurement`, {
104
+ method: 'POST', redirect: 'error', signal: AbortSignal.timeout(3000),
105
+ headers: { 'content-type': 'application/json', 'x-api-key': apiKey }, body: JSON.stringify(payload),
106
+ });
107
+ if (response.ok) { original.reported = true; save(); }
108
+ else emit('The first diagnostic result is retained locally; it was not acknowledged by Studio.');
109
+ } catch {
110
+ emit('The first diagnostic result is retained locally; reporting failed without changing the check result.');
111
+ }
112
+ return result;
113
+ } finally {
114
+ unlock();
115
+ }
116
+ }