omnius 1.0.957 → 1.0.958

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.
@@ -0,0 +1,121 @@
1
+ /**
2
+ * mcp/client.ts — MCP Client (Model Context Protocol)
3
+ *
4
+ * Full MCP client implementing:
5
+ * - initialize handshake (protocol version negotiation)
6
+ * - tools/list (discover server-provided tools)
7
+ * - tools/call (invoke a tool with arguments)
8
+ * - resources/list (discover server-provided resources)
9
+ * - resources/read (read a specific resource)
10
+ * - prompts/list (discover server-provided prompts)
11
+ *
12
+ * Protocol version: MCP 2025-06-18
13
+ * Transport: stdio (subprocess) or Streamable HTTP
14
+ *
15
+ * Reference: Hannover src/services/mcp/client.ts
16
+ * Protocol: https://modelcontextprotocol.io/specification/2025-06-18/
17
+ */
18
+ import type { McpServerConfig, McpToolDefinition, McpResource, McpPrompt, McpToolCallResult, McpInitializeResult, McpConnection, McpContent } from "./types.js";
19
+ import type { McpReturnedHttpReadPolicy } from "./types.js";
20
+ export interface McpReturnedHttpReadBinding {
21
+ readonly serverName: string;
22
+ readonly origin: string;
23
+ readonly policy: Readonly<Required<McpReturnedHttpReadPolicy>>;
24
+ readonly policyRevision: string;
25
+ }
26
+ export declare class McpClient {
27
+ #private;
28
+ private transport;
29
+ private serverName;
30
+ private config;
31
+ private initResult;
32
+ private cachedTools;
33
+ private cachedResources;
34
+ private notificationHandlers;
35
+ /** Config reported by getConnection(); keeps ${MCP_SECRET_*} references instead of resolved credentials. */
36
+ private readonly displayConfig;
37
+ constructor(serverName: string, config: McpServerConfig, displayConfig?: McpServerConfig);
38
+ /**
39
+ * Register a callback for server-sent JSON-RPC notifications.
40
+ * Called for progress updates, log messages, list_changed events, etc.
41
+ * Multiple handlers can be registered.
42
+ */
43
+ onNotification(handler: (method: string, params: any) => void): void;
44
+ /** Server name */
45
+ get name(): string;
46
+ /** Whether the client is connected and initialized */
47
+ get connected(): boolean;
48
+ /** Server capabilities (after initialize) */
49
+ get capabilities(): McpInitializeResult | null;
50
+ /**
51
+ * Connect to the MCP server and perform protocol handshake.
52
+ */
53
+ connect(): Promise<McpInitializeResult>;
54
+ /**
55
+ * Disconnect from the MCP server.
56
+ */
57
+ disconnect(): Promise<void>;
58
+ /**
59
+ * List all tools provided by this MCP server.
60
+ * Results are cached until disconnect.
61
+ */
62
+ listTools(): Promise<McpToolDefinition[]>;
63
+ /**
64
+ * Call a tool on the MCP server.
65
+ *
66
+ * @param toolName The tool name (as returned by listTools)
67
+ * @param args Tool arguments matching the tool's inputSchema
68
+ * @param timeoutMs Request timeout (default: 60s for tool calls)
69
+ * @param options Optional: progressToken to opt-in to progress notifications,
70
+ * onProgress callback receives every notifications/progress
71
+ * event whose progressToken matches.
72
+ */
73
+ callTool(toolName: string, args: Record<string, unknown>, timeoutMs?: number, options?: {
74
+ progressToken?: string | number;
75
+ onProgress?: (progress: {
76
+ progress: number;
77
+ total?: number;
78
+ message?: string;
79
+ }) => void;
80
+ }): Promise<McpToolCallResult>;
81
+ /**
82
+ * List all resources provided by this MCP server.
83
+ * Results are cached until disconnect.
84
+ */
85
+ listResources(): Promise<McpResource[]>;
86
+ /**
87
+ * Read a specific resource by URI.
88
+ */
89
+ readResource(uri: string): Promise<McpContent[]>;
90
+ /** Original successful RPC object on this live connection; JSON copies never qualify. */
91
+ isOriginalReturnedHttpResult(result: unknown): boolean;
92
+ getReturnedHttpReadBinding(): Readonly<McpReturnedHttpReadBinding> | undefined;
93
+ isReturnedHttpUrlAllowed(url: string, binding: Readonly<McpReturnedHttpReadBinding>): boolean;
94
+ /** Credential-bearing GET is available only through a current original binding. */
95
+ fetchReturnedHttpSource(url: string, binding: Readonly<McpReturnedHttpReadBinding>, signal: AbortSignal): Promise<Response>;
96
+ /**
97
+ * List all prompts provided by this MCP server.
98
+ */
99
+ listPrompts(): Promise<McpPrompt[]>;
100
+ /**
101
+ * Get the full connection state for this server.
102
+ */
103
+ getConnection(): McpConnection;
104
+ private ensureConnected;
105
+ }
106
+ /**
107
+ * Normalize a string for use as an MCP tool name component.
108
+ * Replaces invalid chars with underscores, collapses multiples.
109
+ */
110
+ export declare function normalizeMcpName(name: string): string;
111
+ /**
112
+ * Build a namespaced tool name: mcp__{server}__{tool}
113
+ */
114
+ export declare function buildMcpToolName(serverName: string, toolName: string): string;
115
+ /**
116
+ * Parse a namespaced tool name back to server + tool.
117
+ */
118
+ export declare function parseMcpToolName(fullName: string): {
119
+ server: string;
120
+ tool: string;
121
+ } | null;
@@ -0,0 +1,65 @@
1
+ import type { McpClient } from "./client.js";
2
+ import type { McpReturnedHttpReadPolicy, McpToolCallResult } from "./types.js";
3
+ import type { ToolInvocationContext } from "../types.js";
4
+ /** Fixed codes only: provider/guard exceptions cannot smuggle a credential into display errors. */
5
+ export declare function returnedHttpReadFailureCode(error: unknown): string;
6
+ export interface ReturnedHttpSourceInvocation {
7
+ workspaceRoot: string;
8
+ sessionId: string;
9
+ runId: string;
10
+ taskEpoch: number;
11
+ ownerId: string;
12
+ ownerGeneration: number;
13
+ toolCallId: string;
14
+ toolName: string;
15
+ assertCurrent: () => void;
16
+ signal?: AbortSignal;
17
+ }
18
+ export interface ReturnedHttpOriginalOperation {
19
+ result: McpToolCallResult;
20
+ invocation: Readonly<ReturnedHttpSourceInvocation>;
21
+ }
22
+ export interface ReturnedHttpSourceReference {
23
+ sourceRef: string;
24
+ url: string;
25
+ consumption: 'not_read';
26
+ }
27
+ export interface ReturnedHttpSourceResolution {
28
+ readonly sourceRef: string;
29
+ readonly url: string;
30
+ readonly serverName: string;
31
+ readonly assertCurrent: () => void;
32
+ readonly fetch: (signal: AbortSignal) => Promise<Response>;
33
+ }
34
+ /** Original host resolution only; copied JSON/functions are not a credential grant. */
35
+ export declare function readReturnedHttpSourceResolution(value: unknown): Readonly<ReturnedHttpSourceResolution> | undefined;
36
+ /** Attenuation only: this cannot create a resolution from a copied/plain object. */
37
+ export declare function withReturnedHttpSourceGuard(value: unknown, guard: () => void): Readonly<ReturnedHttpSourceResolution> | undefined;
38
+ export declare function normalizeReturnedHttpReadPolicy(value: McpReturnedHttpReadPolicy): Readonly<Required<McpReturnedHttpReadPolicy>>;
39
+ export declare function returnedHttpUrlAllowed(raw: string, origin: string, policy: Readonly<McpReturnedHttpReadPolicy>): boolean;
40
+ export interface ReturnedHttpSourceCaptureStatus {
41
+ status: 'captured' | 'partial' | 'unavailable' | 'unconfigured';
42
+ reasonCode?: string;
43
+ omittedCandidates?: 'unknown';
44
+ observedCandidates?: number;
45
+ issuedReferences?: number;
46
+ rejectedCandidates?: number;
47
+ limits: {
48
+ maxResultBytes: number;
49
+ maxTraversalNodes: number;
50
+ maxDepth: number;
51
+ maxCandidates: number;
52
+ maxSources: number;
53
+ };
54
+ }
55
+ /** Hot, bounded original-result registry. No persistence/JSON restoration grants authority. */
56
+ export declare class ReturnedHttpSourceRegistry {
57
+ #private;
58
+ readCaptureStatus(observation: unknown): Readonly<ReturnedHttpSourceCaptureStatus> | undefined;
59
+ constructor(options: {
60
+ readInvocation: (context?: ToolInvocationContext) => Readonly<ReturnedHttpSourceInvocation> | undefined;
61
+ readOriginalOperation: (observation: unknown) => ReturnedHttpOriginalOperation | undefined;
62
+ });
63
+ capture(client: McpClient, observation: unknown): ReadonlyArray<Readonly<ReturnedHttpSourceReference>>;
64
+ resolve(sourceRef: string, context?: ToolInvocationContext): Readonly<ReturnedHttpSourceResolution> | undefined;
65
+ }
@@ -35,10 +35,17 @@ export interface McpStdioConfig {
35
35
  args?: string[];
36
36
  env?: Record<string, string>;
37
37
  }
38
+ export interface McpReturnedHttpReadPolicy {
39
+ pathPrefixes: string[];
40
+ credentialHeaderNames: string[];
41
+ maxResponseBytes?: number;
42
+ }
38
43
  export interface McpHttpConfig {
39
44
  type: "http" | "sse";
40
45
  url: string;
41
46
  headers?: Record<string, string>;
47
+ /** Explicit host policy for reading URLs returned by this exact connector. */
48
+ returnedHttpRead?: McpReturnedHttpReadPolicy;
42
49
  }
43
50
  export type McpServerConfig = McpStdioConfig | McpHttpConfig;
44
51
  export interface McpConfig {
@@ -0,0 +1,32 @@
1
+ export interface NativeToolOperationInvocation {
2
+ readonly workspaceRoot: string;
3
+ readonly sessionId: string;
4
+ readonly runId: string;
5
+ readonly taskEpoch: number;
6
+ readonly ownerId: string;
7
+ readonly ownerGeneration: number;
8
+ readonly toolCallId: string;
9
+ readonly toolName: string;
10
+ readonly assertCurrent: () => void;
11
+ readonly signal?: AbortSignal;
12
+ readonly returnedSourceConsumer?: Readonly<{
13
+ toolName: string;
14
+ selector: 'source_ref';
15
+ }>;
16
+ }
17
+ export interface NativeToolOperationObservationV1 {
18
+ readonly schema: 'omnius.native-operation-observation.v1';
19
+ readonly scope: Readonly<Omit<NativeToolOperationInvocation, 'assertCurrent' | 'signal'>>;
20
+ readonly producerRef: string;
21
+ readonly toolSchemaSha256: string;
22
+ readonly argumentsSha256: string;
23
+ readonly nativeResultSha256?: string;
24
+ readonly coverage: 'complete' | 'partial' | 'unavailable';
25
+ /** Native producer return status, not business success, body consumption or task readiness. */
26
+ readonly returnedStatus: 'success' | 'error';
27
+ readonly observedAt: string;
28
+ }
29
+ /** Pure identity helper. This function cannot issue an observation or permission. */
30
+ export declare function nativeOperationDigest(value: unknown): string;
31
+ /** Reader only. Fixed native producers keep their issuance maps private. */
32
+ export declare function readIssuedNativeOperationObservation(value: unknown): Readonly<NativeToolOperationObservationV1> | undefined;
@@ -110,9 +110,9 @@ export declare const NolGgufControlInventorySchema: z.ZodObject<{
110
110
  path: z.ZodString;
111
111
  role: z.ZodEnum<{
112
112
  other: "other";
113
+ config: "config";
113
114
  tokenizer: "tokenizer";
114
115
  weights: "weights";
115
- config: "config";
116
116
  chat_template: "chat_template";
117
117
  adapter: "adapter";
118
118
  }>;
@@ -56,9 +56,9 @@ export declare const NolPytorchControlInventorySchema: z.ZodObject<{
56
56
  path: z.ZodString;
57
57
  role: z.ZodEnum<{
58
58
  other: "other";
59
+ config: "config";
59
60
  tokenizer: "tokenizer";
60
61
  weights: "weights";
61
- config: "config";
62
62
  chat_template: "chat_template";
63
63
  adapter: "adapter";
64
64
  }>;
@@ -1,5 +1,6 @@
1
1
  import type { Tool, ToolResult, ToolInvocationContext } from "../types.js";
2
2
  import { type BrowserPageReader } from "./browser-page-fallback.js";
3
+ import { type ReturnedHttpSourceResolution } from "../mcp/returned-http-source.js";
3
4
  export interface WebFetchReceipt {
4
5
  schema: "omnius.web-fetch-receipt.v1";
5
6
  requestedUrl: string;
@@ -10,11 +11,20 @@ export interface WebFetchReceipt {
10
11
  responseSha256: string;
11
12
  fetchedAt: string;
12
13
  linkStatus: "retrieved";
14
+ returnedSource?: {
15
+ sourceRef: string;
16
+ serverName: string;
17
+ consumption: 'body_read';
18
+ };
13
19
  }
14
20
  export declare class WebFetchTool implements Tool {
15
21
  #private;
16
22
  name: string;
17
23
  private readonly eagerSourceMaxBytes;
24
+ readonly returnedHttpSourceConsumer?: Readonly<{
25
+ selector: 'source_ref';
26
+ }>;
27
+ private readonly returnedSourceResolver?;
18
28
  private readonly browserFallback;
19
29
  /** Companion tools registered beside this one; unfed hosts keep the full guidance. */
20
30
  private browserAvailable;
@@ -25,6 +35,7 @@ export declare class WebFetchTool implements Tool {
25
35
  constructor(options?: {
26
36
  eagerSourceMaxBytes?: number;
27
37
  browserFallback?: BrowserPageReader;
38
+ returnedSourceResolver?: (sourceRef: string, context?: ToolInvocationContext) => Readonly<ReturnedHttpSourceResolution> | undefined;
28
39
  });
29
40
  isReadOnly(): boolean;
30
41
  acceptsInvocationContext: boolean;
@@ -229,6 +229,7 @@ export interface AuxiliaryOperationBinding {
229
229
  export interface ToolInvocationContext {
230
230
  /** Original host child-dispatch identity; preserve by reference through adapters. */
231
231
  nativeChildInvocation?: Readonly<import("./native-child-evidence.js").NativeChildInvocation>;
232
+ nativeOperationInvocation?: Readonly<import("./native-operation-observation.js").NativeToolOperationInvocation>;
232
233
  /** Native FileWrite result correlation only; never supplied by model arguments. */
233
234
  nativeFileWriteInvocation?: Readonly<import("./native-file-write-observation.js").NativeFileWriteInvocationScope>;
234
235
  /** Preserve this exact host identity while composing cell-local guards. JSON copies grant nothing. */
@@ -467,6 +468,10 @@ export interface Tool {
467
468
  getHistoryObservationIdentity?: (args: Record<string, unknown>, result: ToolResult) => string | null;
468
469
  /** Exact native command result custody, including failures; model JSON cannot issue it. */
469
470
  getCommandExecutionObservation?: (args: Record<string, unknown>, result: ToolResult) => unknown;
471
+ readIssuedOperationObservation?: (args: Record<string, unknown>, result: ToolResult) => unknown;
472
+ returnedHttpSourceConsumer?: Readonly<{
473
+ selector: 'source_ref';
474
+ }>;
470
475
  /** Original native FileWrite result proof; JSON/copies cannot issue it. */
471
476
  getNativeFileWriteObservation?: (args: Record<string, unknown>, result: ToolResult) => unknown;
472
477
  /** Original producer result custody; returned JSON never grants child evidence. */
@@ -190,6 +190,10 @@ export interface AgenticTool {
190
190
  /** Private execution-time identity; never permission, progress or effect authority. */
191
191
  getHistoryObservationIdentity?: (args: Record<string, unknown>, result: AgenticToolResult) => string | null;
192
192
  getCommandExecutionObservation?: (args: Record<string, unknown>, result: AgenticToolResult) => unknown;
193
+ readIssuedOperationObservation?: (args: Record<string, unknown>, result: AgenticToolResult) => unknown;
194
+ returnedHttpSourceConsumer?: Readonly<{
195
+ selector: 'source_ref';
196
+ }>;
193
197
  readIssuedChildEvidence?: (result: AgenticToolResult) => readonly import("../execution/native-child-evidence.js").NativeChildEvidenceV1[];
194
198
  getNativeFileWriteObservation?: (args: Record<string, unknown>, result: AgenticToolResult) => unknown;
195
199
  getDesktopVerificationScope?: () => DesktopVerificationScope | undefined;
@@ -4667,6 +4671,7 @@ export declare class AgenticRunner {
4667
4671
  * not depend on raw tool messages surviving compaction. */
4668
4672
  private _recentToolOutcomes;
4669
4673
  private readonly _nativeShellProgressProofs;
4674
+ private readonly _nativeOperationProgressProofs;
4670
4675
  /** Recent successful user-work mutations suppress generic "create again" nudges. */
4671
4676
  private _groundTruthSuccessPaths;
4672
4677
  /** Monotonic counter for observed local state changes.
@@ -4730,6 +4735,8 @@ export declare class AgenticRunner {
4730
4735
  */
4731
4736
  private _buildRecentActionGroundTruth;
4732
4737
  private _nativeShellProgressIsCurrent;
4738
+ private _nativeOperationProgressIsCurrent;
4739
+ private _nativeOperationRepetitions;
4733
4740
  private _equivalentNativeObservations;
4734
4741
  /** Legacy REG/recovery prose is retained in telemetry only, never in model history. */
4735
4742
  private _isLegacyControlMessage;
@@ -91,6 +91,22 @@ export interface ModelFacingChildFacts {
91
91
  completionBoundary?: string;
92
92
  terminalProof?: string;
93
93
  }
94
+ export interface ModelFacingOperationRepetitionFacts {
95
+ tool: string;
96
+ producerRef: string;
97
+ toolSchemaSha256: string;
98
+ argumentsSha256: string;
99
+ callIds: string[];
100
+ occurrences: {
101
+ count: number;
102
+ firstTurn: number;
103
+ lastTurn: number;
104
+ };
105
+ returnedSuccessCount: number;
106
+ returnedErrorCount: number;
107
+ distinctNativeResultCount: number;
108
+ partialOrUnavailableCount: number;
109
+ }
94
110
  export interface ModelFacingChildCoverage {
95
111
  status: 'available' | 'partial';
96
112
  maxWorkers: number;
@@ -104,6 +120,12 @@ export declare function renderModelFacingRunObservations(input: {
104
120
  text: string;
105
121
  }[];
106
122
  equivalentObservations?: readonly ModelFacingEquivalentObservationFacts[];
123
+ operationRepetitions?: readonly ModelFacingOperationRepetitionFacts[];
124
+ operationObservationCoverage?: {
125
+ window: string;
126
+ qualifiedReturns: number;
127
+ unavailableReturns: number;
128
+ };
107
129
  childEvidence?: readonly ModelFacingChildFacts[];
108
130
  childEvidenceCoverage?: ModelFacingChildCoverage;
109
131
  modifiedFiles?: readonly string[];
@@ -3321,6 +3321,58 @@ var init_system_deps = __esm({
3321
3321
  }
3322
3322
  });
3323
3323
 
3324
+ // packages/execution/dist/mcp/returned-http-source.js
3325
+ var captureLimits;
3326
+ var init_returned_http_source = __esm({
3327
+ "packages/execution/dist/mcp/returned-http-source.js"() {
3328
+ "use strict";
3329
+ captureLimits = Object.freeze({ maxResultBytes: 2097152, maxTraversalNodes: 8192, maxDepth: 16, maxCandidates: 32, maxSources: 4096 });
3330
+ }
3331
+ });
3332
+
3333
+ // packages/execution/dist/mcp/transport.js
3334
+ var init_transport = __esm({
3335
+ "packages/execution/dist/mcp/transport.js"() {
3336
+ "use strict";
3337
+ }
3338
+ });
3339
+
3340
+ // packages/execution/dist/mcp/client.js
3341
+ var init_client = __esm({
3342
+ "packages/execution/dist/mcp/client.js"() {
3343
+ "use strict";
3344
+ init_transport();
3345
+ init_returned_http_source();
3346
+ init_network_egress_policy();
3347
+ }
3348
+ });
3349
+
3350
+ // packages/execution/dist/mcp/secret-store.js
3351
+ var init_secret_store = __esm({
3352
+ "packages/execution/dist/mcp/secret-store.js"() {
3353
+ "use strict";
3354
+ }
3355
+ });
3356
+
3357
+ // packages/execution/dist/mcp/manager.js
3358
+ var init_manager = __esm({
3359
+ "packages/execution/dist/mcp/manager.js"() {
3360
+ "use strict";
3361
+ init_native_operation_observation();
3362
+ init_returned_http_source();
3363
+ init_client();
3364
+ init_secret_store();
3365
+ }
3366
+ });
3367
+
3368
+ // packages/execution/dist/native-operation-observation.js
3369
+ var init_native_operation_observation = __esm({
3370
+ "packages/execution/dist/native-operation-observation.js"() {
3371
+ "use strict";
3372
+ init_manager();
3373
+ }
3374
+ });
3375
+
3324
3376
  // packages/execution/dist/page-content-source.js
3325
3377
  var init_page_content_source = __esm({
3326
3378
  "packages/execution/dist/page-content-source.js"() {
@@ -247827,37 +247879,6 @@ Node text: ${this.#forgottenText}`;
247827
247879
  }
247828
247880
  });
247829
247881
 
247830
- // packages/execution/dist/mcp/transport.js
247831
- var init_transport = __esm({
247832
- "packages/execution/dist/mcp/transport.js"() {
247833
- "use strict";
247834
- }
247835
- });
247836
-
247837
- // packages/execution/dist/mcp/client.js
247838
- var init_client = __esm({
247839
- "packages/execution/dist/mcp/client.js"() {
247840
- "use strict";
247841
- init_transport();
247842
- }
247843
- });
247844
-
247845
- // packages/execution/dist/mcp/secret-store.js
247846
- var init_secret_store = __esm({
247847
- "packages/execution/dist/mcp/secret-store.js"() {
247848
- "use strict";
247849
- }
247850
- });
247851
-
247852
- // packages/execution/dist/mcp/manager.js
247853
- var init_manager = __esm({
247854
- "packages/execution/dist/mcp/manager.js"() {
247855
- "use strict";
247856
- init_client();
247857
- init_secret_store();
247858
- }
247859
- });
247860
-
247861
247882
  // packages/execution/dist/mcp/md-intake.js
247862
247883
  var init_md_intake = __esm({
247863
247884
  "packages/execution/dist/mcp/md-intake.js"() {
@@ -248933,6 +248954,10 @@ init_process_lifecycle();
248933
248954
  // packages/execution/dist/tools/desktop-control.js
248934
248955
  init_system_deps();
248935
248956
 
248957
+ // packages/execution/dist/index.js
248958
+ init_native_operation_observation();
248959
+ init_returned_http_source();
248960
+
248936
248961
  // packages/execution/dist/tools/change-log.js
248937
248962
  import { randomBytes } from "node:crypto";
248938
248963
  var _sessionId = `session-${Date.now()}-${randomBytes(3).toString("hex")}`;
@@ -252000,6 +252025,7 @@ var voids = new Set("area base br col embed hr img input link meta param source
252000
252025
 
252001
252026
  // packages/execution/dist/tools/web-fetch.js
252002
252027
  init_network_egress_policy();
252028
+ init_returned_http_source();
252003
252029
  var SMALL_SOURCE_BYTES = 5 * 1024 * 1024;
252004
252030
 
252005
252031
  // packages/execution/dist/index.js
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/index.js
3
- size: 42504395 bytes
4
- sha256: 955355759c30cd70c236eef620d1cd09fc546385c9371ba8849d3e3df496dc2c
3
+ size: 42540230 bytes
4
+ sha256: f34ed3b85f9cf0be2e8f26e6ecd77c183fe9a2095d1505bd1a565d6d030025ed