macp-sdk-typescript 0.2.0
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/CHANGELOG.md +73 -0
- package/LICENSE +201 -0
- package/README.md +307 -0
- package/dist/agent/dispatcher.d.ts +16 -0
- package/dist/agent/dispatcher.js +61 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/index.js +25 -0
- package/dist/agent/participant.d.ts +38 -0
- package/dist/agent/participant.js +221 -0
- package/dist/agent/runner.d.ts +18 -0
- package/dist/agent/runner.js +84 -0
- package/dist/agent/strategies.d.ts +40 -0
- package/dist/agent/strategies.js +106 -0
- package/dist/agent/transports.d.ts +35 -0
- package/dist/agent/transports.js +125 -0
- package/dist/agent/types.d.ts +72 -0
- package/dist/agent/types.js +2 -0
- package/dist/auth.d.ts +52 -0
- package/dist/auth.js +112 -0
- package/dist/client.d.ts +171 -0
- package/dist/client.js +384 -0
- package/dist/constants.d.ts +26 -0
- package/dist/constants.js +29 -0
- package/dist/decision.d.ts +65 -0
- package/dist/decision.js +148 -0
- package/dist/envelope.d.ts +50 -0
- package/dist/envelope.js +97 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.js +114 -0
- package/dist/handoff.d.ts +73 -0
- package/dist/handoff.js +160 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +57 -0
- package/dist/policy.d.ts +76 -0
- package/dist/policy.js +118 -0
- package/dist/projections/decision.d.ts +49 -0
- package/dist/projections/decision.js +132 -0
- package/dist/projections/handoff.d.ts +28 -0
- package/dist/projections/handoff.js +111 -0
- package/dist/projections/proposal.d.ts +40 -0
- package/dist/projections/proposal.js +123 -0
- package/dist/projections/quorum.d.ts +36 -0
- package/dist/projections/quorum.js +107 -0
- package/dist/projections/task.d.ts +54 -0
- package/dist/projections/task.js +127 -0
- package/dist/projections.d.ts +5 -0
- package/dist/projections.js +21 -0
- package/dist/proposal.d.ts +69 -0
- package/dist/proposal.js +155 -0
- package/dist/proto-registry.d.ts +12 -0
- package/dist/proto-registry.js +165 -0
- package/dist/quorum.d.ts +65 -0
- package/dist/quorum.js +144 -0
- package/dist/retry.d.ts +14 -0
- package/dist/retry.js +48 -0
- package/dist/task.d.ts +73 -0
- package/dist/task.js +166 -0
- package/dist/types.d.ts +263 -0
- package/dist/types.js +2 -0
- package/dist/validation.d.ts +17 -0
- package/dist/validation.js +92 -0
- package/dist/watchers.d.ts +47 -0
- package/dist/watchers.js +176 -0
- package/package.json +72 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpTransportAdapter = exports.GrpcTransportAdapter = void 0;
|
|
4
|
+
function normalizeEnvelope(envelope, decodePayload, seq) {
|
|
5
|
+
const payload = decodePayload(envelope.mode, envelope.messageType, envelope.payload) ?? {};
|
|
6
|
+
return {
|
|
7
|
+
messageType: envelope.messageType,
|
|
8
|
+
sender: envelope.sender,
|
|
9
|
+
payload,
|
|
10
|
+
proposalId: payload.proposalId ?? payload.proposal_id,
|
|
11
|
+
raw: envelope,
|
|
12
|
+
seq,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
class GrpcTransportAdapter {
|
|
16
|
+
client;
|
|
17
|
+
sessionId;
|
|
18
|
+
auth;
|
|
19
|
+
stream = null;
|
|
20
|
+
seq = 0;
|
|
21
|
+
constructor(client, sessionId, auth) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.sessionId = sessionId;
|
|
24
|
+
this.auth = auth;
|
|
25
|
+
}
|
|
26
|
+
async *start() {
|
|
27
|
+
this.stream = this.client.openStream({ auth: this.auth });
|
|
28
|
+
for await (const envelope of this.stream.responses()) {
|
|
29
|
+
if (envelope.sessionId !== this.sessionId)
|
|
30
|
+
continue;
|
|
31
|
+
yield normalizeEnvelope(envelope, (mode, mt, p) => this.client.protoRegistry.decodeKnownPayload(mode, mt, p), this.seq++);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async stop() {
|
|
35
|
+
if (this.stream) {
|
|
36
|
+
this.stream.close();
|
|
37
|
+
this.stream = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.GrpcTransportAdapter = GrpcTransportAdapter;
|
|
42
|
+
class HttpTransportAdapter {
|
|
43
|
+
config;
|
|
44
|
+
stopped = false;
|
|
45
|
+
seq = 0;
|
|
46
|
+
lastSeq = -1;
|
|
47
|
+
constructor(config) {
|
|
48
|
+
this.config = config;
|
|
49
|
+
}
|
|
50
|
+
async *start() {
|
|
51
|
+
while (!this.stopped) {
|
|
52
|
+
try {
|
|
53
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
54
|
+
if (this.config.authToken) {
|
|
55
|
+
headers['Authorization'] = `Bearer ${this.config.authToken}`;
|
|
56
|
+
}
|
|
57
|
+
const url = `${this.config.baseUrl}/sessions/${this.config.sessionId}/events?after=${this.lastSeq}`;
|
|
58
|
+
const response = await fetch(url, { headers });
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
await this.sleep(this.config.pollIntervalMs);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const body = await response.json();
|
|
64
|
+
// Accept both Python format (JSON array of items) and
|
|
65
|
+
// TypeScript format ({ events: [{ envelope, seq }] }).
|
|
66
|
+
if (Array.isArray(body)) {
|
|
67
|
+
// Python-style: plain array of envelope-like objects
|
|
68
|
+
for (const item of body) {
|
|
69
|
+
const itemSeq = item.seq ?? this.lastSeq + 1;
|
|
70
|
+
if (itemSeq > this.lastSeq) {
|
|
71
|
+
this.lastSeq = itemSeq;
|
|
72
|
+
}
|
|
73
|
+
yield {
|
|
74
|
+
messageType: item.message_type ?? item.messageType ?? '',
|
|
75
|
+
sender: item.sender ?? '',
|
|
76
|
+
payload: typeof item.payload === 'object' && item.payload !== null
|
|
77
|
+
? item.payload
|
|
78
|
+
: this.tryParsePayload(item.payload),
|
|
79
|
+
proposalId: item.proposal_id ?? item.proposalId,
|
|
80
|
+
raw: item,
|
|
81
|
+
seq: this.seq++,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// TypeScript-style: { events: [{ envelope, seq }] }
|
|
87
|
+
const wrapped = body;
|
|
88
|
+
const events = wrapped.events ?? [];
|
|
89
|
+
for (const event of events) {
|
|
90
|
+
if (event.seq > this.lastSeq) {
|
|
91
|
+
this.lastSeq = event.seq;
|
|
92
|
+
}
|
|
93
|
+
yield {
|
|
94
|
+
messageType: event.envelope.messageType,
|
|
95
|
+
sender: event.envelope.sender,
|
|
96
|
+
payload: this.tryParsePayload(event.envelope.payload),
|
|
97
|
+
raw: event.envelope,
|
|
98
|
+
seq: this.seq++,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Ignore errors, retry after interval
|
|
105
|
+
}
|
|
106
|
+
await this.sleep(this.config.pollIntervalMs);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async stop() {
|
|
110
|
+
this.stopped = true;
|
|
111
|
+
}
|
|
112
|
+
tryParsePayload(payload) {
|
|
113
|
+
try {
|
|
114
|
+
const text = typeof payload === 'string' ? payload : Buffer.from(payload).toString('utf8');
|
|
115
|
+
return JSON.parse(text);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
sleep(ms) {
|
|
122
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.HttpTransportAdapter = HttpTransportAdapter;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Envelope } from '../types';
|
|
2
|
+
export interface IncomingMessage {
|
|
3
|
+
messageType: string;
|
|
4
|
+
sender: string;
|
|
5
|
+
payload: Record<string, unknown>;
|
|
6
|
+
proposalId?: string;
|
|
7
|
+
raw: Envelope;
|
|
8
|
+
seq?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SessionInfo {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
mode: string;
|
|
13
|
+
participants: string[];
|
|
14
|
+
modeVersion?: string;
|
|
15
|
+
configurationVersion?: string;
|
|
16
|
+
policyVersion?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionActions {
|
|
19
|
+
evaluate?(input: {
|
|
20
|
+
proposalId: string;
|
|
21
|
+
recommendation: string;
|
|
22
|
+
confidence: number;
|
|
23
|
+
reason?: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
vote?(input: {
|
|
26
|
+
proposalId: string;
|
|
27
|
+
vote: string;
|
|
28
|
+
reason?: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
raiseObjection?(input: {
|
|
31
|
+
proposalId: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
severity?: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
propose?(input: {
|
|
36
|
+
proposalId: string;
|
|
37
|
+
option: string;
|
|
38
|
+
rationale?: string;
|
|
39
|
+
supportingData?: Buffer;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
commit?(input: {
|
|
42
|
+
action: string;
|
|
43
|
+
authorityScope: string;
|
|
44
|
+
reason: string;
|
|
45
|
+
commitmentId?: string;
|
|
46
|
+
outcomePositive?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
send?(messageType: string, payload: Record<string, unknown>): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface HandlerContext {
|
|
51
|
+
participant: ParticipantLike;
|
|
52
|
+
projection: ProjectionLike;
|
|
53
|
+
actions: SessionActions;
|
|
54
|
+
session: SessionInfo;
|
|
55
|
+
log: (msg: string, details?: Record<string, unknown>) => void;
|
|
56
|
+
}
|
|
57
|
+
export interface ParticipantLike {
|
|
58
|
+
readonly participantId: string;
|
|
59
|
+
readonly sessionId: string;
|
|
60
|
+
readonly mode: string;
|
|
61
|
+
}
|
|
62
|
+
export interface ProjectionLike {
|
|
63
|
+
readonly phase: string;
|
|
64
|
+
readonly transcript: Envelope[];
|
|
65
|
+
}
|
|
66
|
+
export type MessageHandler = (event: IncomingMessage, ctx: HandlerContext) => void | Promise<void>;
|
|
67
|
+
export type TerminalHandler = (result: TerminalResult) => void | Promise<void>;
|
|
68
|
+
export type PhaseChangeHandler = (newPhase: string, ctx: HandlerContext) => void | Promise<void>;
|
|
69
|
+
export interface TerminalResult {
|
|
70
|
+
state: string;
|
|
71
|
+
commitment?: Record<string, unknown>;
|
|
72
|
+
}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as grpc from '@grpc/grpc-js';
|
|
2
|
+
export interface AuthConfig {
|
|
3
|
+
bearerToken?: string;
|
|
4
|
+
agentId?: string;
|
|
5
|
+
senderHint?: string;
|
|
6
|
+
/**
|
|
7
|
+
* The authenticated sender this credential represents. When present, the SDK
|
|
8
|
+
* refuses to emit an envelope whose `sender` differs from this value
|
|
9
|
+
* (RFC-MACP-0004 §4). Leave undefined for legacy/dev flows that want to
|
|
10
|
+
* retain the pre-0.2 permissive behavior.
|
|
11
|
+
*/
|
|
12
|
+
expectedSender?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Optional second argument to {@link Auth.bearer}. Accepts either a bare
|
|
16
|
+
* `senderHint` string (legacy) or a structured object that can also declare
|
|
17
|
+
* the authenticated identity via `expectedSender`.
|
|
18
|
+
*/
|
|
19
|
+
export type BearerAuthOptions = string | {
|
|
20
|
+
expectedSender?: string;
|
|
21
|
+
senderHint?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const Auth: {
|
|
24
|
+
/**
|
|
25
|
+
* Dev-mode agent identity. Uses the `x-macp-agent-id` header — only accepted
|
|
26
|
+
* by runtimes started with `MACP_ALLOW_DEV_SENDER_HEADER=1`. Not for
|
|
27
|
+
* production. Does not set {@link AuthConfig.expectedSender}; dev flows stay
|
|
28
|
+
* permissive so tests can reuse a single credential across senders.
|
|
29
|
+
*/
|
|
30
|
+
devAgent(agentId: string): AuthConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Production bearer-token credential. Pass `{ expectedSender }` to have the
|
|
33
|
+
* SDK refuse to emit envelopes whose `sender` differs from the authenticated
|
|
34
|
+
* identity (RFC-MACP-0004 §4).
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* Auth.bearer('tok') // legacy; no identity guard
|
|
38
|
+
* Auth.bearer('tok', 'alice') // legacy; alice is senderHint only
|
|
39
|
+
* Auth.bearer('tok', { expectedSender: 'alice' }) // strict; SDK enforces sender=='alice'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
bearer(token: string, options?: BearerAuthOptions): AuthConfig;
|
|
43
|
+
};
|
|
44
|
+
export declare function validateAuth(auth: AuthConfig): void;
|
|
45
|
+
export declare function authSender(auth?: AuthConfig): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Throw {@link MacpIdentityMismatchError} when a caller-supplied `sender`
|
|
48
|
+
* conflicts with `auth.expectedSender`. Silent when either is undefined, so
|
|
49
|
+
* dev credentials and legacy bearer usage retain pre-0.2 behavior.
|
|
50
|
+
*/
|
|
51
|
+
export declare function assertSenderMatchesIdentity(auth: AuthConfig | undefined, sender: string | undefined): void;
|
|
52
|
+
export declare function metadataFromAuth(auth: AuthConfig): grpc.Metadata;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Auth = void 0;
|
|
37
|
+
exports.validateAuth = validateAuth;
|
|
38
|
+
exports.authSender = authSender;
|
|
39
|
+
exports.assertSenderMatchesIdentity = assertSenderMatchesIdentity;
|
|
40
|
+
exports.metadataFromAuth = metadataFromAuth;
|
|
41
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
42
|
+
const errors_1 = require("./errors");
|
|
43
|
+
exports.Auth = {
|
|
44
|
+
/**
|
|
45
|
+
* Dev-mode agent identity. Uses the `x-macp-agent-id` header — only accepted
|
|
46
|
+
* by runtimes started with `MACP_ALLOW_DEV_SENDER_HEADER=1`. Not for
|
|
47
|
+
* production. Does not set {@link AuthConfig.expectedSender}; dev flows stay
|
|
48
|
+
* permissive so tests can reuse a single credential across senders.
|
|
49
|
+
*/
|
|
50
|
+
devAgent(agentId) {
|
|
51
|
+
return { agentId, senderHint: agentId };
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Production bearer-token credential. Pass `{ expectedSender }` to have the
|
|
55
|
+
* SDK refuse to emit envelopes whose `sender` differs from the authenticated
|
|
56
|
+
* identity (RFC-MACP-0004 §4).
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* Auth.bearer('tok') // legacy; no identity guard
|
|
60
|
+
* Auth.bearer('tok', 'alice') // legacy; alice is senderHint only
|
|
61
|
+
* Auth.bearer('tok', { expectedSender: 'alice' }) // strict; SDK enforces sender=='alice'
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
bearer(token, options) {
|
|
65
|
+
if (options === undefined)
|
|
66
|
+
return { bearerToken: token };
|
|
67
|
+
if (typeof options === 'string')
|
|
68
|
+
return { bearerToken: token, senderHint: options };
|
|
69
|
+
const { expectedSender, senderHint } = options;
|
|
70
|
+
return {
|
|
71
|
+
bearerToken: token,
|
|
72
|
+
expectedSender,
|
|
73
|
+
senderHint: senderHint ?? expectedSender,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
function validateAuth(auth) {
|
|
78
|
+
if (!auth.bearerToken && !auth.agentId) {
|
|
79
|
+
throw new Error('either bearerToken or agentId is required');
|
|
80
|
+
}
|
|
81
|
+
if (auth.bearerToken && auth.agentId) {
|
|
82
|
+
throw new Error('choose either bearerToken or agentId, not both');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function authSender(auth) {
|
|
86
|
+
if (!auth)
|
|
87
|
+
return undefined;
|
|
88
|
+
return auth.expectedSender ?? auth.senderHint ?? auth.agentId;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Throw {@link MacpIdentityMismatchError} when a caller-supplied `sender`
|
|
92
|
+
* conflicts with `auth.expectedSender`. Silent when either is undefined, so
|
|
93
|
+
* dev credentials and legacy bearer usage retain pre-0.2 behavior.
|
|
94
|
+
*/
|
|
95
|
+
function assertSenderMatchesIdentity(auth, sender) {
|
|
96
|
+
if (!auth?.expectedSender)
|
|
97
|
+
return;
|
|
98
|
+
if (sender === undefined)
|
|
99
|
+
return;
|
|
100
|
+
if (sender !== auth.expectedSender) {
|
|
101
|
+
throw new errors_1.MacpIdentityMismatchError(auth.expectedSender, sender);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function metadataFromAuth(auth) {
|
|
105
|
+
validateAuth(auth);
|
|
106
|
+
const metadata = new grpc.Metadata();
|
|
107
|
+
if (auth.bearerToken)
|
|
108
|
+
metadata.set('authorization', `Bearer ${auth.bearerToken}`);
|
|
109
|
+
if (auth.agentId)
|
|
110
|
+
metadata.set('x-macp-agent-id', auth.agentId);
|
|
111
|
+
return metadata;
|
|
112
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as grpc from '@grpc/grpc-js';
|
|
2
|
+
import { type AuthConfig } from './auth';
|
|
3
|
+
import { ProtoRegistry } from './proto-registry';
|
|
4
|
+
import type { Ack, AgentManifest, Envelope, InitializeResult, ModeDescriptor, PolicyDescriptor, SessionMetadata, Root } from './types';
|
|
5
|
+
interface MacpClientOptions {
|
|
6
|
+
address: string;
|
|
7
|
+
/**
|
|
8
|
+
* Use TLS credentials. Defaults to `true` per RFC-MACP-0006 §3. Pass
|
|
9
|
+
* `secure: false` together with {@link MacpClientOptions.allowInsecure}
|
|
10
|
+
* `true` for local development against an insecure runtime.
|
|
11
|
+
*/
|
|
12
|
+
secure?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Opt out of the secure-by-default guard. Must be set to `true` whenever
|
|
15
|
+
* `secure` is `false`; otherwise the constructor throws. Intentionally
|
|
16
|
+
* verbose so agents never ship to production with TLS off by accident.
|
|
17
|
+
*/
|
|
18
|
+
allowInsecure?: boolean;
|
|
19
|
+
auth?: AuthConfig;
|
|
20
|
+
rootCertificates?: Buffer;
|
|
21
|
+
defaultDeadlineMs?: number;
|
|
22
|
+
clientName?: string;
|
|
23
|
+
clientVersion?: string;
|
|
24
|
+
protoDir?: string;
|
|
25
|
+
}
|
|
26
|
+
export type InlineErrorCallback = (error: {
|
|
27
|
+
code?: string;
|
|
28
|
+
message?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
export declare class MacpStream {
|
|
31
|
+
private readonly call;
|
|
32
|
+
private readonly queue;
|
|
33
|
+
private closed;
|
|
34
|
+
private readonly inlineErrorCallbacks;
|
|
35
|
+
constructor(call: grpc.ClientDuplexStream<any, any>);
|
|
36
|
+
onInlineError(callback: InlineErrorCallback): void;
|
|
37
|
+
send(envelope: Envelope): Promise<void>;
|
|
38
|
+
responses(): AsyncGenerator<Envelope, void, void>;
|
|
39
|
+
close(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare class MacpClient {
|
|
42
|
+
readonly auth?: AuthConfig;
|
|
43
|
+
readonly protoRegistry: ProtoRegistry;
|
|
44
|
+
private readonly client;
|
|
45
|
+
private readonly secure;
|
|
46
|
+
private readonly defaultDeadlineMs?;
|
|
47
|
+
private readonly clientName;
|
|
48
|
+
private readonly clientVersion;
|
|
49
|
+
constructor(options: MacpClientOptions);
|
|
50
|
+
private requireAuth;
|
|
51
|
+
private metadata;
|
|
52
|
+
private deadline;
|
|
53
|
+
private unary;
|
|
54
|
+
initialize(deadlineMs?: number): Promise<InitializeResult>;
|
|
55
|
+
send(envelope: Envelope, options?: {
|
|
56
|
+
auth?: AuthConfig;
|
|
57
|
+
deadlineMs?: number;
|
|
58
|
+
raiseOnNack?: boolean;
|
|
59
|
+
}): Promise<Ack>;
|
|
60
|
+
getSession(sessionId: string, options?: {
|
|
61
|
+
auth?: AuthConfig;
|
|
62
|
+
deadlineMs?: number;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
metadata: SessionMetadata;
|
|
65
|
+
}>;
|
|
66
|
+
cancelSession(sessionId: string, reason: string, options?: {
|
|
67
|
+
auth?: AuthConfig;
|
|
68
|
+
deadlineMs?: number;
|
|
69
|
+
raiseOnNack?: boolean;
|
|
70
|
+
cancelledBy?: string;
|
|
71
|
+
}): Promise<Ack>;
|
|
72
|
+
getManifest(agentId?: string, deadlineMs?: number): Promise<{
|
|
73
|
+
manifest: AgentManifest;
|
|
74
|
+
}>;
|
|
75
|
+
listModes(deadlineMs?: number): Promise<{
|
|
76
|
+
modes: ModeDescriptor[];
|
|
77
|
+
}>;
|
|
78
|
+
listExtModes(deadlineMs?: number): Promise<{
|
|
79
|
+
modes: ModeDescriptor[];
|
|
80
|
+
}>;
|
|
81
|
+
listRoots(deadlineMs?: number): Promise<{
|
|
82
|
+
roots: Root[];
|
|
83
|
+
}>;
|
|
84
|
+
registerExtMode(descriptor: ModeDescriptor, options?: {
|
|
85
|
+
auth?: AuthConfig;
|
|
86
|
+
deadlineMs?: number;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ok: boolean;
|
|
89
|
+
error?: string;
|
|
90
|
+
}>;
|
|
91
|
+
unregisterExtMode(mode: string, options?: {
|
|
92
|
+
auth?: AuthConfig;
|
|
93
|
+
deadlineMs?: number;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
ok: boolean;
|
|
96
|
+
error?: string;
|
|
97
|
+
}>;
|
|
98
|
+
promoteMode(mode: string, promotedModeName?: string, options?: {
|
|
99
|
+
auth?: AuthConfig;
|
|
100
|
+
deadlineMs?: number;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
ok: boolean;
|
|
103
|
+
error?: string;
|
|
104
|
+
mode?: string;
|
|
105
|
+
}>;
|
|
106
|
+
registerPolicy(descriptor: PolicyDescriptor, options?: {
|
|
107
|
+
auth?: AuthConfig;
|
|
108
|
+
deadlineMs?: number;
|
|
109
|
+
}): Promise<{
|
|
110
|
+
ok: boolean;
|
|
111
|
+
error?: string;
|
|
112
|
+
}>;
|
|
113
|
+
unregisterPolicy(policyId: string, options?: {
|
|
114
|
+
auth?: AuthConfig;
|
|
115
|
+
deadlineMs?: number;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
ok: boolean;
|
|
118
|
+
error?: string;
|
|
119
|
+
}>;
|
|
120
|
+
getPolicy(policyId: string, options?: {
|
|
121
|
+
auth?: AuthConfig;
|
|
122
|
+
deadlineMs?: number;
|
|
123
|
+
}): Promise<PolicyDescriptor>;
|
|
124
|
+
listPolicies(mode?: string, options?: {
|
|
125
|
+
auth?: AuthConfig;
|
|
126
|
+
deadlineMs?: number;
|
|
127
|
+
}): Promise<PolicyDescriptor[]>;
|
|
128
|
+
watchPolicies(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
129
|
+
/** @deprecated Use {@link watchPolicies}. Scheduled for removal in 0.4.0. */
|
|
130
|
+
_watchPolicies(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
131
|
+
openStream(options?: {
|
|
132
|
+
auth?: AuthConfig;
|
|
133
|
+
}): MacpStream;
|
|
134
|
+
watchModeRegistry(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
135
|
+
watchRoots(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
136
|
+
watchSignals(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use {@link watchModeRegistry}, {@link watchRoots},
|
|
139
|
+
* {@link watchSignals}. Scheduled for removal in 0.4.0 — the underscored
|
|
140
|
+
* aliases were kept while `src/watchers.ts` migrated.
|
|
141
|
+
*/
|
|
142
|
+
_watchModeRegistry(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
143
|
+
/** @deprecated Use {@link watchRoots}. Scheduled for removal in 0.4.0. */
|
|
144
|
+
_watchRoots(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
145
|
+
/** @deprecated Use {@link watchSignals}. Scheduled for removal in 0.4.0. */
|
|
146
|
+
_watchSignals(auth?: AuthConfig): grpc.ClientReadableStream<any>;
|
|
147
|
+
sendSignal(options: {
|
|
148
|
+
signalType: string;
|
|
149
|
+
data?: Buffer;
|
|
150
|
+
confidence?: number;
|
|
151
|
+
correlationSessionId?: string;
|
|
152
|
+
sender?: string;
|
|
153
|
+
auth?: AuthConfig;
|
|
154
|
+
deadlineMs?: number;
|
|
155
|
+
}): Promise<Ack>;
|
|
156
|
+
sendProgress(options: {
|
|
157
|
+
sessionId?: string;
|
|
158
|
+
mode?: string;
|
|
159
|
+
progressToken: string;
|
|
160
|
+
progress: number;
|
|
161
|
+
total: number;
|
|
162
|
+
message?: string;
|
|
163
|
+
targetMessageId?: string;
|
|
164
|
+
sender?: string;
|
|
165
|
+
auth?: AuthConfig;
|
|
166
|
+
deadlineMs?: number;
|
|
167
|
+
}): Promise<Ack>;
|
|
168
|
+
senderHint(auth?: AuthConfig): string | undefined;
|
|
169
|
+
close(): void;
|
|
170
|
+
}
|
|
171
|
+
export {};
|