@mag.ni/process 1.0.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/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/auth.d.ts +50 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +421 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +208 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +701 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agents.d.ts +39 -0
- package/dist/tools/agents.d.ts.map +1 -0
- package/dist/tools/agents.js +141 -0
- package/dist/tools/agents.js.map +1 -0
- package/dist/tools/design.d.ts +175 -0
- package/dist/tools/design.d.ts.map +1 -0
- package/dist/tools/design.js +1172 -0
- package/dist/tools/design.js.map +1 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +131 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/session.d.ts +77 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +285 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/work.d.ts +99 -0
- package/dist/tools/work.d.ts.map +1 -0
- package/dist/tools/work.js +702 -0
- package/dist/tools/work.js.map +1 -0
- package/dist/types.d.ts +264 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Processes - API Client
|
|
3
|
+
* HTTP client for the Process Workboard API
|
|
4
|
+
*/
|
|
5
|
+
import { User, CreateAgentUserRequest, CreateAgentUserResponse, ClaimUserResponse, HeartbeatResponse, ReleaseUserResponse, Instance, AvailableActionsResponse, TakeActionRequest, TakeActionResponse, Diagram, DiagramContext, ApiError, InstanceStatus } from './types.js';
|
|
6
|
+
import { AuthConfig } from './auth.js';
|
|
7
|
+
export declare class ApiClientError extends Error {
|
|
8
|
+
statusCode: number;
|
|
9
|
+
apiError?: ApiError | undefined;
|
|
10
|
+
constructor(message: string, statusCode: number, apiError?: ApiError | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class SessionNotClaimedError extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare class ProcessesApiClient {
|
|
16
|
+
private baseUrl;
|
|
17
|
+
private sessionId;
|
|
18
|
+
private claimedUserId;
|
|
19
|
+
private oauthManager;
|
|
20
|
+
private cookies;
|
|
21
|
+
private sessionEstablished;
|
|
22
|
+
constructor(baseUrl: string, oauth?: AuthConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Get the current session ID (if claimed)
|
|
25
|
+
*/
|
|
26
|
+
getSessionId(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Get the currently claimed user ID
|
|
29
|
+
*/
|
|
30
|
+
getClaimedUserId(): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a user is currently claimed
|
|
33
|
+
*/
|
|
34
|
+
hasClaimedUser(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Set the session ID (for restoring sessions)
|
|
37
|
+
*/
|
|
38
|
+
setSessionId(sessionId: string, userId: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Clear the session state (used when lease expires)
|
|
41
|
+
*/
|
|
42
|
+
clearSession(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Establish a BFF session by exchanging the OAuth access token for a session cookie.
|
|
45
|
+
* This calls POST /api/auth/session with the Bearer token, and the backend validates
|
|
46
|
+
* it via the auth server's userinfo endpoint, then returns a session cookie.
|
|
47
|
+
*/
|
|
48
|
+
private ensureBffSession;
|
|
49
|
+
private getHeaders;
|
|
50
|
+
private request;
|
|
51
|
+
private requireSession;
|
|
52
|
+
/**
|
|
53
|
+
* Logout: destroy the server-side BFF session and clear local OAuth credentials.
|
|
54
|
+
* After this, the next API call will trigger a fresh interactive login.
|
|
55
|
+
*/
|
|
56
|
+
logout(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* List all agent users with their claim status
|
|
59
|
+
*/
|
|
60
|
+
listAgentUsers(): Promise<User[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Create a new agent user
|
|
63
|
+
*/
|
|
64
|
+
createAgentUser(request: CreateAgentUserRequest): Promise<CreateAgentUserResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Delete an agent user (must be unclaimed)
|
|
67
|
+
*/
|
|
68
|
+
deleteAgentUser(userId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Claim a user identity to start working
|
|
71
|
+
* Returns a lease that must be kept alive with heartbeat()
|
|
72
|
+
*/
|
|
73
|
+
claimUser(userId: string): Promise<ClaimUserResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Send heartbeat to keep the lease alive
|
|
76
|
+
* Must be called periodically (recommended: every minute for 5-minute TTL)
|
|
77
|
+
*/
|
|
78
|
+
heartbeat(): Promise<HeartbeatResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Release the claimed user identity
|
|
81
|
+
* Should be called when done working
|
|
82
|
+
*/
|
|
83
|
+
releaseUser(): Promise<ReleaseUserResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Get instances assigned to the claimed user
|
|
86
|
+
* Returns WorkflowInstanceDto[] from the backend
|
|
87
|
+
*/
|
|
88
|
+
getMyInstances(status?: InstanceStatus): Promise<Record<string, unknown>[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Get full details for a specific instance
|
|
91
|
+
* Returns the raw WorkflowInstanceDto from the backend
|
|
92
|
+
*/
|
|
93
|
+
getInstanceDetails(instanceId: string): Promise<Record<string, unknown>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get available actions for an instance at its current step
|
|
96
|
+
*/
|
|
97
|
+
getAvailableActions(instanceId: string): Promise<AvailableActionsResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Execute an action on an instance
|
|
100
|
+
*/
|
|
101
|
+
takeAction(instanceId: string, request: TakeActionRequest): Promise<TakeActionResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get a diagram by ID
|
|
104
|
+
* Maps the raw API response (arrows/from/to/shape) to the MCP type (edges/sourceNodeId/targetNodeId/type)
|
|
105
|
+
*/
|
|
106
|
+
getDiagram(diagramId: string): Promise<Diagram>;
|
|
107
|
+
/**
|
|
108
|
+
* Map raw API diagram response to MCP Diagram type.
|
|
109
|
+
* The backend returns ArrowDto[] as "arrows" with "from"/"to" properties,
|
|
110
|
+
* while MCP types expect DiagramEdge[] as "edges" with "sourceNodeId"/"targetNodeId".
|
|
111
|
+
* Similarly, nodes use "shape"/"isStart"/"isEnd" instead of "type".
|
|
112
|
+
* Raw properties are preserved via spread for handlers that access them directly.
|
|
113
|
+
*/
|
|
114
|
+
private mapRawDiagram;
|
|
115
|
+
/**
|
|
116
|
+
* Get full context for a diagram including node details
|
|
117
|
+
*/
|
|
118
|
+
getDiagramContext(diagramId: string): Promise<DiagramContext>;
|
|
119
|
+
/**
|
|
120
|
+
* Assign an instance to a user
|
|
121
|
+
*/
|
|
122
|
+
assignInstance(instanceId: string, userId: string): Promise<Instance>;
|
|
123
|
+
/**
|
|
124
|
+
* Get a user by ID
|
|
125
|
+
*/
|
|
126
|
+
getUser(userId: string): Promise<User>;
|
|
127
|
+
/**
|
|
128
|
+
* Get all notes for an instance
|
|
129
|
+
*/
|
|
130
|
+
getInstanceNotes(instanceId: string): Promise<Record<string, unknown>>;
|
|
131
|
+
/**
|
|
132
|
+
* Add a note to an instance
|
|
133
|
+
*/
|
|
134
|
+
addInstanceNote(instanceId: string, text: string): Promise<Record<string, unknown>>;
|
|
135
|
+
/**
|
|
136
|
+
* List all diagrams with optional filtering
|
|
137
|
+
*/
|
|
138
|
+
listDiagrams(filter?: {
|
|
139
|
+
search?: string;
|
|
140
|
+
diagramType?: string;
|
|
141
|
+
sortBy?: string;
|
|
142
|
+
sortOrder?: string;
|
|
143
|
+
topLevelOnly?: boolean;
|
|
144
|
+
}): Promise<Record<string, unknown>[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Get a diagram by ID (raw API response without mapping)
|
|
147
|
+
*/
|
|
148
|
+
getDiagramRaw(diagramId: string): Promise<Record<string, unknown>>;
|
|
149
|
+
/**
|
|
150
|
+
* Create a new diagram
|
|
151
|
+
*/
|
|
152
|
+
createDiagram(data: {
|
|
153
|
+
title: string;
|
|
154
|
+
token: string;
|
|
155
|
+
diagramType?: string;
|
|
156
|
+
mode?: string;
|
|
157
|
+
}): Promise<Record<string, unknown>>;
|
|
158
|
+
/**
|
|
159
|
+
* Update a diagram's properties
|
|
160
|
+
*/
|
|
161
|
+
updateDiagram(diagramId: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
162
|
+
/**
|
|
163
|
+
* Delete a diagram
|
|
164
|
+
*/
|
|
165
|
+
deleteDiagram(diagramId: string, confirm?: boolean): Promise<{
|
|
166
|
+
success?: boolean;
|
|
167
|
+
requiresConfirmation?: boolean;
|
|
168
|
+
message?: string;
|
|
169
|
+
count?: number;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Duplicate a diagram
|
|
173
|
+
*/
|
|
174
|
+
duplicateDiagram(diagramId: string): Promise<Record<string, unknown>>;
|
|
175
|
+
/**
|
|
176
|
+
* Add a node to a diagram
|
|
177
|
+
* Fetches the current diagram, adds the node, and saves
|
|
178
|
+
*/
|
|
179
|
+
addNode(diagramId: string, nodeData: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
180
|
+
/**
|
|
181
|
+
* Update a node in a diagram
|
|
182
|
+
*/
|
|
183
|
+
updateNode(diagramId: string, nodeId: string, updateData: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
184
|
+
/**
|
|
185
|
+
* Delete a node from a diagram
|
|
186
|
+
* Also removes any arrows connected to this node
|
|
187
|
+
*/
|
|
188
|
+
deleteNode(diagramId: string, nodeId: string): Promise<{
|
|
189
|
+
removedArrowCount: number;
|
|
190
|
+
}>;
|
|
191
|
+
/**
|
|
192
|
+
* Add an arrow to a diagram
|
|
193
|
+
*/
|
|
194
|
+
addArrow(diagramId: string, arrowData: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
195
|
+
/**
|
|
196
|
+
* Update an arrow in a diagram
|
|
197
|
+
*/
|
|
198
|
+
updateArrow(diagramId: string, arrowId: string, updateData: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
199
|
+
/**
|
|
200
|
+
* Delete an arrow from a diagram
|
|
201
|
+
*/
|
|
202
|
+
deleteArrow(diagramId: string, arrowId: string): Promise<void>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Create a new API client instance from environment variables
|
|
206
|
+
*/
|
|
207
|
+
export declare function createClient(): ProcessesApiClient;
|
|
208
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,IAAI,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EAER,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EAIP,cAAc,EAEd,QAAQ,EACR,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAgB,UAAU,EAAE,MAAM,WAAW,CAAC;AAyCrD,qBAAa,cAAe,SAAQ,KAAK;IAG9B,UAAU,EAAE,MAAM;IAClB,QAAQ,CAAC,EAAE,QAAQ;gBAF1B,OAAO,EAAE,MAAM,EACR,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,QAAQ,YAAA;CAK7B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD;AAMD,qBAAa,kBAAkB;I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