@rolealpha/n8n-nodes-rolealpha 0.0.0-stage → 0.5.1

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,79 @@
1
+ "use strict";
2
+ /**
3
+ * Approval seals: proof that exactly this version was approved by exactly this person.
4
+ * Whoever sends something out recomputes the seal over the current version and
5
+ * stops if it does not match.
6
+ *
7
+ * v3 HMAC-SHA256 over canonical JSON ['v3', type, fields, approver]
8
+ * v2 legacy 64-bit hash written by code nodes without crypto (verify only)
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.canonicalJson = canonicalJson;
12
+ exports.signSeal = signSeal;
13
+ exports.legacySeal = legacySeal;
14
+ exports.verifySeal = verifySeal;
15
+ const crypto_1 = require("crypto");
16
+ const graph_1 = require("./graph");
17
+ /** JSON with sorted object keys so the seal does not depend on field order. */
18
+ function canonicalJson(value) {
19
+ if (value === null || typeof value !== 'object')
20
+ return JSON.stringify(value ?? null);
21
+ if (Array.isArray(value))
22
+ return `[${value.map(canonicalJson).join(',')}]`;
23
+ const o = value;
24
+ const keys = Object.keys(o)
25
+ .filter((k) => o[k] !== undefined)
26
+ .sort();
27
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(o[k])}`).join(',')}}`;
28
+ }
29
+ function requireKey(key) {
30
+ if (typeof key !== 'string' || key.length < 32)
31
+ throw new Error('The seal key must be at least 32 characters long');
32
+ }
33
+ function signSeal(key, type, fields, approver) {
34
+ requireKey(key);
35
+ const email = (0, graph_1.normalizeEmail)(approver);
36
+ if (!email.includes('@'))
37
+ throw new Error('A seal needs the approver address');
38
+ const payload = canonicalJson(['v3', String(type), fields ?? null, email]);
39
+ return `v3:${(0, crypto_1.createHmac)('sha256', key).update(payload, 'utf8').digest('hex')}`;
40
+ }
41
+ /** The v2 hash exactly as the existing code nodes compute it. */
42
+ function legacySeal(key, type, fields, approver) {
43
+ const s = JSON.stringify(['v2', key, type, fields, String(approver || '').trim().toLowerCase()]);
44
+ let h1 = 0xdeadbeef;
45
+ let h2 = 0x41c6ce57;
46
+ for (let i = 0; i < s.length; i++) {
47
+ const c = s.charCodeAt(i);
48
+ h1 = Math.imul(h1 ^ c, 2654435761);
49
+ h2 = Math.imul(h2 ^ c, 1597334677);
50
+ }
51
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
52
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
53
+ return 'v2:' + (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
54
+ }
55
+ function same(a, b) {
56
+ const x = Buffer.from(a, 'utf8');
57
+ const y = Buffer.from(b, 'utf8');
58
+ return x.length === y.length && (0, crypto_1.timingSafeEqual)(x, y);
59
+ }
60
+ function verifySeal(keys, seal, type, fields, approver) {
61
+ const value = typeof seal === 'string' ? seal.trim() : '';
62
+ if (value === '')
63
+ return { valid: false, version: null, reason: 'No seal present' };
64
+ const email = (0, graph_1.normalizeEmail)(approver);
65
+ if (!email.includes('@'))
66
+ return { valid: false, version: null, reason: 'No approver address present' };
67
+ if (value.startsWith('v3:')) {
68
+ const ok = same(value, signSeal(keys.key, type, fields, email));
69
+ return { valid: ok, version: 'v3', reason: ok ? 'Seal matches' : 'Changed after approval' };
70
+ }
71
+ if (value.startsWith('v2:')) {
72
+ if (!keys.legacyKey)
73
+ return { valid: false, version: 'v2', reason: 'Legacy seal, but no legacy key configured' };
74
+ const ok = same(value, legacySeal(keys.legacyKey, type, fields, email));
75
+ return { valid: ok, version: 'v2', reason: ok ? 'Legacy seal matches' : 'Changed after approval' };
76
+ }
77
+ return { valid: false, version: null, reason: 'Unknown seal format' };
78
+ }
79
+ //# sourceMappingURL=seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.js","sourceRoot":"","sources":["../../lib/seal.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAYH,sCAQC;AAMD,4BAMC;AAGD,gCAYC;AAQD,gCAqBC;AA1ED,mCAAqD;AACrD,mCAAyC;AAQzC,+EAA+E;AAC/E,SAAgB,aAAa,CAAC,KAAc;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACtF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CA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E,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAC7F,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,2CAA2C,EAAE,CAAC;QACjH,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACxE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC;IACpG,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Runner settings: limits for waiting, retries, escalation and run time. Defaults live
3
+ * here; a workflow can override them per organisation, step or agent from a table
4
+ * (scope, target, key, value), so a change takes effect without republishing anything.
5
+ *
6
+ * Every value is clamped to fixed bounds: a wrong or hostile table row can make the
7
+ * runner more careful, but never unbounded (no endless waking, no endless runs).
8
+ */
9
+ export interface RunnerSettings {
10
+ /** Minutes a wait may stay unanswered before the scheduler starts the agent again. */
11
+ maxWaitMinutes: number;
12
+ /** How often one agent is woken for the same step and records before it escalates. */
13
+ maxAttempts: number;
14
+ /** Hours done and escalated rows are kept. */
15
+ keepDoneHours: number;
16
+ /** Tool calls of the agent per run. */
17
+ maxIterations: number;
18
+ /** Minutes after which a run counts as dead; its lease is released. */
19
+ runTimeoutMinutes: number;
20
+ /** Whether stuck waits are reported to the role that leads the agent's circle. */
21
+ escalate: boolean;
22
+ /** Hours a share decision is reused while step, roles and trigger stay the same; 0 = never. */
23
+ shareCacheHours: number;
24
+ }
25
+ export type SettingKey = keyof RunnerSettings;
26
+ export declare const DEFAULT_SETTINGS: RunnerSettings;
27
+ export declare const SETTING_BOUNDS: Record<Exclude<SettingKey, 'escalate'>, {
28
+ min: number;
29
+ max: number;
30
+ }>;
31
+ export interface SettingRow {
32
+ scope?: string | null;
33
+ target?: string | null;
34
+ key?: string | null;
35
+ value?: unknown;
36
+ }
37
+ export interface SettingsTarget {
38
+ agentUuid?: string | null;
39
+ stepUuid?: string | null;
40
+ stepCustomId?: string | null;
41
+ }
42
+ export interface ResolvedSettings {
43
+ settings: RunnerSettings;
44
+ /** Where each value came from: default, global, step or agent. */
45
+ sources: Record<SettingKey, string>;
46
+ /** Rows that were ignored or clamped, with the reason. */
47
+ problems: string[];
48
+ }
49
+ /** Checks one value; numbers are rounded and clamped. Returns null for a value that is unusable. */
50
+ export declare function checkSetting(key: SettingKey, value: unknown): {
51
+ value: number | boolean;
52
+ note?: string;
53
+ } | null;
54
+ /** Defaults < global < step < agent. Unknown keys and unusable values are reported, never applied. */
55
+ export declare function resolveSettings(rows: SettingRow[], target?: SettingsTarget): ResolvedSettings;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Runner settings: limits for waiting, retries, escalation and run time. Defaults live
4
+ * here; a workflow can override them per organisation, step or agent from a table
5
+ * (scope, target, key, value), so a change takes effect without republishing anything.
6
+ *
7
+ * Every value is clamped to fixed bounds: a wrong or hostile table row can make the
8
+ * runner more careful, but never unbounded (no endless waking, no endless runs).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.SETTING_BOUNDS = exports.DEFAULT_SETTINGS = void 0;
12
+ exports.checkSetting = checkSetting;
13
+ exports.resolveSettings = resolveSettings;
14
+ exports.DEFAULT_SETTINGS = {
15
+ maxWaitMinutes: 60,
16
+ maxAttempts: 5,
17
+ keepDoneHours: 168,
18
+ maxIterations: 15,
19
+ runTimeoutMinutes: 15,
20
+ escalate: true,
21
+ shareCacheHours: 24,
22
+ };
23
+ exports.SETTING_BOUNDS = {
24
+ maxWaitMinutes: { min: 5, max: 10080 },
25
+ maxAttempts: { min: 1, max: 20 },
26
+ keepDoneHours: { min: 1, max: 2160 },
27
+ maxIterations: { min: 1, max: 50 },
28
+ runTimeoutMinutes: { min: 1, max: 120 },
29
+ shareCacheHours: { min: 0, max: 720 },
30
+ };
31
+ const SCOPE_RANK = { global: 1, step: 2, agent: 3 };
32
+ const lower = (v) => String(v ?? '').trim().toLowerCase();
33
+ function parseBool(value) {
34
+ if (typeof value === 'boolean')
35
+ return value;
36
+ const v = lower(value);
37
+ if (['true', '1', 'yes', 'ja', 'on'].includes(v))
38
+ return true;
39
+ if (['false', '0', 'no', 'nein', 'off'].includes(v))
40
+ return false;
41
+ return null;
42
+ }
43
+ /** Checks one value; numbers are rounded and clamped. Returns null for a value that is unusable. */
44
+ function checkSetting(key, value) {
45
+ if (key === 'escalate') {
46
+ const b = parseBool(value);
47
+ return b === null ? null : { value: b };
48
+ }
49
+ const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
50
+ if (!Number.isFinite(n))
51
+ return null;
52
+ const { min, max } = exports.SETTING_BOUNDS[key];
53
+ const r = Math.round(n);
54
+ const clamped = Math.min(max, Math.max(min, r));
55
+ return clamped === r ? { value: clamped } : { value: clamped, note: `clamped to ${clamped} (allowed ${min}–${max})` };
56
+ }
57
+ function matches(row, scope, target) {
58
+ if (scope === 'global')
59
+ return true;
60
+ const t = lower(row.target);
61
+ if (t === '')
62
+ return false;
63
+ if (scope === 'agent')
64
+ return t === lower(target.agentUuid);
65
+ return t === lower(target.stepUuid) || (!!target.stepCustomId && t === lower(target.stepCustomId));
66
+ }
67
+ /** Defaults < global < step < agent. Unknown keys and unusable values are reported, never applied. */
68
+ function resolveSettings(rows, target = {}) {
69
+ const settings = { ...exports.DEFAULT_SETTINGS };
70
+ const sources = Object.fromEntries(Object.keys(exports.DEFAULT_SETTINGS).map((k) => [k, 'default']));
71
+ const rank = Object.fromEntries(Object.keys(exports.DEFAULT_SETTINGS).map((k) => [k, 0]));
72
+ const problems = [];
73
+ const keys = new Map(Object.keys(exports.DEFAULT_SETTINGS).map((k) => [k.toLowerCase(), k]));
74
+ for (const row of Array.isArray(rows) ? rows : []) {
75
+ if (!row || typeof row !== 'object')
76
+ continue;
77
+ const scope = lower(row.scope) || 'global';
78
+ const label = `${scope}${row.target ? `:${row.target}` : ''}/${row.key ?? ''}`;
79
+ if (!SCOPE_RANK[scope]) {
80
+ problems.push(`${label}: unknown scope`);
81
+ continue;
82
+ }
83
+ const key = keys.get(lower(row.key));
84
+ if (!key) {
85
+ problems.push(`${label}: unknown key`);
86
+ continue;
87
+ }
88
+ if (!matches(row, scope, target))
89
+ continue;
90
+ const checked = checkSetting(key, row.value);
91
+ if (!checked) {
92
+ problems.push(`${label}: unusable value ${JSON.stringify(row.value)}`);
93
+ continue;
94
+ }
95
+ if (checked.note)
96
+ problems.push(`${label}: ${checked.note}`);
97
+ if (SCOPE_RANK[scope] < rank[key])
98
+ continue;
99
+ settings[key] = checked.value;
100
+ sources[key] = scope;
101
+ rank[key] = SCOPE_RANK[scope];
102
+ }
103
+ return { settings, sources, problems };
104
+ }
105
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../lib/settings.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAyEH,oCAWC;AAWD,0CAiCC;AA3GY,QAAA,gBAAgB,GAAmB;IAC/C,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,CAAC;IACd,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,EAAE;IACjB,iBAAiB,EAAE,EAAE;IACrB,QAAQ,EAAE,IAAI;IACd,eAAe,EAAE,EAAE;CACnB,CAAC;AAEW,QAAA,cAAc,GAA0E;I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CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * The share of one agent in a process step. A step can hold many tasks, several roles
3
+ * share it, and their parts can depend on each other within the step. Only the
4
+ * accountabilities of the agent's own roles can make a task the agent's part; what the
5
+ * part needs first comes from the other roles responsible for the same step.
6
+ *
7
+ * The model call itself stays outside: buildShareInput prepares it, checkShare checks
8
+ * the answer against the roleALPHA data, so the model can neither add duties nor invent roles.
9
+ */
10
+ import type { Step } from './graph';
11
+ import type { ContextBundle } from './prompt';
12
+ export interface ShareTrigger {
13
+ type?: string;
14
+ event?: unknown;
15
+ }
16
+ export interface ShareAccountability {
17
+ id: string;
18
+ roleUuid: string;
19
+ role: string;
20
+ text: string;
21
+ }
22
+ export interface ShareOtherRole {
23
+ id: string;
24
+ uuid: string;
25
+ name: string;
26
+ /** Whether an active agent fills the role; only then does its finished run wake the waiting agents. */
27
+ hasActiveAgent: boolean;
28
+ /** Whether anybody (active agent or person) fills the role. */
29
+ filled: boolean;
30
+ }
31
+ export interface ShareInput {
32
+ stepUuid: string;
33
+ stepName: string;
34
+ stepCustomId: string | null;
35
+ roles: Array<{
36
+ uuid: string;
37
+ name: string;
38
+ }>;
39
+ others: ShareOtherRole[];
40
+ accountabilities: ShareAccountability[];
41
+ systemMessage: string;
42
+ prompt: string;
43
+ /**
44
+ * Same key, same decision: hash of the rules, the step, the roles and the kind of trigger,
45
+ * without record data. A cached answer is still checked again by checkShare.
46
+ */
47
+ cacheKey: string;
48
+ }
49
+ export interface ShareNeed {
50
+ roleUuid: string;
51
+ role: string;
52
+ what: string;
53
+ /** Where the result is found (collection, field, status), so a check can see it is there. */
54
+ where: string;
55
+ }
56
+ export interface ShareDuty {
57
+ id: string;
58
+ roleUuid: string;
59
+ role: string;
60
+ accountability: string;
61
+ task: string;
62
+ /** The duty closes the step (hand-over, status change for the next step): it is done last, after its needs. */
63
+ handover: boolean;
64
+ needs: ShareNeed[];
65
+ }
66
+ export interface ShareWait {
67
+ uuid: string;
68
+ name: string;
69
+ needs: string[];
70
+ hasActiveAgent: boolean;
71
+ }
72
+ export interface ShareResult {
73
+ stepUuid: string;
74
+ stepName: string;
75
+ stepCustomId: string | null;
76
+ hasShare: boolean;
77
+ roles: Array<{
78
+ uuid: string;
79
+ name: string;
80
+ }>;
81
+ duties: ShareDuty[];
82
+ notMine: string[];
83
+ others: string[];
84
+ waitsFor: ShareWait[];
85
+ /** Role UUIDs a wait of this agent refers to: the predicted needs, else every other role of the step. */
86
+ waitRoleUuids: string[];
87
+ reason: string;
88
+ }
89
+ export declare const SHARE_SYSTEM_MESSAGE: string;
90
+ /** Raise when the rules or the input format change, so cached decisions are not reused. */
91
+ export declare const SHARE_VERSION = "share-5";
92
+ /** JSON schema of the model answer, for a structured output parser. */
93
+ export declare const SHARE_SCHEMA: {
94
+ type: string;
95
+ properties: {
96
+ duties: {
97
+ type: string;
98
+ items: {
99
+ type: string;
100
+ properties: {
101
+ id: {
102
+ type: string;
103
+ description: string;
104
+ };
105
+ task: {
106
+ type: string;
107
+ description: string;
108
+ };
109
+ handover: {
110
+ type: string;
111
+ description: string;
112
+ };
113
+ needs: {
114
+ type: string;
115
+ items: {
116
+ type: string;
117
+ properties: {
118
+ role: {
119
+ type: string;
120
+ description: string;
121
+ };
122
+ what: {
123
+ type: string;
124
+ description: string;
125
+ };
126
+ where: {
127
+ type: string;
128
+ description: string;
129
+ };
130
+ };
131
+ required: string[];
132
+ };
133
+ };
134
+ };
135
+ required: string[];
136
+ };
137
+ };
138
+ notMine: {
139
+ type: string;
140
+ items: {
141
+ type: string;
142
+ };
143
+ };
144
+ reason: {
145
+ type: string;
146
+ };
147
+ };
148
+ required: string[];
149
+ };
150
+ /**
151
+ * Prepares the model call. myRoleUuids are the agent's roles that are responsible for
152
+ * the step (Check Responsibility); without them the roles of the bundle on the step count.
153
+ */
154
+ export declare function buildShareInput(bundle: ContextBundle, step: Step, myRoleUuids: string[], trigger?: ShareTrigger): ShareInput;
155
+ /** Keeps only duties of real accountabilities and needs on real other roles of the step. */
156
+ export declare function checkShare(input: ShareInput, answer: unknown): ShareResult;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * The share of one agent in a process step. A step can hold many tasks, several roles
4
+ * share it, and their parts can depend on each other within the step. Only the
5
+ * accountabilities of the agent's own roles can make a task the agent's part; what the
6
+ * part needs first comes from the other roles responsible for the same step.
7
+ *
8
+ * The model call itself stays outside: buildShareInput prepares it, checkShare checks
9
+ * the answer against the roleALPHA data, so the model can neither add duties nor invent roles.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SHARE_SCHEMA = exports.SHARE_VERSION = exports.SHARE_SYSTEM_MESSAGE = void 0;
13
+ exports.buildShareInput = buildShareInput;
14
+ exports.checkShare = checkShare;
15
+ const crypto_1 = require("crypto");
16
+ exports.SHARE_SYSTEM_MESSAGE = [
17
+ 'A process step can hold many tasks, and several roles share it. Decide which part of this step belongs to the roles of one agent, and what that part needs from the other roles of the same step.',
18
+ '1. Only an accountability listed under "Accountabilities of the agent\'s roles" can make a task the agent\'s part. The role purpose is context only and adds no task.',
19
+ '2. Pick each accountability that this step calls for in this run (step description, criteria, result and trigger). For each, write in "task" concretely what the agent does now in this step under exactly that accountability, and nothing beyond it.',
20
+ '3. In "needs", list for each duty the deliveries of other roles of this step that must exist before the agent can do that task: the role id (R…), in "what" exactly which result, and in "where" where it is found (collection, field or status). A delivery is a result that the step description or an accountability of that role names, that is stored in data where it can be checked, and without which the task cannot be done, for example the text a visual illustrates, or a decision the step requires before the hand-over. Informing people, asking for feedback, recording or answering questions is no delivery and never a need. Leave "needs" empty when the task can start right away.',
21
+ '4. List in "notMine" every task of the step that none of the listed accountabilities covers.',
22
+ '5. Never stretch an accountability to cover a task it does not name. If none fits, return an empty "duties" list.',
23
+ '6. Use only the ids from the input. Write "task", "what", "notMine" and "reason" in the language of the step. Describe tasks without record ids, names or contents: the same part applies to every record of this kind of trigger.',
24
+ '7. Set "handover" to true for a duty that closes the step for the next one, e.g. handing results on or setting the status for the next step. Such a duty is done last. It waits only on the deliveries listed in its "needs", never on a role that delivers nothing in this step.',
25
+ ].join('\n');
26
+ /** Raise when the rules or the input format change, so cached decisions are not reused. */
27
+ exports.SHARE_VERSION = 'share-5';
28
+ /** Event fields that change the share decision; record data (ids, texts) does not. */
29
+ const EVENT_KIND_FIELDS = ['collection', 'status', 'event', 'action', 'type'];
30
+ /** JSON schema of the model answer, for a structured output parser. */
31
+ exports.SHARE_SCHEMA = {
32
+ type: 'object',
33
+ properties: {
34
+ duties: {
35
+ type: 'array',
36
+ items: {
37
+ type: 'object',
38
+ properties: {
39
+ id: { type: 'string', description: 'Id of the accountability, e.g. A1.2' },
40
+ task: { type: 'string', description: 'What the agent does now in this step under this accountability' },
41
+ handover: { type: 'boolean', description: 'True when this duty closes the step for the next one (hand-over, status for the next step)' },
42
+ needs: {
43
+ type: 'array',
44
+ items: {
45
+ type: 'object',
46
+ properties: {
47
+ role: { type: 'string', description: 'Id of another role of this step, e.g. R1' },
48
+ what: { type: 'string', description: 'The delivery of that role this task needs first' },
49
+ where: { type: 'string', description: 'Where the delivery is found: collection, field or status' },
50
+ },
51
+ required: ['role', 'what', 'where'],
52
+ },
53
+ },
54
+ },
55
+ required: ['id', 'task', 'handover', 'needs'],
56
+ },
57
+ },
58
+ notMine: { type: 'array', items: { type: 'string' } },
59
+ reason: { type: 'string' },
60
+ },
61
+ required: ['duties', 'notMine', 'reason'],
62
+ };
63
+ function text(value) {
64
+ if (value === null || value === undefined)
65
+ return '';
66
+ if (typeof value === 'string')
67
+ return value.trim();
68
+ return JSON.stringify(value);
69
+ }
70
+ function textList(value) {
71
+ if (Array.isArray(value))
72
+ return value.map(text).filter(Boolean);
73
+ const single = text(value);
74
+ return single ? [single] : [];
75
+ }
76
+ const lower = (v) => String(v ?? '').trim().toLowerCase();
77
+ function hasActiveAgent(role) {
78
+ return (role.holders?.agents ?? []).some((a) => lower(a.status) === 'active');
79
+ }
80
+ /**
81
+ * Prepares the model call. myRoleUuids are the agent's roles that are responsible for
82
+ * the step (Check Responsibility); without them the roles of the bundle on the step count.
83
+ */
84
+ function buildShareInput(bundle, step, myRoleUuids, trigger = {}) {
85
+ const onStep = new Set(step.responsibleRoles.map((r) => lower(r.uuid)));
86
+ const wanted = new Set((myRoleUuids.length ? myRoleUuids : Array.from(onStep)).map(lower));
87
+ const roles = (bundle.context ?? []).filter((c) => c.kind === 'role' && wanted.has(lower(c.uuid)) && onStep.has(lower(c.uuid)));
88
+ if (roles.length === 0)
89
+ throw new Error(`None of the roles of agent ${bundle.agent?.name ?? ''} is responsible for step ${step.name}`);
90
+ const mine = new Set(roles.map((r) => lower(r.uuid)));
91
+ const accountabilities = [];
92
+ roles.forEach((r, ri) => {
93
+ textList(r.body?.accountabilities).forEach((t, ai) => accountabilities.push({ id: `A${ri + 1}.${ai + 1}`, roleUuid: lower(r.uuid), role: r.name, text: t }));
94
+ });
95
+ const otherRoles = step.responsibleRoles.filter((r) => !mine.has(lower(r.uuid)));
96
+ const others = otherRoles.map((r, n) => ({
97
+ id: `R${n + 1}`,
98
+ uuid: lower(r.uuid),
99
+ name: r.name,
100
+ hasActiveAgent: hasActiveAgent(r),
101
+ filled: hasActiveAgent(r) || (r.holders?.persons ?? []).length > 0,
102
+ }));
103
+ const lines = ['# Step', `${step.name}${step.customId ? ` [${step.customId}]` : ''}`, `Description: ${step.description || '-'}`];
104
+ if (step.criteria)
105
+ lines.push(`Criteria: ${step.criteria}`);
106
+ if (step.result)
107
+ lines.push(`Result: ${step.result}`);
108
+ lines.push('', '# Other roles responsible for this step (id: name)');
109
+ if (otherRoles.length === 0)
110
+ lines.push('none');
111
+ otherRoles.forEach((r, n) => {
112
+ lines.push(`${others[n].id}: ${r.name}`);
113
+ if (r.purpose)
114
+ lines.push(` Purpose: ${r.purpose}`);
115
+ for (const a of r.accountabilities ?? [])
116
+ lines.push(` - ${a}`);
117
+ });
118
+ lines.push('', "# Roles of the agent on this step");
119
+ for (const r of roles) {
120
+ const purpose = text(r.body?.purpose);
121
+ lines.push(`- ${r.name}${purpose ? ` (purpose, context only): ${purpose}` : ''}`);
122
+ }
123
+ lines.push('', "# Accountabilities of the agent's roles (id (role): text)");
124
+ if (accountabilities.length === 0)
125
+ lines.push('none');
126
+ for (const a of accountabilities)
127
+ lines.push(`${a.id} (${a.role}): ${a.text}`);
128
+ // The decision is cached per kind of trigger and reused for every record, so the model sees no record data either.
129
+ const kind = eventKind(trigger.event);
130
+ lines.push('', '# Trigger', `Type: ${trigger.type || 'manual'}`);
131
+ if (Object.keys(kind).length)
132
+ lines.push(`Kind of event: ${JSON.stringify(kind)}`);
133
+ const cacheKey = (0, crypto_1.createHash)('sha256')
134
+ .update(JSON.stringify([exports.SHARE_VERSION, exports.SHARE_SYSTEM_MESSAGE, lines.join('\n'), others.map((o) => [o.uuid, o.hasActiveAgent, o.filled])]))
135
+ .digest('hex');
136
+ return {
137
+ stepUuid: lower(step.uuid),
138
+ stepName: step.name,
139
+ stepCustomId: step.customId,
140
+ roles: roles.map((r) => ({ uuid: lower(r.uuid), name: r.name })),
141
+ others,
142
+ accountabilities,
143
+ systemMessage: exports.SHARE_SYSTEM_MESSAGE,
144
+ prompt: lines.join('\n'),
145
+ cacheKey,
146
+ };
147
+ }
148
+ /** The kind of trigger without record data, e.g. {collection, status}. */
149
+ function eventKind(event) {
150
+ const e = (event && typeof event === 'object' && !Array.isArray(event) ? event : {});
151
+ const out = {};
152
+ for (const k of EVENT_KIND_FIELDS) {
153
+ const v = e[k];
154
+ if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean')
155
+ out[k] = String(v).slice(0, 200);
156
+ }
157
+ return out;
158
+ }
159
+ /** Keeps only duties of real accountabilities and needs on real other roles of the step. */
160
+ function checkShare(input, answer) {
161
+ const out = (answer && typeof answer === 'object' ? answer : {});
162
+ const byId = new Map(input.accountabilities.map((a) => [a.id, a]));
163
+ const roleById = new Map(input.others.map((r) => [r.id, r]));
164
+ const roleByName = new Map(input.others.map((r) => [lower(r.name), r]));
165
+ const seen = new Set();
166
+ const duties = [];
167
+ for (const raw of Array.isArray(out.duties) ? out.duties : []) {
168
+ const d = (raw && typeof raw === 'object' ? raw : {});
169
+ const id = text(d.id);
170
+ const acc = byId.get(id);
171
+ if (!acc || seen.has(id))
172
+ continue;
173
+ seen.add(id);
174
+ const needs = [];
175
+ for (const rawNeed of Array.isArray(d.needs) ? d.needs : []) {
176
+ const n = (rawNeed && typeof rawNeed === 'object' ? rawNeed : {});
177
+ const role = roleById.get(text(n.role)) ?? roleByName.get(lower(n.role));
178
+ const what = text(n.what);
179
+ if (role && what && !needs.some((x) => x.roleUuid === role.uuid && x.what === what))
180
+ needs.push({ roleUuid: role.uuid, role: role.name, what: what.slice(0, 500), where: text(n.where).slice(0, 300) });
181
+ }
182
+ // A hand-over waits only on the deliveries it lists: a role that delivers nothing here holds nothing up.
183
+ const handover = d.handover === true || text(d.handover).toLowerCase() === 'true';
184
+ duties.push({ id, roleUuid: acc.roleUuid, role: acc.role, accountability: acc.text, task: (text(d.task) || acc.text).slice(0, 2000), handover, needs });
185
+ }
186
+ const waits = new Map();
187
+ for (const n of duties.flatMap((d) => d.needs)) {
188
+ const role = input.others.find((r) => r.uuid === n.roleUuid);
189
+ const w = waits.get(n.roleUuid) ?? { uuid: n.roleUuid, name: n.role, needs: [], hasActiveAgent: role.hasActiveAgent };
190
+ if (!w.needs.includes(n.what))
191
+ w.needs.push(n.what);
192
+ waits.set(n.roleUuid, w);
193
+ }
194
+ return {
195
+ stepUuid: input.stepUuid,
196
+ stepName: input.stepName,
197
+ stepCustomId: input.stepCustomId,
198
+ hasShare: duties.length > 0,
199
+ roles: input.roles,
200
+ duties,
201
+ notMine: textList(out.notMine).slice(0, 50).map((t) => t.slice(0, 500)),
202
+ others: input.others.map((r) => r.name),
203
+ waitsFor: Array.from(waits.values()),
204
+ waitRoleUuids: waits.size ? Array.from(waits.keys()) : input.others.map((r) => r.uuid),
205
+ reason: text(out.reason).slice(0, 2000),
206
+ };
207
+ }
208
+ //# sourceMappingURL=share.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.js","sourceRoot":"","sources":["../../lib/share.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA8JH,0CA4DC;AAcD,gCA8CC;AApRD,mCAAoC;AAmFvB,QAAA,oBAAoB,GAAG;IACnC,mMAAmM;IACnM,uKAAuK;IACvK,wPAAwP;IACxP,0qBAA0qB;IAC1qB,8FAA8F;IAC9F,mHAAmH;IACnH,oOAAoO;IACpO,mRAAmR;CACnR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,2FAA2F;AAC9E,QAAA,aAAa,GAAG,SAAS,CAAC;AAEvC,sFAAsF;AACtF,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE9E,uEAAuE;AAC1D,QAAA,YAAY,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,MAAM,EAAE;YACP,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACX,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;oBAC1E,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gEAAgE,EAAE;oBACvG,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,4FAA4F,EAAE;oBACxI,KAAK,EAAE;wBACN,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACN,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACX,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0C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