@ours.network/mcp 1.2.0-nightly.5 → 1.2.0-nightly.6

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,26 @@
1
+ export declare const APPLICATION_IDENTITIES_VERSION: 1;
2
+ export declare const APPLICATION_IDENTITIES_ENV = "OURS_MCP_CONFIG";
3
+ type ApplicationIdentityTarget = string | Readonly<{
4
+ instanceId: string;
5
+ }>;
6
+ export declare function applicationIdentityConfigPath(env?: NodeJS.ProcessEnv): string;
7
+ /** Application-local identity visibility bookkeeping, never authorization or selection state. */
8
+ export declare class ApplicationIdentityStore {
9
+ readonly stateDir: string | null;
10
+ readonly instanceId: string | null;
11
+ readonly path: string;
12
+ constructor(target: ApplicationIdentityTarget, options?: {
13
+ path?: string;
14
+ env?: NodeJS.ProcessEnv;
15
+ });
16
+ private rows;
17
+ private key;
18
+ list(): Promise<string[]>;
19
+ has(name: string): Promise<boolean>;
20
+ add(name: string): Promise<void>;
21
+ remove(name: string): Promise<void>;
22
+ }
23
+ export declare function filterApplicationIdentities<T extends {
24
+ name: string;
25
+ }>(store: ApplicationIdentityStore, daemonRows: readonly T[]): Promise<T[]>;
26
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { OursClient } from '@ours.network/sdk';
2
+ import type { HostProfile } from './host-profile.js';
3
+ import { createOursMcpServer } from './mcp/server.js';
4
+ export type ExternalConnectorSelection = Readonly<{
5
+ mode: 'external-profile';
6
+ profile: HostProfile;
7
+ ownerInstanceId: string;
8
+ }>;
9
+ export interface ConnectorOptions {
10
+ leaseToken: string;
11
+ clientPid: number;
12
+ version: string;
13
+ bindIdentity?: string;
14
+ selection?: ExternalConnectorSelection;
15
+ }
16
+ export declare class ArrivalWatcher {
17
+ private readonly client;
18
+ private readonly server;
19
+ private stopped;
20
+ private bound;
21
+ private readonly abort;
22
+ constructor(client: OursClient, server: ReturnType<typeof createOursMcpServer>);
23
+ stop(): void;
24
+ run(): Promise<void>;
25
+ }
26
+ export declare function runConnector(options: ConnectorOptions): Promise<void>;
@@ -0,0 +1,12 @@
1
+ export interface ContactLineInput {
2
+ name: string;
3
+ container_id: string;
4
+ /** pre-rendered root-linkage tag, e.g. ` [role "PeerOne" of BookKeeper]` */
5
+ rootTag?: string;
6
+ /** queued-restore count when the contact's keys are degraded */
7
+ degradedQueued?: number;
8
+ /** the shared name this contact held before the boot import sweep renamed it */
9
+ renamedFrom?: string;
10
+ }
11
+ export declare function duplicateNameCounts(items: ContactLineInput[]): Map<string, number>;
12
+ export declare function buildContactLines(items: ContactLineInput[]): string[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { readHostProfile, hostProfileFromEnv, hostProfileSelectionFromEnv, validateHostProfile } from './profile.js';
2
+ export type { HostProfile } from './profile.js';
3
+ export { endNativeSessionAtRoot, nativeClientForAtRoot, nativeSessionRecordPath, } from './native-session.js';
@@ -0,0 +1 @@
1
+ export { endNativeSessionAtRoot, nativeClientForAtRoot, nativeSessionRecordPath, } from '../native-session.js';
@@ -0,0 +1,2 @@
1
+ export { hostProfileFromEnv, hostProfileSelectionFromEnv, readHostProfile, validateHostProfile } from '../host-profile.js';
2
+ export type { HostProfile } from '../host-profile.js';
@@ -0,0 +1,13 @@
1
+ export type HostProfile = Readonly<{
2
+ endpoint: string;
3
+ expectedInstanceId: string;
4
+ credentialPath: string;
5
+ }>;
6
+ export declare function validateHostProfile(value: unknown): HostProfile;
7
+ export declare function readHostProfile(configPath: string): HostProfile | null;
8
+ /** Select only host-client profiles; daemon configuration resolution is unchanged. */
9
+ export declare function hostProfileSelectionFromEnv(env?: NodeJS.ProcessEnv): {
10
+ profile: HostProfile;
11
+ configPath: string;
12
+ } | null;
13
+ export declare function hostProfileFromEnv(env?: NodeJS.ProcessEnv): HostProfile | null;
@@ -0,0 +1,17 @@
1
+ import type { ToolRequestExtra } from './tool.js';
2
+ /** All path resolution, probing and I/O happens in the caller's OS context. */
3
+ export interface FileExecutionContext {
4
+ read(path: string, extra: ToolRequestExtra): Promise<{
5
+ filename: string;
6
+ size: number;
7
+ body: ReadableStream<Uint8Array>;
8
+ close(): void | Promise<void>;
9
+ }>;
10
+ write(path: string, body: ReadableStream<Uint8Array>, extra: ToolRequestExtra): Promise<{
11
+ path: string;
12
+ size: number;
13
+ }>;
14
+ canRead(path: string, extra: ToolRequestExtra): Promise<boolean>;
15
+ }
16
+ /** Standalone only. Managed callers must supply their sandbox callback context. */
17
+ export declare const localFileContext: FileExecutionContext;
@@ -0,0 +1,20 @@
1
+ import type { OursClient } from '@ours.network/sdk';
2
+ type IncomingFileMeta = Awaited<ReturnType<OursClient['listIncomingFiles']>>[number];
3
+ export declare const FILES_ALWAYS_PROMPT: boolean;
4
+ export declare const canRead: (p: string) => boolean;
5
+ declare function renderFiles(files: IncomingFileMeta[]): string;
6
+ export { renderFiles };
7
+ /**
8
+ * Annotate a get_files RESULT in place when some of its files are not readable
9
+ * by this OS user. Returns true if the result was annotated. No
10
+ * structuredContent (an older daemon) means no probe and no annotation — pure
11
+ * passthrough.
12
+ *
13
+ * The instruction is PREPENDED, never substituted for the daemon's own text.
14
+ * That text can carry payload the proxy cannot reconstruct — a voice message is
15
+ * delivered as a TRANSCRIPT, not as a path — so replacing it wholesale would
16
+ * drop real message content whenever an unreadable file shares a batch with one.
17
+ *
18
+ * Unchanged from `proxy.ts:139`. What changed is who calls it — see below.
19
+ */
20
+ export declare function annotateGetFilesResult(result: unknown, readable: (p: string) => boolean): boolean;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The member of `McpServer` this file touches, described structurally so
3
+ * nothing here has to import the MCP package. The real `McpServer` satisfies it.
4
+ */
5
+ export interface ArrivalPushTarget {
6
+ sendLoggingMessage(payload: {
7
+ level: 'info';
8
+ logger: string;
9
+ data: string;
10
+ }): unknown;
11
+ }
12
+ /** Reported per failed push; the caller decides how to log it. */
13
+ export type PushErrorSink = (what: 'sendLoggingMessage', err: unknown) => void;
14
+ /**
15
+ * Announce one body-free arrival summary on the logging channel.
16
+ */
17
+ export declare function pushArrivalNotification(target: ArrivalPushTarget, summary: string, onError: PushErrorSink): void;
@@ -0,0 +1,22 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ToolRequestExtra } from './tool.js';
3
+ export declare const REGISTRY_VERSION: 1;
4
+ export declare const TOOL_EFFECTS: readonly ["bound", "binding", "lifecycle", "profile", "contact", "inventory", "filesystem", "workspace-pin"];
5
+ export type ToolEffect = typeof TOOL_EFFECTS[number];
6
+ export interface ToolPolicy {
7
+ version: typeof REGISTRY_VERSION;
8
+ allowedEffects: readonly ToolEffect[];
9
+ /** Admission spans the entire handler, including file callbacks and rendering. */
10
+ admit: (tool: string, extra: ToolRequestExtra) => Promise<() => void | Promise<void>>;
11
+ }
12
+ /** Registrations own their effects alongside their original schemas and handlers. */
13
+ export declare class ToolRegistry {
14
+ private readonly server;
15
+ private readonly policy?;
16
+ readonly entries: Array<{
17
+ name: string;
18
+ effect: ToolEffect;
19
+ }>;
20
+ constructor(server: McpServer, policy?: ToolPolicy | undefined);
21
+ tool(effect: ToolEffect): McpServer['tool'];
22
+ }
@@ -0,0 +1,23 @@
1
+ import type { FileExecutionContext } from './file-context.js';
2
+ import { type ToolPolicy } from './registry.js';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import type { OursClient } from '@ours.network/sdk';
5
+ import type { ApplicationIdentityStore } from '../application-identities.js';
6
+ import type { OursClientProvider } from './tool.js';
7
+ /**
8
+ * Build one per-session MCP server around the already-attached shared-daemon
9
+ * client.
10
+ */
11
+ export declare function createOursMcpServer(client: OursClient | OursClientProvider, version: string, applicationIdentities: ApplicationIdentityStore, options?: {
12
+ remoteDaemonFiles?: boolean;
13
+ policy?: ToolPolicy;
14
+ fileContext?: FileExecutionContext;
15
+ }): McpServer;
16
+ export { REGISTRY_VERSION, TOOL_EFFECTS, type ToolEffect, type ToolPolicy } from "./registry.js";
17
+ export type { FileExecutionContext } from "./file-context.js";
18
+ /** Fixed-identity entry point: lifecycle tools cannot be enabled by a caller policy. */
19
+ export declare function createManagedOursMcpServer(client: OursClient, version: string, applicationIdentities: ApplicationIdentityStore, options: {
20
+ fileContext: FileExecutionContext;
21
+ admit: ToolPolicy['admit'];
22
+ remoteDaemonFiles?: boolean;
23
+ }): McpServer;
@@ -0,0 +1,22 @@
1
+ import type { OursClient } from '@ours.network/sdk';
2
+ import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
3
+ import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
4
+ export type ToolRequestExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
5
+ export type OursClientProvider = (extra: ToolRequestExtra) => OursClient | Promise<OursClient>;
6
+ /** The MCP content shape every ours tool returns. */
7
+ export type McpTextResult = {
8
+ content: Array<{
9
+ type: 'text';
10
+ text: string;
11
+ }>;
12
+ isError: boolean;
13
+ structuredContent?: Record<string, unknown>;
14
+ };
15
+ export declare function textResult(text: string, isError?: boolean): McpTextResult;
16
+ /** Managed clients never bind or retry behind the supervisor recovery gate. */
17
+ export declare function markManagedClient(client: OursClient): void;
18
+ export declare function rememberBinding(client: OursClient, name: string): void;
19
+ /** What runTool has learned. The inbox watch reads this rather than asking again. */
20
+ export declare function getBoundIdentity(client: OursClient): string | null;
21
+ export declare function forgetBinding(client: OursClient): void;
22
+ export declare function runTool<T>(clientValue: OursClient | Promise<OursClient>, call: (client: OursClient) => Promise<T> | T, render: (value: T) => McpTextResult | Promise<McpTextResult>): Promise<McpTextResult>;
@@ -0,0 +1,3 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import { type OursClientProvider } from '../tool.js';
3
+ export declare function registerCommandTools(server: ToolRegistry, clientFor: OursClientProvider): void;
@@ -0,0 +1,3 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import { type OursClientProvider } from '../tool.js';
3
+ export declare function registerContactsTools(server: ToolRegistry, clientFor: OursClientProvider): void;
@@ -0,0 +1,7 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import { type FileExecutionContext } from '../file-context.js';
3
+ import { type OursClientProvider } from '../tool.js';
4
+ export declare function registerFilesTools(server: ToolRegistry, clientFor: OursClientProvider, options?: {
5
+ remoteDaemonFiles?: boolean;
6
+ fileContext?: FileExecutionContext;
7
+ }): void;
@@ -0,0 +1,3 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import { type OursClientProvider } from '../tool.js';
3
+ export declare function registerHistoryTools(server: ToolRegistry, clientFor: OursClientProvider): void;
@@ -0,0 +1,6 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import type { ApplicationIdentityStore } from '../../application-identities.js';
3
+ import { type OursClientProvider } from '../tool.js';
4
+ export declare function registerIdentityTools(server: ToolRegistry, clientFor: OursClientProvider, applicationIdentities: ApplicationIdentityStore, options?: {
5
+ managedLifetime?: boolean;
6
+ }): void;
@@ -0,0 +1,4 @@
1
+ import { type FileExecutionContext } from '../file-context.js';
2
+ import type { ToolRegistry } from '../registry.js';
3
+ import { type OursClientProvider } from '../tool.js';
4
+ export declare function registerMessagingTools(server: ToolRegistry, clientFor: OursClientProvider, files?: FileExecutionContext): void;
@@ -0,0 +1,3 @@
1
+ import type { ToolRegistry } from '../registry.js';
2
+ import { type OursClientProvider } from '../tool.js';
3
+ export declare function registerProfileTools(server: ToolRegistry, clientFor: OursClientProvider): void;
@@ -0,0 +1,9 @@
1
+ import type { OursClient } from '@ours.network/sdk';
2
+ import type { HostProfile } from './host-profile.js';
3
+ export declare function nativeSessionRecordPath(hostRecordRoot: string, instanceId: string, nativeSessionId: string): string;
4
+ /** Attach or recover the owner for one native Codex/Claude logical session. */
5
+ export declare function nativeClientFor(profileValue: HostProfile, nativeSessionId: string, env?: NodeJS.ProcessEnv): Promise<OursClient>;
6
+ export declare function nativeClientForAtRoot(profileValue: HostProfile, nativeSessionId: string, hostRecordRoot: string): Promise<OursClient>;
7
+ /** Persist terminal intent and release exactly the owner captured by that intent. */
8
+ export declare function endNativeSession(profileValue: HostProfile, nativeSessionId: string, env?: NodeJS.ProcessEnv): Promise<void>;
9
+ export declare function endNativeSessionAtRoot(profileValue: HostProfile, nativeSessionId: string, hostRecordRoot: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Cross-process coordination guard for native session records.
3
+ * Uses SQLite BEGIN EXCLUSIVE on a permanent guard file adjacent to
4
+ * the JSON record, following the SDK acquireStateRootLock pattern.
5
+ *
6
+ * OS-released: process death closes the SQLite connection and
7
+ * releases the exclusive lock. The guard inode is permanent.
8
+ */
9
+ /**
10
+ * Acquire a cross-process exclusive lock on the guard file.
11
+ * Returns a release function. The lock is also released on process death.
12
+ */
13
+ export declare function acquireSessionGuard(recordPath: string): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/mcp",
3
- "version": "1.2.0-nightly.5",
3
+ "version": "1.2.0-nightly.6",
4
4
  "description": "MCP adapter for the shared ours daemon, with application-local identity bookkeeping and secure agent-to-agent messaging tools over stdio.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -27,7 +27,15 @@
27
27
  "ours-mcp": "dist/cli.js"
28
28
  },
29
29
  "exports": {
30
- "./dist/*": "./dist/*"
30
+ "./dist/*": "./dist/*",
31
+ "./server": {
32
+ "types": "./dist/types/mcp/server.d.ts",
33
+ "default": "./dist/server.js"
34
+ },
35
+ "./application-identities": {
36
+ "types": "./dist/types/application-identities.d.ts",
37
+ "default": "./dist/application-identities.js"
38
+ }
31
39
  },
32
40
  "files": [
33
41
  "dist",
@@ -46,20 +54,20 @@
46
54
  "dev": "tsx src/cli.ts proxy",
47
55
  "prepublishOnly": "node build.mjs",
48
56
  "typecheck": "tsc -p tsconfig.json --noEmit",
49
- "test": "node test/application-identities.test.mjs && node test/local-files.test.mjs && node test/cli-delegation.test.mjs && node test/sdk-pin.test.mjs && node test/skill-tool-vocabulary.test.mjs && node test/inbox-push.test.mjs && node test/contact-lines.test.mjs && node test/env-bind-identity.test.mjs && node test/proxy-exit-on-stdin-eof.test.mjs && node test/proxy-dead-stderr.test.mjs && node test/session-end-temp-cleanup.test.mjs && node test/host-profile.test.mjs && node test/container.test.mjs",
57
+ "test": "node --test test/managed-server.test.mjs && node test/application-identities.test.mjs && node test/local-files.test.mjs && node test/cli-delegation.test.mjs && node test/inbox-push.test.mjs && node test/contact-lines.test.mjs && node test/env-bind-identity.test.mjs && node test/proxy-exit-on-stdin-eof.test.mjs && node test/proxy-dead-stderr.test.mjs && node test/session-end-temp-cleanup.test.mjs && node test/host-profile.test.mjs && node test/container.test.mjs",
50
58
  "test:external-profile": "node test/native-profile-session.test.mjs && node test/external-profile-stdio-refresh.test.mjs"
51
59
  },
52
60
  "dependencies": {
53
- "@ours.network/sdk": "3.8.1-nightly.9"
61
+ "@ours.network/sdk": "3.8.1-nightly.10",
62
+ "@modelcontextprotocol/sdk": "^1.0.4",
63
+ "zod": "^3.23.8"
54
64
  },
55
65
  "devDependencies": {
56
- "@modelcontextprotocol/sdk": "^1.0.4",
57
66
  "@types/node": "^20.14.0",
58
67
  "esbuild": "^0.24.2",
59
68
  "tsx": "^4.19.0",
60
69
  "typescript": "^5.5.4",
61
- "zod": "^3.23.8",
62
- "@ours.network/cli": "2.8.1-nightly.7",
63
- "@ours.network/daemon": "3.8.1-nightly.1"
70
+ "@ours.network/cli": "2.8.1-nightly.8",
71
+ "@ours.network/daemon": "3.8.1-nightly.2"
64
72
  }
65
73
  }