witnora 0.19.2 → 0.20.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/dist/cli.js +8 -0
- package/dist/command-help.js +4 -1
- package/dist/mcp.js +25 -0
- package/dist/onboard.js +73 -1
- package/mcp.d.ts +9 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -158,6 +158,7 @@ else if (command === "onboard") {
|
|
|
158
158
|
name: readFlag("--name"),
|
|
159
159
|
repository: readFlag("--repo") ?? process.cwd(),
|
|
160
160
|
template: readFlag("--template") ? parseAgentTemplate(readFlag("--template")) : undefined,
|
|
161
|
+
actionTransport: readActionTransport(readFlag("--action-transport")),
|
|
161
162
|
openBrowser: readBoolFlag("--no-browser") ? async () => { } : undefined,
|
|
162
163
|
});
|
|
163
164
|
}
|
|
@@ -906,6 +907,13 @@ else {
|
|
|
906
907
|
witnora schema validate --schema evidence-bundle --file .witnora/latest/agentcert-evidence.json
|
|
907
908
|
`);
|
|
908
909
|
}
|
|
910
|
+
function readActionTransport(value) {
|
|
911
|
+
if (value === undefined)
|
|
912
|
+
return undefined;
|
|
913
|
+
if (value === "http" || value === "mcp")
|
|
914
|
+
return value;
|
|
915
|
+
throw new Error("--action-transport must be http or mcp.");
|
|
916
|
+
}
|
|
909
917
|
async function loadConfig(path) {
|
|
910
918
|
if (!path) {
|
|
911
919
|
return undefined;
|
package/dist/command-help.js
CHANGED
|
@@ -41,11 +41,13 @@ Options:
|
|
|
41
41
|
return `Usage:
|
|
42
42
|
witnora onboard --project <project-id>
|
|
43
43
|
witnora onboard --project <project-id> --template <browser|coding|mcp|workflow|data>
|
|
44
|
+
witnora onboard --project <project-id> --action-transport <http|mcp>
|
|
44
45
|
|
|
45
46
|
Opens one browser authorization, saves a restricted project credential, detects the repository,
|
|
46
47
|
writes missing starter files, starts a customer-owned Gateway in the background, and records an
|
|
47
48
|
isolated synthetic self-test receipt. The self-test does not create assurance evidence or establish
|
|
48
|
-
CURRENT status.
|
|
49
|
+
CURRENT status. When --action-transport is selected, Witnora validates that exact local transport
|
|
50
|
+
without proposing or executing an Action and reports the bounded result to Hosted.
|
|
49
51
|
|
|
50
52
|
Options:
|
|
51
53
|
--server <url> Hosted server (default: https://witnora.com)
|
|
@@ -53,6 +55,7 @@ Options:
|
|
|
53
55
|
--name <name> Saved connection name (default: repository name)
|
|
54
56
|
--repo <directory> Repository to configure (default: current directory)
|
|
55
57
|
--template <type> Override automatic repository detection
|
|
58
|
+
--action-transport <t> Test HTTP or MCP against the exact generated sandbox Action path
|
|
56
59
|
--no-browser Print the approval URL without opening it
|
|
57
60
|
`;
|
|
58
61
|
if (command === "mcp")
|
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
2
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
6
|
import { z } from "zod";
|
|
@@ -52,6 +54,29 @@ export async function runWitnoraMcpStdioServer(options = {}) {
|
|
|
52
54
|
const { server } = await createWitnoraMcpServerFromRepository(options);
|
|
53
55
|
await server.connect(new StdioServerTransport());
|
|
54
56
|
}
|
|
57
|
+
export async function testWitnoraMcpConnection(options = {}) {
|
|
58
|
+
const { server, actionTool, action } = await createWitnoraMcpServerFromRepository(options);
|
|
59
|
+
const client = new Client({ name: "witnora-onboarding-connection-test", version: "1.0.0" });
|
|
60
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
61
|
+
try {
|
|
62
|
+
await server.connect(serverTransport);
|
|
63
|
+
await client.connect(clientTransport);
|
|
64
|
+
const listed = await client.listTools();
|
|
65
|
+
const tools = listed.tools.map((tool) => tool.name).sort();
|
|
66
|
+
const expected = [actionTool, "witnora_get_action"].sort();
|
|
67
|
+
if (JSON.stringify(tools) !== JSON.stringify(expected)) {
|
|
68
|
+
throw new Error("Witnora MCP connection test found an unexpected tool surface.");
|
|
69
|
+
}
|
|
70
|
+
if (tools.some((tool) => /approve|execute|verify/i.test(tool))) {
|
|
71
|
+
throw new Error("Witnora MCP connection test found a forbidden authority-bearing tool.");
|
|
72
|
+
}
|
|
73
|
+
return { actionId: action.id, actionTool, tools };
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await client.close().catch(() => undefined);
|
|
77
|
+
await server.close().catch(() => undefined);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
55
80
|
export function witnoraMcpActionToolName(actionId) {
|
|
56
81
|
const normalized = actionId.toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "action";
|
|
57
82
|
const candidate = `witnora_${normalized}`;
|
package/dist/onboard.js
CHANGED
|
@@ -8,7 +8,7 @@ import { verifyControlPlaneConnection } from "./control-plane.js";
|
|
|
8
8
|
import { inferPrivateCapabilities, runPrivateCapabilityDiscovery } from "./private-discovery.js";
|
|
9
9
|
import { parseAgentTemplate, starterAdapter, starterProfile, starterTripwireConfig } from "./onboarding-templates.js";
|
|
10
10
|
import { writeTryEvidence } from "./try.js";
|
|
11
|
-
import { doctorCustomerGateway, activateManagedWorkflowHarness, configureCustomerHttpAction, ensureCustomerGatewayPortAvailable, initializeCustomerGateway, inspectLocalRuntimeBinding, inspectCustomerGatewayFiles, startManagedCustomerGateway, statusManagedCustomerGateway, stopManagedCustomerGateway, upgradeCustomerGatewayRuntime, RuntimeSetupNotReadyError, } from "./gateway.js";
|
|
11
|
+
import { doctorCustomerGateway, activateManagedWorkflowHarness, configureCustomerHttpAction, ensureCustomerGatewayPortAvailable, initializeCustomerGateway, inspectLocalRuntimeBinding, inspectCustomerGatewayFiles, loadCustomerMcpActionBinding, startManagedCustomerGateway, statusManagedCustomerGateway, stopManagedCustomerGateway, upgradeCustomerGatewayRuntime, RuntimeSetupNotReadyError, } from "./gateway.js";
|
|
12
12
|
import { discoverRuntimeReferences, planRuntimeSandboxModules } from "./runtime-sandbox-kit.js";
|
|
13
13
|
import { automaticRuntimeReferencesUsable, bootstrapLocalRuntime, verifyAutomaticRuntimeProbe } from "./runtime-bootstrap.js";
|
|
14
14
|
import { activateRealPathIntegrations } from "./real-path-activation.js";
|
|
@@ -294,6 +294,19 @@ export async function runOnboard(options) {
|
|
|
294
294
|
const runtimeReadiness = doctor.overall === "READY_FOR_RUNTIME" && runtimeBinding
|
|
295
295
|
? { state: "LOCAL_SANDBOX_READY", checkedAt: new Date().toISOString(), limitations: [] }
|
|
296
296
|
: { state: "RECORDED_ONLY", checkedAt: new Date().toISOString(), limitations: [runtimeLimitation ?? "The local sandbox Runtime worker has not established exact adapter, probe, source-key, identity, mandate, and readiness bindings."] };
|
|
297
|
+
const actionTransportTest = options.actionTransport
|
|
298
|
+
? await runActionTransportTest({
|
|
299
|
+
transport: options.actionTransport,
|
|
300
|
+
repository: repositoryPath,
|
|
301
|
+
server,
|
|
302
|
+
projectId: token.projectId,
|
|
303
|
+
apiKey: token.apiKey,
|
|
304
|
+
repositoryIdentity: repository,
|
|
305
|
+
httpActionReady: httpActionSetup?.state === "READY" && Boolean(httpActionSetup.action),
|
|
306
|
+
fetch: requestFetch,
|
|
307
|
+
generatedFiles,
|
|
308
|
+
})
|
|
309
|
+
: undefined;
|
|
297
310
|
await reportInstall(requestFetch, server, token.projectId, token.apiKey, setupPlan.id, {
|
|
298
311
|
status: "verified", attemptId, generatedFiles: relativeGeneratedFiles(repositoryPath, generatedFiles), runtimeReadiness,
|
|
299
312
|
connectedAgent: agentIdentity,
|
|
@@ -316,11 +329,18 @@ export async function runOnboard(options) {
|
|
|
316
329
|
if (httpActionSetup?.state === "READY" && httpActionSetup.action) {
|
|
317
330
|
output(`HTTP Action: READY. POST ${managedGateway.baseUrl}${httpActionSetup.action.path}; copy the action-scoped token and request example from .witnora/gateway/HTTP_ACTION.md.\n`);
|
|
318
331
|
}
|
|
332
|
+
if (actionTransportTest?.state === "PASSED") {
|
|
333
|
+
output(`Action transport: ${actionTransportTest.transport.toUpperCase()} connection test PASSED at the customer-owned Gateway. No Action was proposed or executed.\n`);
|
|
334
|
+
}
|
|
335
|
+
else if (actionTransportTest) {
|
|
336
|
+
output(`Action transport: ${actionTransportTest.transport.toUpperCase()} is waiting for one exact sandbox Task/action path. ${actionTransportTest.limitation}\n`);
|
|
337
|
+
}
|
|
319
338
|
output("Connected. Nora is monitoring this Agent. Run it normally whenever it is ready; the first source-signed activity will appear automatically without blocking setup.\n");
|
|
320
339
|
return { projectId: token.projectId, connectionName: token.connectionName, credentialsPath, template: repository.template,
|
|
321
340
|
repositoryKind: repository.kind, generatedFiles, receiptPath, discovery, setupPlanId: setupPlan.id,
|
|
322
341
|
gatewayDirectory: join(repositoryPath, ".witnora", "gateway"), gatewayArchiveDirectory: gatewayMigration?.archiveDirectory,
|
|
323
342
|
gateway: managedGateway, runtimeReadiness, assuranceHarnessReadiness, continuousService,
|
|
343
|
+
actionTransportTest,
|
|
324
344
|
...(httpActionSetup?.state === "READY" && httpActionSetup.action ? { httpAction: {
|
|
325
345
|
state: "READY",
|
|
326
346
|
method: "POST",
|
|
@@ -346,6 +366,58 @@ export async function runOnboard(options) {
|
|
|
346
366
|
throw new Error(`Witnora Setup Autopilot rolled back this install attempt: ${diagnosis}`);
|
|
347
367
|
}
|
|
348
368
|
}
|
|
369
|
+
async function runActionTransportTest(options) {
|
|
370
|
+
if (!options.httpActionReady)
|
|
371
|
+
return {
|
|
372
|
+
state: "WAITING_FOR_ACTION_PATH",
|
|
373
|
+
transport: options.transport,
|
|
374
|
+
limitation: "Define and approve one exact sandbox Task/action Harness, then rerun this same onboarding command.",
|
|
375
|
+
};
|
|
376
|
+
const binding = await loadCustomerMcpActionBinding({ repository: options.repository });
|
|
377
|
+
const checkedAt = new Date().toISOString();
|
|
378
|
+
const passed = options.transport === "http"
|
|
379
|
+
? {
|
|
380
|
+
state: "PASSED",
|
|
381
|
+
transport: "http",
|
|
382
|
+
checkedAt,
|
|
383
|
+
actionId: binding.action.id,
|
|
384
|
+
endpoint: `${binding.baseUrl}${binding.action.path}`,
|
|
385
|
+
}
|
|
386
|
+
: await import("./mcp.js").then(async ({ testWitnoraMcpConnection }) => {
|
|
387
|
+
const result = await testWitnoraMcpConnection({ repository: options.repository, fetch: options.fetch });
|
|
388
|
+
return {
|
|
389
|
+
state: "PASSED",
|
|
390
|
+
transport: "mcp",
|
|
391
|
+
checkedAt,
|
|
392
|
+
actionId: result.actionId,
|
|
393
|
+
actionTool: result.actionTool,
|
|
394
|
+
};
|
|
395
|
+
});
|
|
396
|
+
const report = {
|
|
397
|
+
transport: passed.transport,
|
|
398
|
+
actionId: passed.actionId,
|
|
399
|
+
...(passed.transport === "http" ? { endpoint: passed.endpoint } : { actionTool: passed.actionTool }),
|
|
400
|
+
};
|
|
401
|
+
const receipt = await jsonRequest(options.fetch, `${options.server}/v1/projects/${encodeURIComponent(options.projectId)}/onboarding/self-test`, {
|
|
402
|
+
method: "POST",
|
|
403
|
+
headers: { authorization: `Bearer ${options.apiKey}`, "content-type": "application/json" },
|
|
404
|
+
body: JSON.stringify({
|
|
405
|
+
template: options.repositoryIdentity.template,
|
|
406
|
+
repository: {
|
|
407
|
+
kind: options.repositoryIdentity.kind,
|
|
408
|
+
name: options.repositoryIdentity.name,
|
|
409
|
+
fingerprintSha256: options.repositoryIdentity.fingerprintSha256,
|
|
410
|
+
actionTransportTest: report,
|
|
411
|
+
},
|
|
412
|
+
bundleSha256: createHash("sha256").update(JSON.stringify(report)).digest("hex"),
|
|
413
|
+
}),
|
|
414
|
+
});
|
|
415
|
+
const receiptPath = join(options.repository, ".witnora", "onboarding", "receipts", `action-transport-${passed.transport}-${Date.now()}.json`);
|
|
416
|
+
await mkdir(dirname(receiptPath), { recursive: true });
|
|
417
|
+
await writeFile(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
418
|
+
options.generatedFiles.push(receiptPath);
|
|
419
|
+
return { ...passed, receiptPath };
|
|
420
|
+
}
|
|
349
421
|
async function waitForInstalledGatewayService(options) {
|
|
350
422
|
const pause = options.sleep ?? ((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
|
|
351
423
|
const deadline = Date.now() + (options.timeoutMs ?? 12_000);
|
package/mcp.d.ts
CHANGED
|
@@ -39,4 +39,13 @@ export function runWitnoraMcpStdioServer(options?: {
|
|
|
39
39
|
fetch?: typeof fetch;
|
|
40
40
|
}): Promise<void>;
|
|
41
41
|
|
|
42
|
+
export function testWitnoraMcpConnection(options?: {
|
|
43
|
+
repository?: string;
|
|
44
|
+
dir?: string;
|
|
45
|
+
fetch?: typeof fetch;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
actionTool: string;
|
|
48
|
+
tools: string[];
|
|
49
|
+
}>;
|
|
50
|
+
|
|
42
51
|
export function witnoraMcpActionToolName(actionId: string): string;
|