@rolealpha/n8n-nodes-rolealpha 0.0.0-stage → 0.5.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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -2
  3. package/dist/credentials/ApprovalSealApi.credentials.d.ts +7 -0
  4. package/dist/credentials/ApprovalSealApi.credentials.js +29 -0
  5. package/dist/credentials/ApprovalSealApi.credentials.js.map +1 -0
  6. package/dist/credentials/RoleAlphaAgentKeysApi.credentials.d.ts +11 -0
  7. package/dist/credentials/RoleAlphaAgentKeysApi.credentials.js +35 -0
  8. package/dist/credentials/RoleAlphaAgentKeysApi.credentials.js.map +1 -0
  9. package/dist/credentials/RoleAlphaWebhookApi.credentials.d.ts +8 -0
  10. package/dist/credentials/RoleAlphaWebhookApi.credentials.js +23 -0
  11. package/dist/credentials/RoleAlphaWebhookApi.credentials.js.map +1 -0
  12. package/dist/lib/agentRun.d.ts +73 -0
  13. package/dist/lib/agentRun.js +170 -0
  14. package/dist/lib/agentRun.js.map +1 -0
  15. package/dist/lib/agents.d.ts +19 -0
  16. package/dist/lib/agents.js +91 -0
  17. package/dist/lib/agents.js.map +1 -0
  18. package/dist/lib/graph.d.ts +155 -0
  19. package/dist/lib/graph.js +380 -0
  20. package/dist/lib/graph.js.map +1 -0
  21. package/dist/lib/keys.d.ts +12 -0
  22. package/dist/lib/keys.js +53 -0
  23. package/dist/lib/keys.js.map +1 -0
  24. package/dist/lib/mcp.d.ts +52 -0
  25. package/dist/lib/mcp.js +201 -0
  26. package/dist/lib/mcp.js.map +1 -0
  27. package/dist/lib/prompt.d.ts +52 -0
  28. package/dist/lib/prompt.js +180 -0
  29. package/dist/lib/prompt.js.map +1 -0
  30. package/dist/lib/schedule.d.ts +37 -0
  31. package/dist/lib/schedule.js +106 -0
  32. package/dist/lib/schedule.js.map +1 -0
  33. package/dist/lib/seal.d.ts +22 -0
  34. package/dist/lib/seal.js +79 -0
  35. package/dist/lib/seal.js.map +1 -0
  36. package/dist/lib/settings.d.ts +55 -0
  37. package/dist/lib/settings.js +105 -0
  38. package/dist/lib/settings.js.map +1 -0
  39. package/dist/lib/share.d.ts +156 -0
  40. package/dist/lib/share.js +208 -0
  41. package/dist/lib/share.js.map +1 -0
  42. package/dist/lib/waits.d.ts +142 -0
  43. package/dist/lib/waits.js +339 -0
  44. package/dist/lib/waits.js.map +1 -0
  45. package/dist/lib/webhook.d.ts +12 -0
  46. package/dist/lib/webhook.js +50 -0
  47. package/dist/lib/webhook.js.map +1 -0
  48. package/dist/nodes/ApprovalSeal/ApprovalSeal.node.d.ts +9 -0
  49. package/dist/nodes/ApprovalSeal/ApprovalSeal.node.js +141 -0
  50. package/dist/nodes/ApprovalSeal/ApprovalSeal.node.js.map +1 -0
  51. package/dist/nodes/ApprovalSeal/approvalSeal.svg +1 -0
  52. package/dist/nodes/RoleAlpha/RoleAlpha.node.d.ts +5 -0
  53. package/dist/nodes/RoleAlpha/RoleAlpha.node.js +1099 -0
  54. package/dist/nodes/RoleAlpha/RoleAlpha.node.js.map +1 -0
  55. package/dist/nodes/RoleAlpha/roleAlpha.svg +1 -0
  56. package/dist/nodes/RoleAlphaTrigger/RoleAlphaTrigger.node.d.ts +9 -0
  57. package/dist/nodes/RoleAlphaTrigger/RoleAlphaTrigger.node.js +61 -0
  58. package/dist/nodes/RoleAlphaTrigger/RoleAlphaTrigger.node.js.map +1 -0
  59. package/dist/nodes/RoleAlphaTrigger/roleAlpha.svg +1 -0
  60. package/package.json +56 -4
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * Acting as an agent (roleALPHA `agent:run`, RFC 8693). The runner holds one function
4
+ * account; for every run it swaps the account token for a run token that carries exactly
5
+ * the view of one agent, valid for 15 minutes. Without a run token nothing runs: there is
6
+ * no fallback to the view of the account.
7
+ *
8
+ * Tokens stay in memory only and are never written to node output.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.AgentRunTokens = exports.PROCESS_STORE = exports.TOKEN_TYPE_ACCESS = exports.GRANT_TOKEN_EXCHANGE = exports.AgentRunError = void 0;
12
+ exports.reactionFor = reactionFor;
13
+ exports.isValidRunId = isValidRunId;
14
+ exports.mcpRefusalCode = mcpRefusalCode;
15
+ const REACTIONS = {
16
+ agent_uuid_fehlt: 'fixConfig',
17
+ run_id_ungueltig: 'fixConfig',
18
+ invalid_request: 'fixConfig',
19
+ unsupported_grant_type: 'fixConfig',
20
+ kein_agent_run_recht: 'informAdmin',
21
+ agent_nicht_gebunden: 'informAdmin',
22
+ funktionskonto_deaktiviert: 'informAdmin',
23
+ funktion_nicht_freigeschaltet: 'informAdmin',
24
+ mandant_stimmt_nicht: 'informAdmin',
25
+ anker_fehlt: 'informAdmin',
26
+ invalid_client: 'informAdmin',
27
+ agent_unbekannt: 'removeAgent',
28
+ agent_nicht_aktiv: 'pause',
29
+ agent_budget_erschoepft: 'pauseUntilNextPeriod',
30
+ agent_status_nicht_pruefbar: 'retryLater',
31
+ token_ungueltig: 'renewAccountToken',
32
+ falscher_token_typ: 'renewAccountToken',
33
+ falsche_resource: 'renewAccountToken',
34
+ funktionskonto_unbekannt: 'renewAccountToken',
35
+ secret_widerrufen: 'renewAccountToken',
36
+ };
37
+ function reactionFor(code, status = 0) {
38
+ return REACTIONS[code] ?? (status === 401 ? 'renewAccountToken' : status >= 500 || status === 429 ? 'retryLater' : 'endRun');
39
+ }
40
+ class AgentRunError extends Error {
41
+ code;
42
+ status;
43
+ description;
44
+ reaction;
45
+ constructor(code, status, description) {
46
+ super(`${code}${description ? `: ${description}` : ''}`);
47
+ this.code = code;
48
+ this.status = status;
49
+ this.description = description;
50
+ this.name = 'AgentRunError';
51
+ this.reaction = reactionFor(code, status);
52
+ }
53
+ }
54
+ exports.AgentRunError = AgentRunError;
55
+ const RUN_ID = /^[A-Za-z0-9._:-]{1,128}$/;
56
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
57
+ /** Renew a token this long before it expires, so no call starts with a token about to lapse. */
58
+ const MARGIN_MS = 60_000;
59
+ exports.GRANT_TOKEN_EXCHANGE = 'urn:ietf:params:oauth:grant-type:token-exchange';
60
+ exports.TOKEN_TYPE_ACCESS = 'urn:ietf:params:oauth:token-type:access_token';
61
+ function isValidRunId(runId) {
62
+ return RUN_ID.test(runId);
63
+ }
64
+ function parse(body) {
65
+ try {
66
+ const v = JSON.parse(body);
67
+ return v && typeof v === 'object' ? v : {};
68
+ }
69
+ catch {
70
+ return {};
71
+ }
72
+ }
73
+ function refusal(reply) {
74
+ const b = parse(reply.body);
75
+ const code = typeof b.error === 'string' && b.error ? b.error : `http_${reply.status}`;
76
+ const description = typeof b.error_description === 'string' ? b.error_description : reply.body.slice(0, 300);
77
+ return new AgentRunError(code, reply.status, description);
78
+ }
79
+ function basic(id, secret) {
80
+ return `Basic ${Buffer.from(`${encodeURIComponent(id)}:${encodeURIComponent(secret)}`).toString('base64')}`;
81
+ }
82
+ /** One store per process: the nodes and sub-workflows of one run swap once and share the token. */
83
+ exports.PROCESS_STORE = { accounts: new Map(), runs: new Map() };
84
+ /** Holds the account token and the run tokens, kept per account, agent and run. */
85
+ class AgentRunTokens {
86
+ post;
87
+ now;
88
+ accounts;
89
+ runs;
90
+ constructor(post, now = Date.now, store = exports.PROCESS_STORE) {
91
+ this.post = post;
92
+ this.now = now;
93
+ this.accounts = store.accounts;
94
+ this.runs = store.runs;
95
+ }
96
+ accountKey(a) {
97
+ return `${a.tokenUrl}|${a.clientId}`;
98
+ }
99
+ async accountToken(a, fresh) {
100
+ const key = this.accountKey(a);
101
+ const hit = this.accounts.get(key);
102
+ if (!fresh && hit && hit.expiresAt - MARGIN_MS > this.now())
103
+ return hit.token;
104
+ const reply = a.authentication === 'body'
105
+ ? await this.post(a.tokenUrl, { grant_type: 'client_credentials', client_id: a.clientId, client_secret: a.clientSecret }, {})
106
+ : await this.post(a.tokenUrl, { grant_type: 'client_credentials' }, { Authorization: basic(a.clientId, a.clientSecret) });
107
+ if (reply.status !== 200)
108
+ throw refusal(reply);
109
+ const b = parse(reply.body);
110
+ if (typeof b.access_token !== 'string' || !b.access_token)
111
+ throw new AgentRunError('no_access_token', reply.status, 'The token endpoint returned no access_token');
112
+ const token = { token: b.access_token, expiresAt: this.now() + (Number(b.expires_in) || 3600) * 1000 };
113
+ this.accounts.set(key, token);
114
+ return token.token;
115
+ }
116
+ /** The run token for one agent and run: cached, swapped again shortly before it expires. */
117
+ async runToken(a, agentUuid, runId, opts = {}) {
118
+ const agent = agentUuid.trim().toLowerCase();
119
+ if (!UUID.test(agent))
120
+ throw new AgentRunError('agent_uuid_fehlt', 400, `Not an agent UUID: "${agentUuid}"`);
121
+ if (!isValidRunId(runId))
122
+ throw new AgentRunError('run_id_ungueltig', 400, 'Run ID: 1-128 characters of A-Z a-z 0-9 . _ : -');
123
+ const key = `${this.accountKey(a)}|${agent}|${runId}`;
124
+ const hit = this.runs.get(key);
125
+ if (!opts.fresh && hit && hit.expiresAt - MARGIN_MS > this.now())
126
+ return hit;
127
+ this.prune();
128
+ const swap = async (fresh) => this.post(a.tokenUrl, { grant_type: exports.GRANT_TOKEN_EXCHANGE, subject_token: await this.accountToken(a, fresh), subject_token_type: exports.TOKEN_TYPE_ACCESS, agent_uuid: agent, run_id: runId }, {});
129
+ let reply = await swap(false);
130
+ // A stale account token is renewed once; every other refusal is final for this call.
131
+ if (reply.status !== 200 && reactionFor(refusal(reply).code, reply.status) === 'renewAccountToken')
132
+ reply = await swap(true);
133
+ if (reply.status !== 200)
134
+ throw refusal(reply);
135
+ const b = parse(reply.body);
136
+ if (typeof b.access_token !== 'string' || !b.access_token)
137
+ throw new AgentRunError('no_access_token', reply.status, 'The token exchange returned no access_token');
138
+ const named = (b.agent ?? {});
139
+ const token = {
140
+ token: b.access_token,
141
+ expiresAt: this.now() + (Number(b.expires_in) || 900) * 1000,
142
+ agent: { uuid: agent, name: typeof named.name === 'string' ? named.name : null },
143
+ runId,
144
+ };
145
+ this.runs.set(key, token);
146
+ return token;
147
+ }
148
+ /** Forgets a run token, e.g. after the MCP endpoint refused it. */
149
+ forget(a, agentUuid, runId) {
150
+ this.runs.delete(`${this.accountKey(a)}|${agentUuid.trim().toLowerCase()}|${runId}`);
151
+ }
152
+ prune() {
153
+ const now = this.now();
154
+ for (const [k, v] of this.runs)
155
+ if (v.expiresAt <= now)
156
+ this.runs.delete(k);
157
+ }
158
+ }
159
+ exports.AgentRunTokens = AgentRunTokens;
160
+ /** Reads the refusal code of an MCP reply under a run token: JSON-RPC error.message or an OAuth error. */
161
+ function mcpRefusalCode(body) {
162
+ const b = parse(body);
163
+ const err = b.error;
164
+ if (typeof err === 'string')
165
+ return err;
166
+ if (err && typeof err === 'object' && typeof err.message === 'string')
167
+ return String(err.message).trim().split(/\s/)[0];
168
+ return '';
169
+ }
170
+ //# sourceMappingURL=agentRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentRun.js","sourceRoot":"","sources":["../../lib/agentRun.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA4CH,kCAEC;AAuBD,oCAEC;AA0HD,wCAMC;AAlLD,MAAM,SAAS,GAA6B;IAC3C,gBAAgB,EAAE,WAAW;IAC7B,gBAAgB,EAAE,WAAW;IAC7B,eAAe,EAAE,WAAW;IAC5B,sBAAsB,EAAE,WAAW;IACnC,oBAAoB,EAAE,aAAa;IACnC,oBAAoB,EAAE,aAAa;IACnC,0BAA0B,EAAE,aAAa;IACzC,6BAA6B,EAAE,aAAa;IAC5C,oBAAoB,EAAE,aAAa;IACnC,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,aAAa;IAC7B,eAAe,EAAE,aAAa;IAC9B,iBAAiB,EAAE,OAAO;IAC1B,uBAAuB,EAAE,sBAAsB;IAC/C,2BAA2B,EAAE,YAAY;IACzC,eAAe,EAAE,mBAAmB;IACpC,kBAAkB,EAAE,mBAAmB;IACv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C,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClL,OAAO,EAAE,CAAC;AACX,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Agents over the roleALPHA MCP endpoint. With one OAuth2 connection every agent
3
+ * of the organisation is found and run, so a new agent needs no per-agent key.
4
+ */
5
+ import type { McpClient } from './mcp';
6
+ import type { ContextBundle } from './prompt';
7
+ export type ContextView = 'agent' | 'caller';
8
+ export interface AgentEntry {
9
+ agentUuid: string;
10
+ agentName: string;
11
+ customId: string | null;
12
+ status: string | null;
13
+ }
14
+ /** Status comes from `status`, else from the last part of the summary ("Name | active"). */
15
+ export declare function agentStatus(raw: Record<string, unknown>): string | null;
16
+ /** All agents of the organisation, paged through search_agents. */
17
+ export declare function listAgents(client: McpClient, organisation: string): Promise<AgentEntry[]>;
18
+ /** The context bundle of one agent; view "agent" is exactly what the agent receives over its own key. */
19
+ export declare function getAgentContext(client: McpClient, organisation: string, agentUuid: string, view?: ContextView): Promise<ContextBundle>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /**
3
+ * Agents over the roleALPHA MCP endpoint. With one OAuth2 connection every agent
4
+ * of the organisation is found and run, so a new agent needs no per-agent key.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.agentStatus = agentStatus;
8
+ exports.listAgents = listAgents;
9
+ exports.getAgentContext = getAgentContext;
10
+ const PAGE_SIZE = 200;
11
+ const MAX_PAGES = 50;
12
+ function str(value) {
13
+ if (typeof value === 'string')
14
+ return value.trim() === '' ? null : value.trim();
15
+ if (typeof value === 'number')
16
+ return String(value);
17
+ return null;
18
+ }
19
+ /** Status comes from `status`, else from the last part of the summary ("Name | active"). */
20
+ function agentStatus(raw) {
21
+ const direct = str(raw.status);
22
+ if (direct)
23
+ return direct.toLowerCase();
24
+ const summary = str(raw.summary);
25
+ if (!summary || !summary.includes('|'))
26
+ return null;
27
+ return str(summary.split('|').pop())?.toLowerCase() ?? null;
28
+ }
29
+ function toEntry(raw) {
30
+ const uuid = str(raw.uuid ?? raw.entityUuid ?? raw.id);
31
+ if (!uuid)
32
+ return null;
33
+ return {
34
+ agentUuid: uuid.toLowerCase(),
35
+ agentName: str(raw.name) ?? '',
36
+ customId: str(raw.customerId ?? raw.customer_id ?? raw.customId),
37
+ status: agentStatus(raw),
38
+ };
39
+ }
40
+ /** All agents of the organisation, paged through search_agents. */
41
+ async function listAgents(client, organisation) {
42
+ const out = [];
43
+ const seen = new Set();
44
+ let offset = 0;
45
+ for (let page = 0; page < MAX_PAGES; page++) {
46
+ const res = (await client.callTool('search_agents', { query: '', organisation, limit: PAGE_SIZE, offset }));
47
+ const list = Array.isArray(res) ? res : (res?.agents ?? res?.results ?? res?.entities ?? []);
48
+ for (const raw of list) {
49
+ const entry = raw && typeof raw === 'object' ? toEntry(raw) : null;
50
+ if (entry && !seen.has(entry.agentUuid)) {
51
+ seen.add(entry.agentUuid);
52
+ out.push(entry);
53
+ }
54
+ }
55
+ if (Array.isArray(res) || !res?.hasMore)
56
+ return out;
57
+ const next = Number(res.nextOffset);
58
+ offset = Number.isFinite(next) && next > offset ? next : offset + list.length;
59
+ if (list.length === 0)
60
+ break;
61
+ }
62
+ throw new Error(`search_agents did not finish after ${MAX_PAGES} pages`);
63
+ }
64
+ /** The bundle may come bare, wrapped in {bundle} or as one of several content parts. */
65
+ function findBundle(value) {
66
+ if (Array.isArray(value)) {
67
+ for (const v of value) {
68
+ const b = findBundle(v);
69
+ if (b)
70
+ return b;
71
+ }
72
+ return null;
73
+ }
74
+ if (!value || typeof value !== 'object')
75
+ return null;
76
+ const obj = value;
77
+ if (obj.agent && typeof obj.agent === 'object')
78
+ return obj;
79
+ return obj.bundle ? findBundle(obj.bundle) : null;
80
+ }
81
+ /** The context bundle of one agent; view "agent" is exactly what the agent receives over its own key. */
82
+ async function getAgentContext(client, organisation, agentUuid, view = 'agent') {
83
+ const res = await client.callTool('get_agent_context', { agent_uuid: agentUuid, organisation, view });
84
+ const bundle = findBundle(res);
85
+ if (!bundle) {
86
+ const raw = typeof res === 'string' ? res : JSON.stringify(res);
87
+ throw new Error(`get_agent_context returned no agent for ${agentUuid}: ${String(raw).slice(0, 400)}`);
88
+ }
89
+ return { ...bundle, guardrails: bundle.guardrails ?? [], context: bundle.context ?? [] };
90
+ }
91
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../lib/agents.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAwBH,kCAMC;AAcD,gCAoBC;AAkBD,0CAQC;AA5ED,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,GAAG,CAAC,KAAc;IAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,4FAA4F;AAC5F,SAAgB,WAAW,CAAC,GAA4B;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,IAAI,CAAC;AAC7D,CAAC;AAED,SAAS,OAAO,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,KAAK,KAAK,QAAQ;QAAE,OAAO,GAA+B,CAAC;IACvF,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,yGAAyG;AAClG,KAAK,UAAU,eAAe,CAAC,MAAiB,EAAE,YAAoB,EAAE,SAAiB,EAAE,OAAoB,OAAO;IAC5H,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACtG,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,2CAA2C,SAAS,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Traversal of the roleALPHA graph. Nothing here knows a concrete role, person
3
+ * or step: everything is read at run time, starting from an agent or a step.
4
+ *
5
+ * Edge directions (roleALPHA conventions):
6
+ * Role --RESPONSIBLE_FOR--> Step Role --DECIDES_ON--> Step
7
+ * Role --ACCOUNTABLE_FOR--> Step Policy --APPLIES_TO--> Step
8
+ * Successor --DEPENDS_ON--> Predecessor Parent --HAS_SUBPROCESS--> Child
9
+ * Person --EXECUTES--> Role Agent --AGENT_FULFILLS_ROLE--> Role
10
+ * Circle --IS_IMPLEMENTED_BY--> Role
11
+ */
12
+ import type { McpClient } from './mcp';
13
+ export interface EntityDetails {
14
+ uuid: string;
15
+ name: string;
16
+ customId: string | null;
17
+ entityType: string;
18
+ data: Record<string, unknown>;
19
+ }
20
+ export interface Relationship {
21
+ id?: string | number;
22
+ type: string;
23
+ direction: 'incoming' | 'outgoing';
24
+ uuid: string;
25
+ name: string;
26
+ entityType: string;
27
+ }
28
+ export interface SearchHit {
29
+ uuid: string;
30
+ name: string;
31
+ customId: string | null;
32
+ entityType: string;
33
+ }
34
+ export interface GraphSource {
35
+ details(uuid: string): Promise<EntityDetails>;
36
+ relationships(uuid: string): Promise<Relationship[]>;
37
+ search(query: string, entityType?: string): Promise<SearchHit[]>;
38
+ }
39
+ export interface EntityRef {
40
+ uuid: string;
41
+ name: string;
42
+ entityType?: string;
43
+ }
44
+ export interface PersonRef extends EntityRef {
45
+ email: string | null;
46
+ }
47
+ export interface AgentRef extends EntityRef {
48
+ status: string | null;
49
+ }
50
+ export interface RoleHolders {
51
+ persons: PersonRef[];
52
+ agents: AgentRef[];
53
+ }
54
+ export interface RoleRef extends EntityRef {
55
+ holders?: RoleHolders;
56
+ purpose?: string | null;
57
+ accountabilities?: string[];
58
+ domains?: string[];
59
+ }
60
+ export interface StepSummary extends EntityRef {
61
+ customId: string | null;
62
+ subtype: string | null;
63
+ status: string | null;
64
+ frequency: string | null;
65
+ dueDate: string | null;
66
+ description: string | null;
67
+ criteria: string | null;
68
+ result: string | null;
69
+ }
70
+ export interface Step extends StepSummary {
71
+ predecessors: EntityRef[];
72
+ successors: EntityRef[];
73
+ parents: EntityRef[];
74
+ children: EntityRef[];
75
+ responsibleRoles: RoleRef[];
76
+ decidingRoles: RoleRef[];
77
+ accountableRoles: RoleRef[];
78
+ policies: Array<EntityRef & {
79
+ description: string | null;
80
+ version: string | null;
81
+ status: string | null;
82
+ }>;
83
+ }
84
+ export interface Duty {
85
+ role: EntityRef;
86
+ circle: EntityRef | null;
87
+ step: StepSummary;
88
+ }
89
+ export interface Decider {
90
+ basis: 'DECIDES_ON' | 'ACCOUNTABLE_FOR' | null;
91
+ roles: RoleRef[];
92
+ }
93
+ export interface ApproverCheck {
94
+ allowed: boolean;
95
+ reason: string;
96
+ basis: Decider['basis'];
97
+ role: EntityRef | null;
98
+ person: PersonRef | null;
99
+ candidates: Array<{
100
+ role: EntityRef;
101
+ persons: string[];
102
+ }>;
103
+ }
104
+ export declare function normalizeEmail(value: unknown): string;
105
+ export declare function toDetails(raw: unknown, uuid: string): EntityDetails;
106
+ export declare function toRelationships(raw: unknown): Relationship[];
107
+ export declare function toSearchHits(raw: unknown): SearchHit[];
108
+ export declare function toStepSummary(d: EntityDetails): StepSummary;
109
+ /** Graph source on top of the roleALPHA MCP. Caches per instance (one per node execution). */
110
+ export declare class McpGraphSource implements GraphSource {
111
+ private readonly client;
112
+ private readonly organisation;
113
+ private readonly detailCache;
114
+ private readonly relCache;
115
+ constructor(client: McpClient, organisation: string);
116
+ details(uuid: string): Promise<EntityDetails>;
117
+ relationships(uuid: string): Promise<Relationship[]>;
118
+ search(query: string, entityType?: string): Promise<SearchHit[]>;
119
+ }
120
+ export declare function findStepByCustomId(src: GraphSource, customId: string): Promise<StepSummary | null>;
121
+ export declare function getRoleHolders(src: GraphSource, roleUuid: string): Promise<RoleHolders>;
122
+ export declare function getCircle(src: GraphSource, roleUuid: string): Promise<EntityRef | null>;
123
+ export interface CircleLead {
124
+ circle: EntityRef;
125
+ /** The role that leads the circle, with its holders; null when the circle names none. */
126
+ lead: RoleRef | null;
127
+ /** How the lead was recognised. */
128
+ basis: 'flag' | 'lead-link' | 'custom-id' | 'decides-on-circle' | null;
129
+ /** The agent's roles in this circle. */
130
+ roles: EntityRef[];
131
+ }
132
+ /**
133
+ * The role that leads the circle of each given role, read from roleALPHA at run time:
134
+ * a role inside the circle flagged as lead (leadLink / lead / subtype), else one whose purpose
135
+ * names it the Lead Link, else one whose custom ID ends in ":lead", else a role that decides on
136
+ * or is accountable for the circle itself. Persons first, agents after, as holders.
137
+ */
138
+ export declare function getCircleLeads(src: GraphSource, roleUuids: string[]): Promise<CircleLead[]>;
139
+ export declare function getStep(src: GraphSource, stepUuid: string, opts?: {
140
+ resolveHolders?: boolean;
141
+ roleDetails?: boolean;
142
+ }): Promise<Step>;
143
+ /** The roles an agent fulfils, read from the graph (used when no context bundle is at hand). */
144
+ export declare function getAgentRoles(src: GraphSource, agentUuid: string): Promise<EntityRef[]>;
145
+ /** Every step the given roles are responsible for, one entry per role and step. */
146
+ export declare function getDuties(src: GraphSource, roleUuids: string[]): Promise<Duty[]>;
147
+ /** Which of the given roles is responsible for the step. Empty means: not responsible. */
148
+ export declare function responsibleRolesFor(src: GraphSource, stepUuid: string, roleUuids: string[]): Promise<EntityRef[]>;
149
+ /** Role first, then person: DECIDES_ON wins; without it the ACCOUNTABLE_FOR role decides. */
150
+ export declare function getDecider(src: GraphSource, stepUuid: string): Promise<Decider>;
151
+ /**
152
+ * Fail-closed check whether the acting person may decide on the step right now.
153
+ * Only persons decide; agents filling the deciding role never count.
154
+ */
155
+ export declare function checkApprover(src: GraphSource, stepUuid: string, actor: string): Promise<ApproverCheck>;