macp-sdk-typescript 0.2.2 → 0.4.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 +176 -1
- package/README.md +49 -6
- package/dist/agent/cancel-callback.d.ts +23 -0
- package/dist/agent/cancel-callback.js +108 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +1 -0
- package/dist/agent/participant.d.ts +39 -0
- package/dist/agent/participant.js +114 -45
- package/dist/agent/runner.d.ts +13 -0
- package/dist/agent/runner.js +34 -0
- package/dist/agent/strategies.d.ts +2 -0
- package/dist/agent/strategies.js +8 -0
- package/dist/agent/transports.js +5 -0
- package/dist/base-session.d.ts +75 -0
- package/dist/base-session.js +127 -0
- package/dist/client.d.ts +54 -0
- package/dist/client.js +130 -9
- package/dist/constants.d.ts +21 -16
- package/dist/constants.js +24 -17
- package/dist/decision.d.ts +10 -0
- package/dist/decision.js +20 -0
- package/dist/envelope.d.ts +38 -1
- package/dist/envelope.js +53 -1
- package/dist/errors.d.ts +17 -4
- package/dist/errors.js +19 -10
- package/dist/handoff.d.ts +10 -8
- package/dist/handoff.js +20 -16
- package/dist/index.d.ts +3 -1
- package/dist/index.js +10 -2
- package/dist/logging.d.ts +21 -0
- package/dist/logging.js +64 -0
- package/dist/policy.d.ts +47 -42
- package/dist/policy.js +5 -6
- package/dist/projections/base.d.ts +20 -0
- package/dist/projections/base.js +37 -0
- package/dist/projections.d.ts +1 -0
- package/dist/projections.js +1 -0
- package/dist/proposal.d.ts +10 -0
- package/dist/proposal.js +20 -0
- package/dist/quorum.d.ts +10 -0
- package/dist/quorum.js +20 -0
- package/dist/task.d.ts +14 -4
- package/dist/task.js +24 -4
- package/dist/types.d.ts +30 -3
- package/dist/watchers.d.ts +37 -2
- package/dist/watchers.js +65 -5
- package/package.json +2 -2
package/dist/handoff.js
CHANGED
|
@@ -6,14 +6,6 @@ const constants_1 = require("./constants");
|
|
|
6
6
|
const envelope_1 = require("./envelope");
|
|
7
7
|
const handoff_1 = require("./projections/handoff");
|
|
8
8
|
const validation_1 = require("./validation");
|
|
9
|
-
let sendContextWarned = false;
|
|
10
|
-
function warnSendContextOnce() {
|
|
11
|
-
if (sendContextWarned)
|
|
12
|
-
return;
|
|
13
|
-
sendContextWarned = true;
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.warn('[macp-sdk-typescript] HandoffSession.sendContext() is deprecated and will be removed in 0.4.0. Use addContext() instead.');
|
|
16
|
-
}
|
|
17
9
|
class HandoffSession {
|
|
18
10
|
client;
|
|
19
11
|
sessionId;
|
|
@@ -95,14 +87,6 @@ class HandoffSession {
|
|
|
95
87
|
});
|
|
96
88
|
return this.sendAndTrack(envelope, input.auth);
|
|
97
89
|
}
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated Use {@link addContext} instead. Scheduled for removal in 0.4.0.
|
|
100
|
-
* First call logs a one-shot warning to guide migrations without spamming long-lived processes.
|
|
101
|
-
*/
|
|
102
|
-
async sendContext(input) {
|
|
103
|
-
warnSendContextOnce();
|
|
104
|
-
return this.addContext(input);
|
|
105
|
-
}
|
|
106
90
|
async acceptHandoff(input) {
|
|
107
91
|
(0, validation_1.validateRequiredField)('handoffId', input.handoffId);
|
|
108
92
|
const envelope = (0, envelope_1.buildEnvelope)({
|
|
@@ -154,6 +138,26 @@ class HandoffSession {
|
|
|
154
138
|
raiseOnNack: true,
|
|
155
139
|
});
|
|
156
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
143
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
144
|
+
*/
|
|
145
|
+
async suspend(reason = '', auth) {
|
|
146
|
+
return this.client.suspendSession(this.sessionId, reason, {
|
|
147
|
+
auth: auth ?? this.auth,
|
|
148
|
+
raiseOnNack: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
153
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
154
|
+
*/
|
|
155
|
+
async resume(reason = '', auth) {
|
|
156
|
+
return this.client.resumeSession(this.sessionId, reason, {
|
|
157
|
+
auth: auth ?? this.auth,
|
|
158
|
+
raiseOnNack: true,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
157
161
|
openStream(auth) {
|
|
158
162
|
return this.client.openStream({ auth: auth ?? this.auth });
|
|
159
163
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Auth, type AuthConfig, type BearerAuthOptions } from './auth';
|
|
2
|
+
export * from './base-session';
|
|
2
3
|
export * from './client';
|
|
3
4
|
export * from './constants';
|
|
4
5
|
export * from './decision';
|
|
5
6
|
export * from './envelope';
|
|
6
7
|
export * from './errors';
|
|
7
8
|
export * from './handoff';
|
|
9
|
+
export * from './logging';
|
|
8
10
|
export * from './policy';
|
|
9
11
|
export * from './projections';
|
|
10
12
|
export * from './proposal';
|
package/dist/index.js
CHANGED
|
@@ -36,14 +36,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.agent = void 0;
|
|
40
|
-
|
|
39
|
+
exports.agent = exports.Auth = void 0;
|
|
40
|
+
// Auth: export only the public constructors and types. The helpers
|
|
41
|
+
// `validateAuth`, `authSender`, `assertSenderMatchesIdentity`, and
|
|
42
|
+
// `metadataFromAuth` are SDK-internal — importable from the `./auth`
|
|
43
|
+
// submodule if needed, but intentionally absent from the top-level surface
|
|
44
|
+
// to match python-sdk's `__all__` (which only exposes `AuthConfig`).
|
|
45
|
+
var auth_1 = require("./auth");
|
|
46
|
+
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return auth_1.Auth; } });
|
|
47
|
+
__exportStar(require("./base-session"), exports);
|
|
41
48
|
__exportStar(require("./client"), exports);
|
|
42
49
|
__exportStar(require("./constants"), exports);
|
|
43
50
|
__exportStar(require("./decision"), exports);
|
|
44
51
|
__exportStar(require("./envelope"), exports);
|
|
45
52
|
__exportStar(require("./errors"), exports);
|
|
46
53
|
__exportStar(require("./handoff"), exports);
|
|
54
|
+
__exportStar(require("./logging"), exports);
|
|
47
55
|
__exportStar(require("./policy"), exports);
|
|
48
56
|
__exportStar(require("./projections"), exports);
|
|
49
57
|
__exportStar(require("./proposal"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logger for the MACP SDK.
|
|
3
|
+
*
|
|
4
|
+
* Parity with python-sdk's `macp_sdk._logging.logger` + `configure_logging()`:
|
|
5
|
+
* production Node apps need controllable log levels (silent by default-ish,
|
|
6
|
+
* opt-in verbose) and the ability to re-route to Pino / Winston / etc.
|
|
7
|
+
*/
|
|
8
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
9
|
+
export type LogSink = (level: Exclude<LogLevel, 'silent'>, args: unknown[]) => void;
|
|
10
|
+
export declare const logger: {
|
|
11
|
+
error: (...args: unknown[]) => void;
|
|
12
|
+
warn: (...args: unknown[]) => void;
|
|
13
|
+
info: (...args: unknown[]) => void;
|
|
14
|
+
debug: (...args: unknown[]) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function configureLogging(options: {
|
|
17
|
+
level?: LogLevel;
|
|
18
|
+
sink?: LogSink;
|
|
19
|
+
}): void;
|
|
20
|
+
/** Test-only: reset to env-derived level + default sink. */
|
|
21
|
+
export declare function _resetLoggingForTests(): void;
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Structured logger for the MACP SDK.
|
|
4
|
+
*
|
|
5
|
+
* Parity with python-sdk's `macp_sdk._logging.logger` + `configure_logging()`:
|
|
6
|
+
* production Node apps need controllable log levels (silent by default-ish,
|
|
7
|
+
* opt-in verbose) and the ability to re-route to Pino / Winston / etc.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.logger = void 0;
|
|
11
|
+
exports.configureLogging = configureLogging;
|
|
12
|
+
exports._resetLoggingForTests = _resetLoggingForTests;
|
|
13
|
+
const LEVEL_ORDER = {
|
|
14
|
+
silent: 0,
|
|
15
|
+
error: 1,
|
|
16
|
+
warn: 2,
|
|
17
|
+
info: 3,
|
|
18
|
+
debug: 4,
|
|
19
|
+
};
|
|
20
|
+
const defaultSink = (level, args) => {
|
|
21
|
+
const method = level === 'debug' || level === 'info' ? 'log' : level;
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
(console[method] ?? console.log)('[macp-sdk]', ...args);
|
|
24
|
+
};
|
|
25
|
+
function envLevel() {
|
|
26
|
+
const raw = typeof process !== 'undefined' ? process.env?.MACP_LOG_LEVEL?.toLowerCase() : undefined;
|
|
27
|
+
if (raw && raw in LEVEL_ORDER)
|
|
28
|
+
return raw;
|
|
29
|
+
return 'warn';
|
|
30
|
+
}
|
|
31
|
+
const state = {
|
|
32
|
+
level: envLevel(),
|
|
33
|
+
sink: defaultSink,
|
|
34
|
+
};
|
|
35
|
+
function shouldLog(level) {
|
|
36
|
+
return LEVEL_ORDER[state.level] >= LEVEL_ORDER[level];
|
|
37
|
+
}
|
|
38
|
+
function emit(level, args) {
|
|
39
|
+
if (!shouldLog(level))
|
|
40
|
+
return;
|
|
41
|
+
state.sink(level, args);
|
|
42
|
+
}
|
|
43
|
+
exports.logger = {
|
|
44
|
+
error: (...args) => emit('error', args),
|
|
45
|
+
warn: (...args) => emit('warn', args),
|
|
46
|
+
info: (...args) => emit('info', args),
|
|
47
|
+
debug: (...args) => emit('debug', args),
|
|
48
|
+
};
|
|
49
|
+
function configureLogging(options) {
|
|
50
|
+
if (options.level !== undefined) {
|
|
51
|
+
if (!(options.level in LEVEL_ORDER)) {
|
|
52
|
+
throw new Error(`configureLogging: unknown level "${options.level}"`);
|
|
53
|
+
}
|
|
54
|
+
state.level = options.level;
|
|
55
|
+
}
|
|
56
|
+
if (options.sink !== undefined) {
|
|
57
|
+
state.sink = options.sink;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Test-only: reset to env-derived level + default sink. */
|
|
61
|
+
function _resetLoggingForTests() {
|
|
62
|
+
state.level = envLevel();
|
|
63
|
+
state.sink = defaultSink;
|
|
64
|
+
}
|
package/dist/policy.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { PolicyDescriptor } from './types';
|
|
2
|
-
export interface
|
|
2
|
+
export interface CommitmentRules {
|
|
3
3
|
authority?: 'initiator_only' | 'any_participant' | 'designated_role';
|
|
4
4
|
designatedRoles?: string[];
|
|
5
|
+
/** Decision-specific: require quorum before commit. Ignored for other modes. */
|
|
6
|
+
requireVoteQuorum?: boolean;
|
|
5
7
|
}
|
|
6
|
-
export interface
|
|
8
|
+
export interface VotingRules {
|
|
7
9
|
algorithm?: 'none' | 'majority' | 'supermajority' | 'unanimous' | 'weighted' | 'plurality';
|
|
8
10
|
threshold?: number;
|
|
9
11
|
quorum?: {
|
|
@@ -12,62 +14,65 @@ export interface DecisionVotingRules {
|
|
|
12
14
|
};
|
|
13
15
|
weights?: Record<string, number>;
|
|
14
16
|
}
|
|
15
|
-
export interface
|
|
17
|
+
export interface ObjectionHandlingRules {
|
|
16
18
|
criticalSeverityVetoes?: boolean;
|
|
17
19
|
vetoThreshold?: number;
|
|
18
20
|
}
|
|
19
|
-
export interface
|
|
21
|
+
export interface EvaluationRules {
|
|
20
22
|
minimumConfidence?: number;
|
|
21
23
|
requiredBeforeVoting?: boolean;
|
|
22
24
|
}
|
|
23
|
-
export interface
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
export interface QuorumThreshold {
|
|
26
|
+
type: 'n_of_m' | 'percentage' | 'weighted';
|
|
27
|
+
value: number;
|
|
28
|
+
}
|
|
29
|
+
export interface AbstentionRules {
|
|
30
|
+
countsTowardQuorum?: boolean;
|
|
31
|
+
interpretation?: 'neutral' | 'implicit_reject' | 'ignored';
|
|
32
|
+
}
|
|
33
|
+
export interface ProposalAcceptanceRules {
|
|
34
|
+
criterion?: 'all_parties' | 'counterparty' | 'initiator';
|
|
35
|
+
}
|
|
36
|
+
export interface CounterProposalRules {
|
|
37
|
+
maxRounds?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface RejectionRules {
|
|
40
|
+
terminalOnAnyReject?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface TaskAssignmentRules {
|
|
43
|
+
allowReassignmentOnReject?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface TaskCompletionRules {
|
|
46
|
+
requireOutput?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface HandoffAcceptanceRules {
|
|
49
|
+
implicitAcceptTimeoutMs?: number;
|
|
27
50
|
}
|
|
28
51
|
export interface DecisionPolicyRulesInput {
|
|
29
|
-
voting?:
|
|
30
|
-
objectionHandling?:
|
|
31
|
-
evaluation?:
|
|
32
|
-
commitment?:
|
|
52
|
+
voting?: VotingRules;
|
|
53
|
+
objectionHandling?: ObjectionHandlingRules;
|
|
54
|
+
evaluation?: EvaluationRules;
|
|
55
|
+
commitment?: CommitmentRules;
|
|
33
56
|
}
|
|
34
57
|
export interface QuorumPolicyRulesInput {
|
|
35
|
-
threshold?:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
abstention?: {
|
|
40
|
-
countsTowardQuorum?: boolean;
|
|
41
|
-
interpretation?: 'neutral' | 'implicit_reject' | 'ignored';
|
|
42
|
-
};
|
|
43
|
-
commitment?: CommitmentRulesInput;
|
|
58
|
+
threshold?: QuorumThreshold;
|
|
59
|
+
abstention?: AbstentionRules;
|
|
60
|
+
commitment?: CommitmentRules;
|
|
44
61
|
}
|
|
45
62
|
export interface ProposalPolicyRulesInput {
|
|
46
|
-
acceptance?:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
maxRounds?: number;
|
|
51
|
-
};
|
|
52
|
-
rejection?: {
|
|
53
|
-
terminalOnAnyReject?: boolean;
|
|
54
|
-
};
|
|
55
|
-
commitment?: CommitmentRulesInput;
|
|
63
|
+
acceptance?: ProposalAcceptanceRules;
|
|
64
|
+
counterProposal?: CounterProposalRules;
|
|
65
|
+
rejection?: RejectionRules;
|
|
66
|
+
commitment?: CommitmentRules;
|
|
56
67
|
}
|
|
57
68
|
export interface TaskPolicyRulesInput {
|
|
58
|
-
assignment?:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
completion?: {
|
|
62
|
-
requireOutput?: boolean;
|
|
63
|
-
};
|
|
64
|
-
commitment?: CommitmentRulesInput;
|
|
69
|
+
assignment?: TaskAssignmentRules;
|
|
70
|
+
completion?: TaskCompletionRules;
|
|
71
|
+
commitment?: CommitmentRules;
|
|
65
72
|
}
|
|
66
73
|
export interface HandoffPolicyRulesInput {
|
|
67
|
-
acceptance?:
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
commitment?: CommitmentRulesInput;
|
|
74
|
+
acceptance?: HandoffAcceptanceRules;
|
|
75
|
+
commitment?: CommitmentRules;
|
|
71
76
|
}
|
|
72
77
|
export declare function buildDecisionPolicy(policyId: string, description: string, rules: DecisionPolicyRulesInput): PolicyDescriptor;
|
|
73
78
|
export declare function buildQuorumPolicy(policyId: string, description: string, rules: QuorumPolicyRulesInput): PolicyDescriptor;
|
package/dist/policy.js
CHANGED
|
@@ -5,13 +5,16 @@ exports.buildQuorumPolicy = buildQuorumPolicy;
|
|
|
5
5
|
exports.buildProposalPolicy = buildProposalPolicy;
|
|
6
6
|
exports.buildTaskPolicy = buildTaskPolicy;
|
|
7
7
|
exports.buildHandoffPolicy = buildHandoffPolicy;
|
|
8
|
+
// ── Builder helpers ─────────────────────────────────────────────────
|
|
8
9
|
function serializeCommitment(commitment) {
|
|
9
10
|
return {
|
|
10
11
|
authority: commitment?.authority ?? 'initiator_only',
|
|
11
12
|
designated_roles: commitment?.designatedRoles ?? [],
|
|
13
|
+
// Parity with python-sdk `_commitment_dict`: emitted for every mode, not
|
|
14
|
+
// just decision, so policy JSON is byte-identical across SDKs.
|
|
15
|
+
require_vote_quorum: commitment?.requireVoteQuorum ?? false,
|
|
12
16
|
};
|
|
13
17
|
}
|
|
14
|
-
// ── Builder helpers ─────────────────────────────────────────────────
|
|
15
18
|
function buildDecisionPolicy(policyId, description, rules) {
|
|
16
19
|
const rulesJson = {
|
|
17
20
|
voting: {
|
|
@@ -28,11 +31,7 @@ function buildDecisionPolicy(policyId, description, rules) {
|
|
|
28
31
|
minimum_confidence: rules.evaluation?.minimumConfidence ?? 0,
|
|
29
32
|
required_before_voting: rules.evaluation?.requiredBeforeVoting ?? false,
|
|
30
33
|
},
|
|
31
|
-
commitment:
|
|
32
|
-
authority: rules.commitment?.authority ?? 'initiator_only',
|
|
33
|
-
designated_roles: rules.commitment?.designatedRoles ?? [],
|
|
34
|
-
require_vote_quorum: rules.commitment?.requireVoteQuorum ?? false,
|
|
35
|
-
},
|
|
34
|
+
commitment: serializeCommitment(rules.commitment),
|
|
36
35
|
};
|
|
37
36
|
return {
|
|
38
37
|
policyId,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProtoRegistry } from '../proto-registry';
|
|
2
|
+
import type { Envelope } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base for in-process mode-state tracking — parity with python-sdk's
|
|
5
|
+
* `macp_sdk.base_projection.BaseProjection`. Maintains a shared transcript,
|
|
6
|
+
* phase string, and commitment payload; subclasses override `applyMode`
|
|
7
|
+
* to handle mode-specific envelopes. `SessionStart` and `Commitment` are
|
|
8
|
+
* handled here so custom modes get the common lifecycle for free.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class BaseProjection {
|
|
11
|
+
readonly transcript: Envelope[];
|
|
12
|
+
phase: string;
|
|
13
|
+
commitment?: Record<string, unknown>;
|
|
14
|
+
protected abstract readonly mode: string;
|
|
15
|
+
get isCommitted(): boolean;
|
|
16
|
+
get isPositiveOutcome(): boolean | undefined;
|
|
17
|
+
applyEnvelope(envelope: Envelope, protoRegistry: ProtoRegistry): void;
|
|
18
|
+
/** Handle a mode-specific (non-Commitment) envelope. */
|
|
19
|
+
protected abstract applyMode(envelope: Envelope, protoRegistry: ProtoRegistry): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseProjection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base for in-process mode-state tracking — parity with python-sdk's
|
|
6
|
+
* `macp_sdk.base_projection.BaseProjection`. Maintains a shared transcript,
|
|
7
|
+
* phase string, and commitment payload; subclasses override `applyMode`
|
|
8
|
+
* to handle mode-specific envelopes. `SessionStart` and `Commitment` are
|
|
9
|
+
* handled here so custom modes get the common lifecycle for free.
|
|
10
|
+
*/
|
|
11
|
+
class BaseProjection {
|
|
12
|
+
transcript = [];
|
|
13
|
+
phase = '';
|
|
14
|
+
commitment;
|
|
15
|
+
get isCommitted() {
|
|
16
|
+
return this.commitment !== undefined;
|
|
17
|
+
}
|
|
18
|
+
get isPositiveOutcome() {
|
|
19
|
+
if (!this.commitment)
|
|
20
|
+
return undefined;
|
|
21
|
+
const val = this.commitment.outcomePositive ??
|
|
22
|
+
this.commitment.outcome_positive;
|
|
23
|
+
return val !== undefined ? Boolean(val) : true;
|
|
24
|
+
}
|
|
25
|
+
applyEnvelope(envelope, protoRegistry) {
|
|
26
|
+
if (envelope.mode !== this.mode)
|
|
27
|
+
return;
|
|
28
|
+
this.transcript.push(envelope);
|
|
29
|
+
if (envelope.messageType === 'Commitment') {
|
|
30
|
+
this.commitment = protoRegistry.decodeKnownPayload(envelope.mode, envelope.messageType, envelope.payload);
|
|
31
|
+
this.phase = 'Committed';
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.applyMode(envelope, protoRegistry);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BaseProjection = BaseProjection;
|
package/dist/projections.d.ts
CHANGED
package/dist/projections.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./projections/base"), exports);
|
|
17
18
|
__exportStar(require("./projections/decision"), exports);
|
|
18
19
|
__exportStar(require("./projections/proposal"), exports);
|
|
19
20
|
__exportStar(require("./projections/task"), exports);
|
package/dist/proposal.d.ts
CHANGED
|
@@ -65,6 +65,16 @@ export declare class ProposalSession {
|
|
|
65
65
|
metadata: SessionMetadata;
|
|
66
66
|
}>;
|
|
67
67
|
cancel(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
68
|
+
/**
|
|
69
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
70
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
71
|
+
*/
|
|
72
|
+
suspend(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
73
|
+
/**
|
|
74
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
75
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
76
|
+
*/
|
|
77
|
+
resume(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
68
78
|
openStream(auth?: AuthConfig): MacpStream;
|
|
69
79
|
}
|
|
70
80
|
export {};
|
package/dist/proposal.js
CHANGED
|
@@ -149,6 +149,26 @@ class ProposalSession {
|
|
|
149
149
|
raiseOnNack: true,
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
154
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
155
|
+
*/
|
|
156
|
+
async suspend(reason = '', auth) {
|
|
157
|
+
return this.client.suspendSession(this.sessionId, reason, {
|
|
158
|
+
auth: auth ?? this.auth,
|
|
159
|
+
raiseOnNack: true,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
164
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
165
|
+
*/
|
|
166
|
+
async resume(reason = '', auth) {
|
|
167
|
+
return this.client.resumeSession(this.sessionId, reason, {
|
|
168
|
+
auth: auth ?? this.auth,
|
|
169
|
+
raiseOnNack: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
152
172
|
openStream(auth) {
|
|
153
173
|
return this.client.openStream({ auth: auth ?? this.auth });
|
|
154
174
|
}
|
package/dist/quorum.d.ts
CHANGED
|
@@ -61,6 +61,16 @@ export declare class QuorumSession {
|
|
|
61
61
|
metadata: SessionMetadata;
|
|
62
62
|
}>;
|
|
63
63
|
cancel(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
64
|
+
/**
|
|
65
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
66
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
67
|
+
*/
|
|
68
|
+
suspend(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
69
|
+
/**
|
|
70
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
71
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
72
|
+
*/
|
|
73
|
+
resume(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
64
74
|
openStream(auth?: AuthConfig): MacpStream;
|
|
65
75
|
}
|
|
66
76
|
export {};
|
package/dist/quorum.js
CHANGED
|
@@ -138,6 +138,26 @@ class QuorumSession {
|
|
|
138
138
|
raiseOnNack: true,
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
143
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
144
|
+
*/
|
|
145
|
+
async suspend(reason = '', auth) {
|
|
146
|
+
return this.client.suspendSession(this.sessionId, reason, {
|
|
147
|
+
auth: auth ?? this.auth,
|
|
148
|
+
raiseOnNack: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
153
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
154
|
+
*/
|
|
155
|
+
async resume(reason = '', auth) {
|
|
156
|
+
return this.client.resumeSession(this.sessionId, reason, {
|
|
157
|
+
auth: auth ?? this.auth,
|
|
158
|
+
raiseOnNack: true,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
141
161
|
openStream(auth) {
|
|
142
162
|
return this.client.openStream({ auth: auth ?? this.auth });
|
|
143
163
|
}
|
package/dist/task.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class TaskSession {
|
|
|
32
32
|
}[];
|
|
33
33
|
sender?: string;
|
|
34
34
|
}): Promise<Ack>;
|
|
35
|
-
|
|
35
|
+
requestTask(input: TaskRequestPayload & {
|
|
36
36
|
sender?: string;
|
|
37
37
|
auth?: AuthConfig;
|
|
38
38
|
}): Promise<Ack>;
|
|
@@ -44,15 +44,15 @@ export declare class TaskSession {
|
|
|
44
44
|
sender?: string;
|
|
45
45
|
auth?: AuthConfig;
|
|
46
46
|
}): Promise<Ack>;
|
|
47
|
-
|
|
47
|
+
updateTask(input: TaskUpdatePayload & {
|
|
48
48
|
sender?: string;
|
|
49
49
|
auth?: AuthConfig;
|
|
50
50
|
}): Promise<Ack>;
|
|
51
|
-
|
|
51
|
+
completeTask(input: TaskCompletePayload & {
|
|
52
52
|
sender?: string;
|
|
53
53
|
auth?: AuthConfig;
|
|
54
54
|
}): Promise<Ack>;
|
|
55
|
-
|
|
55
|
+
failTask(input: TaskFailPayload & {
|
|
56
56
|
sender?: string;
|
|
57
57
|
auth?: AuthConfig;
|
|
58
58
|
}): Promise<Ack>;
|
|
@@ -69,6 +69,16 @@ export declare class TaskSession {
|
|
|
69
69
|
metadata: SessionMetadata;
|
|
70
70
|
}>;
|
|
71
71
|
cancel(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
72
|
+
/**
|
|
73
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
74
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
75
|
+
*/
|
|
76
|
+
suspend(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
77
|
+
/**
|
|
78
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
79
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
80
|
+
*/
|
|
81
|
+
resume(reason?: string, auth?: AuthConfig): Promise<Ack>;
|
|
72
82
|
openStream(auth?: AuthConfig): MacpStream;
|
|
73
83
|
}
|
|
74
84
|
export {};
|
package/dist/task.js
CHANGED
|
@@ -63,7 +63,7 @@ class TaskSession {
|
|
|
63
63
|
});
|
|
64
64
|
return this.sendAndTrack(envelope, this.auth);
|
|
65
65
|
}
|
|
66
|
-
async
|
|
66
|
+
async requestTask(input) {
|
|
67
67
|
(0, validation_1.validateRequiredField)('taskId', input.taskId);
|
|
68
68
|
(0, validation_1.validateRequiredField)('title', input.title);
|
|
69
69
|
(0, validation_1.validateRequiredField)('instructions', input.instructions);
|
|
@@ -98,7 +98,7 @@ class TaskSession {
|
|
|
98
98
|
});
|
|
99
99
|
return this.sendAndTrack(envelope, input.auth);
|
|
100
100
|
}
|
|
101
|
-
async
|
|
101
|
+
async updateTask(input) {
|
|
102
102
|
(0, validation_1.validateRequiredField)('taskId', input.taskId);
|
|
103
103
|
const envelope = (0, envelope_1.buildEnvelope)({
|
|
104
104
|
mode: constants_1.MODE_TASK,
|
|
@@ -109,7 +109,7 @@ class TaskSession {
|
|
|
109
109
|
});
|
|
110
110
|
return this.sendAndTrack(envelope, input.auth);
|
|
111
111
|
}
|
|
112
|
-
async
|
|
112
|
+
async completeTask(input) {
|
|
113
113
|
(0, validation_1.validateRequiredField)('taskId', input.taskId);
|
|
114
114
|
const envelope = (0, envelope_1.buildEnvelope)({
|
|
115
115
|
mode: constants_1.MODE_TASK,
|
|
@@ -120,7 +120,7 @@ class TaskSession {
|
|
|
120
120
|
});
|
|
121
121
|
return this.sendAndTrack(envelope, input.auth);
|
|
122
122
|
}
|
|
123
|
-
async
|
|
123
|
+
async failTask(input) {
|
|
124
124
|
(0, validation_1.validateRequiredField)('taskId', input.taskId);
|
|
125
125
|
const envelope = (0, envelope_1.buildEnvelope)({
|
|
126
126
|
mode: constants_1.MODE_TASK,
|
|
@@ -160,6 +160,26 @@ class TaskSession {
|
|
|
160
160
|
raiseOnNack: true,
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Pause this session via `SuspendSession` (proto 0.1.3+). Non-terminal: the
|
|
165
|
+
* runtime banks remaining TTL and rejects messages until {@link resume}.
|
|
166
|
+
*/
|
|
167
|
+
async suspend(reason = '', auth) {
|
|
168
|
+
return this.client.suspendSession(this.sessionId, reason, {
|
|
169
|
+
auth: auth ?? this.auth,
|
|
170
|
+
raiseOnNack: true,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Resume this suspended session via `ResumeSession` (proto 0.1.3+),
|
|
175
|
+
* restoring `SESSION_STATE_OPEN` and the banked TTL.
|
|
176
|
+
*/
|
|
177
|
+
async resume(reason = '', auth) {
|
|
178
|
+
return this.client.resumeSession(this.sessionId, reason, {
|
|
179
|
+
auth: auth ?? this.auth,
|
|
180
|
+
raiseOnNack: true,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
163
183
|
openStream(auth) {
|
|
164
184
|
return this.client.openStream({ auth: auth ?? this.auth });
|
|
165
185
|
}
|