@pixelbyte-software/pixcode 1.42.3 → 1.42.5

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 (35) hide show
  1. package/dist/assets/{index-BnaWRV1a.js → index-nefOyhzb.js} +168 -168
  2. package/dist/index.html +1 -1
  3. package/dist-server/server/claude-sdk.js +23 -2
  4. package/dist-server/server/claude-sdk.js.map +1 -1
  5. package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +1 -1
  6. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +2 -0
  7. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +1 -1
  8. package/dist-server/server/modules/orchestration/a2a/routes.js +2 -0
  9. package/dist-server/server/modules/orchestration/a2a/routes.js.map +1 -1
  10. package/dist-server/server/modules/orchestration/index.js +2 -0
  11. package/dist-server/server/modules/orchestration/index.js.map +1 -1
  12. package/dist-server/server/modules/orchestration/security/permission-policy.js +269 -0
  13. package/dist-server/server/modules/orchestration/security/permission-policy.js.map +1 -0
  14. package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +115 -1
  15. package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +1 -1
  16. package/dist-server/server/modules/orchestration/workflows/workflow-templates.js +242 -0
  17. package/dist-server/server/modules/orchestration/workflows/workflow-templates.js.map +1 -0
  18. package/dist-server/server/modules/orchestration/workflows/workflow-trace.js +53 -0
  19. package/dist-server/server/modules/orchestration/workflows/workflow-trace.js.map +1 -1
  20. package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +137 -0
  21. package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +1 -1
  22. package/package.json +1 -1
  23. package/scripts/smoke/permission-policy.mjs +50 -0
  24. package/scripts/smoke/workflow-templates.mjs +43 -0
  25. package/server/claude-sdk.js +24 -2
  26. package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +8 -0
  27. package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +2 -0
  28. package/server/modules/orchestration/a2a/routes.ts +6 -0
  29. package/server/modules/orchestration/index.ts +28 -0
  30. package/server/modules/orchestration/security/permission-policy.ts +401 -0
  31. package/server/modules/orchestration/workflows/workflow-runner.ts +141 -1
  32. package/server/modules/orchestration/workflows/workflow-templates.ts +272 -0
  33. package/server/modules/orchestration/workflows/workflow-trace.ts +54 -0
  34. package/server/modules/orchestration/workflows/workflow.routes.ts +165 -0
  35. package/server/modules/orchestration/workflows/workflow.types.ts +9 -1
@@ -21,6 +21,13 @@ import {
21
21
  classifyWorkflowFailure,
22
22
  resolveWorkflowFallbackDecision,
23
23
  } from '@/modules/orchestration/workflows/workflow-fallback-policy.js';
24
+ import {
25
+ evaluatePermissionRequest,
26
+ resolvePermissionPolicyFromMetadata,
27
+ type PermissionDecision,
28
+ type PermissionPolicy,
29
+ type PermissionPolicyEvent,
30
+ } from '@/modules/orchestration/security/permission-policy.js';
24
31
  import {
25
32
  type ResolvedWorkspaceTarget,
26
33
  resolveWorkflowWorkspace,
@@ -36,7 +43,12 @@ import {
36
43
  getStaticProviderModels,
37
44
  } from '@/services/model-registry.js';
38
45
  // @ts-ignore — plain-JS service
39
- import { notifyRunFailed, notifyRunStopped } from '@/services/notification-orchestrator.js';
46
+ import {
47
+ createNotificationEvent,
48
+ notifyRunFailed,
49
+ notifyRunStopped,
50
+ notifyUserIfEnabled,
51
+ } from '@/services/notification-orchestrator.js';
40
52
 
41
53
  const TERMINAL = new Set(['completed', 'failed', 'canceled']);
42
54
  const SKIPPED = 'skipped';
@@ -245,6 +257,49 @@ function notifyWorkflowRunFinished(run: WorkflowRun): void {
245
257
  }
246
258
  }
247
259
 
260
+ function permissionPolicyFromRun(run: WorkflowRun): PermissionPolicy {
261
+ return resolvePermissionPolicyFromMetadata(run.metadata);
262
+ }
263
+
264
+ function permissionPolicyEvents(run: WorkflowRun): PermissionPolicyEvent[] {
265
+ return Array.isArray(run.metadata?.permissionPolicyEvents)
266
+ ? run.metadata.permissionPolicyEvents.filter((event): event is PermissionPolicyEvent =>
267
+ Boolean(event && typeof event === 'object'),
268
+ )
269
+ : [];
270
+ }
271
+
272
+ function permissionApprovalRequests(run: WorkflowRun): Array<Record<string, unknown>> {
273
+ return Array.isArray(run.metadata?.pendingPermissionApprovals)
274
+ ? run.metadata.pendingPermissionApprovals.filter((event): event is Record<string, unknown> =>
275
+ Boolean(event && typeof event === 'object'),
276
+ )
277
+ : [];
278
+ }
279
+
280
+ function notifyPermissionApprovalRequested(run: WorkflowRun, decision: PermissionDecision): void {
281
+ const userId = readNotificationUserId(run.metadata);
282
+ if (!userId || !decision.approvalRequest) return;
283
+
284
+ const event = (createNotificationEvent as unknown as (payload: Record<string, unknown>) => unknown)({
285
+ provider: 'system',
286
+ sessionId: run.id,
287
+ kind: 'action_required',
288
+ code: 'permission.required',
289
+ meta: {
290
+ toolName: decision.capabilities.join(', '),
291
+ sessionName: workflowNotificationTitle(run),
292
+ },
293
+ severity: 'warning',
294
+ requiresUserAction: true,
295
+ dedupeKey: `workflow:permission:${run.id}:${decision.requestId}`,
296
+ });
297
+ (notifyUserIfEnabled as (payload: { userId: string | number; event: unknown }) => void)({
298
+ userId,
299
+ event,
300
+ });
301
+ }
302
+
248
303
  function readBoolean(value: unknown): boolean | undefined {
249
304
  return typeof value === 'boolean' ? value : undefined;
250
305
  }
@@ -1216,8 +1271,10 @@ class WorkflowRunner {
1216
1271
  const runtimeWorkflow = expandWorkflowForRun(workflow, metadata);
1217
1272
  validateWorkflow(runtimeWorkflow);
1218
1273
  const workspaceTarget = resolveWorkflowWorkspace(metadata);
1274
+ const permissionPolicy = resolvePermissionPolicyFromMetadata(metadata);
1219
1275
  const runMetadata: Record<string, unknown> = {
1220
1276
  ...metadata,
1277
+ permissionPolicy,
1221
1278
  projectPath: workspaceTarget.projectPath,
1222
1279
  selectedProjectPath: workspaceTarget.selectedProjectPath,
1223
1280
  workspaceTarget: workspaceTargetMetadata(workspaceTarget),
@@ -1602,6 +1659,37 @@ class WorkflowRunner {
1602
1659
  }
1603
1660
  }
1604
1661
 
1662
+ private recordPermissionDecision(
1663
+ run: WorkflowRun,
1664
+ nodeRun: WorkflowNodeRun,
1665
+ decision: PermissionDecision,
1666
+ ): void {
1667
+ nodeRun.permissionDecisions = [
1668
+ ...(nodeRun.permissionDecisions ?? []),
1669
+ decision,
1670
+ ];
1671
+
1672
+ const existingApprovals = permissionApprovalRequests(run)
1673
+ .filter((approval) => approval.id !== decision.approvalRequest?.id);
1674
+ run.metadata = {
1675
+ ...run.metadata,
1676
+ permissionPolicyEvents: [
1677
+ ...permissionPolicyEvents(run),
1678
+ decision.event,
1679
+ ],
1680
+ pendingPermissionApprovals: decision.approvalRequest
1681
+ ? [
1682
+ ...existingApprovals,
1683
+ decision.approvalRequest,
1684
+ ]
1685
+ : existingApprovals,
1686
+ };
1687
+
1688
+ if (decision.approvalRequest) {
1689
+ notifyPermissionApprovalRequested(run, decision);
1690
+ }
1691
+ }
1692
+
1605
1693
  private async executeNode(
1606
1694
  node: WorkflowNode,
1607
1695
  workflow: Workflow,
@@ -1680,6 +1768,49 @@ class WorkflowRunner {
1680
1768
  };
1681
1769
  workflowStore.setRun(run);
1682
1770
  }
1771
+ const permissionPolicy = permissionPolicyFromRun(run);
1772
+ nodeRun.permissionPolicy = permissionPolicy;
1773
+ const permissionDecision = evaluatePermissionRequest({
1774
+ policy: permissionPolicy,
1775
+ request: {
1776
+ source: 'workflow_node',
1777
+ toolName: node.adapterId,
1778
+ input: {
1779
+ assignment: node.assignment,
1780
+ stage: node.stage,
1781
+ toolsSettings: node.toolsSettings,
1782
+ },
1783
+ cwd: projectPath,
1784
+ workspacePath: workspaceTarget.appRoot,
1785
+ targetPaths: [projectPath],
1786
+ summary: [
1787
+ node.agentLabel || node.id,
1788
+ node.stage ? `stage=${node.stage}` : undefined,
1789
+ node.assignment,
1790
+ ].filter(Boolean).join(' / '),
1791
+ },
1792
+ context: {
1793
+ runId: run.id,
1794
+ nodeId: node.id,
1795
+ workflowId: run.workflowId,
1796
+ adapterId: node.adapterId,
1797
+ agentLabel: node.agentLabel,
1798
+ userId: readNotificationUserId(run.metadata),
1799
+ },
1800
+ });
1801
+ this.recordPermissionDecision(run, nodeRun, permissionDecision);
1802
+ workflowStore.setRun(run);
1803
+ if (permissionDecision.behavior === 'deny') {
1804
+ nodeRun.finishedAt = Date.now();
1805
+ nodeRun.status = 'failed';
1806
+ nodeRun.error = permissionDecision.message;
1807
+ workflowStore.setRun(run);
1808
+ if (node.onFail === 'continue') {
1809
+ completed.add(node.id);
1810
+ return;
1811
+ }
1812
+ throw new Error(permissionDecision.message);
1813
+ }
1683
1814
  let body: { id?: string; error?: { message?: string } };
1684
1815
  try {
1685
1816
  const submit = await fetch(`${localA2ABaseUrl()}/tasks`, {
@@ -1701,6 +1832,15 @@ class WorkflowRunner {
1701
1832
  assignment: node.assignment,
1702
1833
  model: effectiveModel,
1703
1834
  permissionMode: effectivePermissionMode,
1835
+ permissionPolicy,
1836
+ permissionPolicyContext: {
1837
+ runId: run.id,
1838
+ nodeId: node.id,
1839
+ workflowId: run.workflowId,
1840
+ adapterId: node.adapterId,
1841
+ agentLabel: node.agentLabel,
1842
+ userId: readNotificationUserId(run.metadata),
1843
+ },
1704
1844
  toolsSettings: node.toolsSettings,
1705
1845
  projectPath,
1706
1846
  workspaceTarget: workspaceTargetMetadata(workspaceTarget),
@@ -0,0 +1,272 @@
1
+ export const PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL = 'pixcode.workflow-template.v1' as const;
2
+
3
+ export interface WorkflowTemplateAgentSlot {
4
+ id: string;
5
+ role: string;
6
+ label: string;
7
+ instruction: string;
8
+ }
9
+
10
+ export interface WorkflowTemplate {
11
+ id: string;
12
+ protocol: typeof PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL;
13
+ version: 1;
14
+ workflowId: string;
15
+ name: string;
16
+ description: string;
17
+ inputPlaceholder: string;
18
+ agentSlots: WorkflowTemplateAgentSlot[];
19
+ acceptanceCriteria: string[];
20
+ defaultSettings?: {
21
+ maxParallelAgents?: number;
22
+ maxRepairCycles?: number;
23
+ };
24
+ }
25
+
26
+ type AgentRecord = Record<string, unknown>;
27
+
28
+ export const builtInWorkflowTemplates: WorkflowTemplate[] = [
29
+ {
30
+ id: 'bug_fix_team',
31
+ protocol: PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
32
+ version: 1,
33
+ workflowId: 'agent_team',
34
+ name: 'Bug fix team',
35
+ description: 'Reproduce, fix, and verify a focused bug with an implementation and review loop.',
36
+ inputPlaceholder: 'Describe the bug, expected behavior, current behavior, and any reproduction steps.',
37
+ agentSlots: [
38
+ {
39
+ id: 'reproducer',
40
+ role: 'implementation',
41
+ label: 'Reproducer',
42
+ instruction: 'Reproduce the bug from the user report, identify the failing path, and keep the scope narrow.',
43
+ },
44
+ {
45
+ id: 'fixer',
46
+ role: 'implementation',
47
+ label: 'Fixer',
48
+ instruction: 'Implement the smallest durable fix and report changed files and verification commands.',
49
+ },
50
+ {
51
+ id: 'reviewer',
52
+ role: 'review',
53
+ label: 'Reviewer',
54
+ instruction: 'Review the fix for regressions, missing validation, and whether the original bug is covered.',
55
+ },
56
+ ],
57
+ acceptanceCriteria: [
58
+ 'The bug has a concrete reproduction or a clearly documented blocker.',
59
+ 'The fix is limited to the failing behavior.',
60
+ 'Verification commands and remaining risks are reported.',
61
+ ],
62
+ defaultSettings: {
63
+ maxParallelAgents: 2,
64
+ maxRepairCycles: 1,
65
+ },
66
+ },
67
+ {
68
+ id: 'pr_review_team',
69
+ protocol: PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
70
+ version: 1,
71
+ workflowId: 'multi_model_review',
72
+ name: 'PR review team',
73
+ description: 'Run independent reviewers and aggregate actionable findings for a pull request or diff.',
74
+ inputPlaceholder: 'Paste the PR link, branch, or diff summary to review.',
75
+ agentSlots: [
76
+ {
77
+ id: 'correctness',
78
+ role: 'review',
79
+ label: 'Correctness reviewer',
80
+ instruction: 'Prioritize correctness bugs, regressions, missing tests, and broken edge cases.',
81
+ },
82
+ {
83
+ id: 'security',
84
+ role: 'review',
85
+ label: 'Security reviewer',
86
+ instruction: 'Prioritize security, secret handling, permission, and data exposure risks.',
87
+ },
88
+ {
89
+ id: 'reporter',
90
+ role: 'report',
91
+ label: 'Report aggregator',
92
+ instruction: 'Aggregate findings by severity with file references and concrete fix suggestions.',
93
+ },
94
+ ],
95
+ acceptanceCriteria: [
96
+ 'Findings are ordered by severity and avoid speculative noise.',
97
+ 'Each issue includes the concrete impact and suggested fix.',
98
+ 'The final report clearly says when no blocking issue is found.',
99
+ ],
100
+ defaultSettings: {
101
+ maxParallelAgents: 3,
102
+ },
103
+ },
104
+ {
105
+ id: 'frontend_polish',
106
+ protocol: PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
107
+ version: 1,
108
+ workflowId: 'agent_team',
109
+ name: 'Frontend polish',
110
+ description: 'Improve a UI workflow with implementation, responsive checks, and UX review.',
111
+ inputPlaceholder: 'Describe the screen or workflow that needs frontend polish.',
112
+ agentSlots: [
113
+ {
114
+ id: 'ui_implementation',
115
+ role: 'frontend',
116
+ label: 'UI implementer',
117
+ instruction: 'Implement the requested UI change using existing design conventions and responsive constraints.',
118
+ },
119
+ {
120
+ id: 'ux_review',
121
+ role: 'review',
122
+ label: 'UX reviewer',
123
+ instruction: 'Review layout, text overflow, responsive behavior, accessibility, and interaction states.',
124
+ },
125
+ {
126
+ id: 'verification',
127
+ role: 'review',
128
+ label: 'Verification reviewer',
129
+ instruction: 'Verify the change with available typecheck, lint, build, smoke, or manual UI evidence.',
130
+ },
131
+ ],
132
+ acceptanceCriteria: [
133
+ 'The UI follows existing components and visual density.',
134
+ 'Text and controls do not overlap on mobile or desktop.',
135
+ 'Verification evidence is included in the final summary.',
136
+ ],
137
+ defaultSettings: {
138
+ maxParallelAgents: 2,
139
+ maxRepairCycles: 1,
140
+ },
141
+ },
142
+ {
143
+ id: 'release_manager',
144
+ protocol: PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
145
+ version: 1,
146
+ workflowId: 'sequential_handoff',
147
+ name: 'Release manager',
148
+ description: 'Prepare a release checklist, run verification, and summarize publish readiness.',
149
+ inputPlaceholder: 'Describe the version, release scope, and target channels.',
150
+ agentSlots: [
151
+ {
152
+ id: 'release_plan',
153
+ role: 'implementation',
154
+ label: 'Release planner',
155
+ instruction: 'Create a release checklist, verify version surfaces, and identify publish blockers.',
156
+ },
157
+ {
158
+ id: 'release_verification',
159
+ role: 'review',
160
+ label: 'Release verifier',
161
+ instruction: 'Run or inspect release verification commands and report the exact publish state.',
162
+ },
163
+ {
164
+ id: 'release_report',
165
+ role: 'report',
166
+ label: 'Release reporter',
167
+ instruction: 'Summarize what was released, what was verified, and any blocked channels.',
168
+ },
169
+ ],
170
+ acceptanceCriteria: [
171
+ 'Version surfaces are aligned.',
172
+ 'Build/package verification is reported.',
173
+ 'Remote artifact and publish state are explicitly stated.',
174
+ ],
175
+ defaultSettings: {
176
+ maxParallelAgents: 1,
177
+ },
178
+ },
179
+ {
180
+ id: 'dependency_audit',
181
+ protocol: PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
182
+ version: 1,
183
+ workflowId: 'agent_team',
184
+ name: 'Dependency audit',
185
+ description: 'Inspect dependency, runtime, and package risks without making broad upgrades by default.',
186
+ inputPlaceholder: 'Describe the dependency or runtime area to audit.',
187
+ agentSlots: [
188
+ {
189
+ id: 'audit',
190
+ role: 'implementation',
191
+ label: 'Audit analyst',
192
+ instruction: 'Inspect dependency and runtime risk using existing lockfiles and configured package managers.',
193
+ },
194
+ {
195
+ id: 'risk_review',
196
+ role: 'review',
197
+ label: 'Risk reviewer',
198
+ instruction: 'Validate the findings, call out false positives, and avoid broad upgrade churn unless requested.',
199
+ },
200
+ {
201
+ id: 'report',
202
+ role: 'report',
203
+ label: 'Audit reporter',
204
+ instruction: 'Produce a prioritized remediation plan with commands, risks, and no-secret output.',
205
+ },
206
+ ],
207
+ acceptanceCriteria: [
208
+ 'Findings are tied to actual dependency evidence.',
209
+ 'No unrelated dependency upgrades are proposed as automatic work.',
210
+ 'Security and runtime risks are separated from maintenance suggestions.',
211
+ ],
212
+ defaultSettings: {
213
+ maxParallelAgents: 2,
214
+ },
215
+ },
216
+ ];
217
+
218
+ export function getWorkflowTemplate(templateId: string): WorkflowTemplate | undefined {
219
+ return builtInWorkflowTemplates.find((template) => template.id === templateId);
220
+ }
221
+
222
+ function applyTemplateSlots(agents: AgentRecord[] | undefined, template: WorkflowTemplate): AgentRecord[] | undefined {
223
+ if (!Array.isArray(agents) || agents.length === 0) return agents;
224
+
225
+ let enabledSlotIndex = 0;
226
+ return agents.map((agent) => {
227
+ if (agent.enabled === false) return agent;
228
+ const slot = template.agentSlots[enabledSlotIndex];
229
+ enabledSlotIndex += 1;
230
+ if (!slot) return agent;
231
+ return {
232
+ ...agent,
233
+ role: slot.role,
234
+ instruction: typeof agent.instruction === 'string' && agent.instruction.trim()
235
+ ? agent.instruction
236
+ : slot.instruction,
237
+ templateSlotId: slot.id,
238
+ templateSlotLabel: slot.label,
239
+ };
240
+ });
241
+ }
242
+
243
+ export function applyWorkflowTemplateToMetadata(
244
+ template: WorkflowTemplate,
245
+ metadata?: Record<string, unknown>,
246
+ ): Record<string, unknown> {
247
+ const settings = metadata?.settings && typeof metadata.settings === 'object'
248
+ ? metadata.settings as Record<string, unknown>
249
+ : {};
250
+
251
+ return {
252
+ ...metadata,
253
+ workflowTemplate: {
254
+ protocol: template.protocol,
255
+ id: template.id,
256
+ version: template.version,
257
+ name: template.name,
258
+ workflowId: template.workflowId,
259
+ acceptanceCriteria: template.acceptanceCriteria,
260
+ agentSlots: template.agentSlots.map((slot) => ({
261
+ id: slot.id,
262
+ role: slot.role,
263
+ label: slot.label,
264
+ })),
265
+ },
266
+ agents: applyTemplateSlots(metadata?.agents as AgentRecord[] | undefined, template),
267
+ settings: {
268
+ ...settings,
269
+ ...template.defaultSettings,
270
+ },
271
+ };
272
+ }
@@ -165,6 +165,28 @@ export function buildWorkflowTrace(run: WorkflowRun): WorkflowTraceEvent[] {
165
165
  });
166
166
  }
167
167
 
168
+ const workflowTemplate = readRecord(run.metadata?.workflowTemplate);
169
+ if (workflowTemplate) {
170
+ pushEvent(events, {
171
+ id: traceId([run.id, 'workflow-template']),
172
+ type: 'run',
173
+ severity: 'info',
174
+ status: run.status,
175
+ timestamp: run.startedAt + 0.3,
176
+ actor: 'Pixcode',
177
+ title: 'Workflow template applied',
178
+ titleKey: 'workflow.trace.template',
179
+ summary: redactTraceText([
180
+ `Template: ${readString(workflowTemplate.name) ?? readString(workflowTemplate.id) ?? 'unknown'}`,
181
+ `Protocol: ${readString(workflowTemplate.protocol) ?? 'unknown'}`,
182
+ Array.isArray(workflowTemplate.acceptanceCriteria)
183
+ ? `Acceptance criteria:\n- ${workflowTemplate.acceptanceCriteria.filter((item) => typeof item === 'string').join('\n- ')}`
184
+ : undefined,
185
+ ].filter(Boolean).join('\n'), run),
186
+ metadata: workflowTemplate,
187
+ });
188
+ }
189
+
168
190
  const fallbackEvents = Array.isArray(run.metadata?.fallbackEvents)
169
191
  ? run.metadata.fallbackEvents
170
192
  : [];
@@ -216,6 +238,38 @@ export function buildWorkflowTrace(run: WorkflowRun): WorkflowTraceEvent[] {
216
238
  });
217
239
  });
218
240
 
241
+ const permissionPolicyEvents = Array.isArray(run.metadata?.permissionPolicyEvents)
242
+ ? run.metadata.permissionPolicyEvents
243
+ : [];
244
+ permissionPolicyEvents.forEach((event, index) => {
245
+ const record = readRecord(event);
246
+ if (!record) return;
247
+ const behavior = readString(record.behavior);
248
+ const capabilities = Array.isArray(record.capabilities)
249
+ ? record.capabilities.filter((item): item is string => typeof item === 'string')
250
+ : [];
251
+ pushEvent(events, {
252
+ id: traceId([run.id, 'permission-policy', readString(record.id) ?? index]),
253
+ type: 'permission_policy',
254
+ severity: behavior === 'deny' ? 'error' : behavior === 'prompt' ? 'warning' : 'info',
255
+ status: behavior === 'deny' ? 'failed' : behavior === 'prompt' ? 'submitted' : 'completed',
256
+ timestamp: typeof record.createdAt === 'number' ? record.createdAt : run.startedAt + 0.85 + index,
257
+ actor: 'Pixcode',
258
+ nodeId: readString(record.nodeId),
259
+ adapterId: readString(record.adapterId),
260
+ agentLabel: readString(record.agentLabel),
261
+ title: 'Permission policy decision',
262
+ titleKey: 'workflow.trace.permissionPolicy',
263
+ summary: redactTraceText([
264
+ `Decision: ${behavior ?? readString(record.status) ?? 'unknown'}`,
265
+ capabilities.length > 0 ? `Capabilities: ${capabilities.join(', ')}` : undefined,
266
+ readString(record.summary),
267
+ readString(record.message),
268
+ ].filter(Boolean).join('\n'), run),
269
+ metadata: record,
270
+ });
271
+ });
272
+
219
273
  run.nodeRuns.forEach((node, index) => {
220
274
  const base = eventBase(node);
221
275
  const timestamp = nodeTimestamp(run, node, index);