@pixelbyte-software/pixcode 1.42.4 → 1.43.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/dist/assets/index-B-_FofJ_.css +32 -0
- package/dist/assets/{index-cTGs3Dvx.js → index-CDKI7Ucy.js} +170 -170
- package/dist/index.html +2 -2
- package/dist-server/server/index.js +3 -0
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/index.js +2 -0
- package/dist-server/server/modules/orchestration/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/workflows/approval-queue.js +72 -0
- package/dist-server/server/modules/orchestration/workflows/approval-queue.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +25 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +1 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-templates.js +242 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-templates.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-trace.js +21 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-trace.js.map +1 -1
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +121 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +1 -1
- package/dist-server/server/routes/public-api.js +7 -1
- package/dist-server/server/routes/public-api.js.map +1 -1
- package/dist-server/server/routes/remote.js +18 -0
- package/dist-server/server/routes/remote.js.map +1 -1
- package/dist-server/server/routes/webhooks.js +53 -0
- package/dist-server/server/routes/webhooks.js.map +1 -0
- package/dist-server/server/services/control-room.js +89 -0
- package/dist-server/server/services/control-room.js.map +1 -0
- package/dist-server/server/services/public-api-manifest.js +96 -0
- package/dist-server/server/services/public-api-manifest.js.map +1 -1
- package/dist-server/server/services/telegram/control-center.js +110 -0
- package/dist-server/server/services/telegram/control-center.js.map +1 -1
- package/dist-server/server/services/telegram/translations.js +24 -2
- package/dist-server/server/services/telegram/translations.js.map +1 -1
- package/dist-server/server/services/webhooks.js +198 -0
- package/dist-server/server/services/webhooks.js.map +1 -0
- package/package.json +1 -1
- package/scripts/smoke/v143-remote-control.mjs +76 -0
- package/scripts/smoke/workflow-templates.mjs +43 -0
- package/server/index.js +4 -0
- package/server/modules/orchestration/index.ts +14 -0
- package/server/modules/orchestration/workflows/approval-queue.ts +106 -0
- package/server/modules/orchestration/workflows/workflow-runner.ts +25 -0
- package/server/modules/orchestration/workflows/workflow-templates.ts +272 -0
- package/server/modules/orchestration/workflows/workflow-trace.ts +22 -0
- package/server/modules/orchestration/workflows/workflow.routes.ts +139 -0
- package/server/routes/public-api.js +14 -1
- package/server/routes/remote.js +22 -0
- package/server/routes/webhooks.js +63 -0
- package/server/services/control-room.js +102 -0
- package/server/services/public-api-manifest.js +98 -0
- package/server/services/telegram/control-center.js +113 -0
- package/server/services/telegram/translations.js +24 -2
- package/server/services/webhooks.js +216 -0
- package/dist/assets/index-CHa1760s.css +0 -32
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
|
|
9
|
+
function read(relativePath) {
|
|
10
|
+
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const telegram = read('server/services/telegram/control-center.js');
|
|
14
|
+
assert.match(telegram, /\/approvals/, 'Telegram control should expose an approvals command.');
|
|
15
|
+
assert.match(telegram, /showApprovalQueue/, 'Telegram menu should render pending approval decisions.');
|
|
16
|
+
assert.match(telegram, /approval_decide/, 'Telegram callbacks should allow approval decisions.');
|
|
17
|
+
assert.match(telegram, /showControlRoom/, 'Telegram menu should expose the multi-project control room.');
|
|
18
|
+
assert.match(telegram, /showWebhookMenu/, 'Telegram menu should expose webhook status.');
|
|
19
|
+
|
|
20
|
+
const workflowRoutes = read('server/modules/orchestration/workflows/workflow.routes.ts');
|
|
21
|
+
assert.match(workflowRoutes, /\/workflows\/approvals/, 'Orchestration should expose a global approval queue.');
|
|
22
|
+
assert.match(workflowRoutes, /resolvePermissionApproval/, 'Global approval route should resolve permission approvals.');
|
|
23
|
+
assert.match(workflowRoutes, /dispatchWebhookEvent/, 'Workflow routes should dispatch webhook events for remote automation.');
|
|
24
|
+
|
|
25
|
+
const approvalQueue = read('server/modules/orchestration/workflows/approval-queue.ts');
|
|
26
|
+
assert.match(approvalQueue, /listPendingApprovals/, 'Approval queue should list pending approvals across runs.');
|
|
27
|
+
assert.match(approvalQueue, /resolvePermissionApproval/, 'Approval queue should resolve approval requests centrally.');
|
|
28
|
+
assert.match(approvalQueue, /source: 'ui' \| 'telegram' \| 'api'/, 'Approval queue should preserve the decision source.');
|
|
29
|
+
|
|
30
|
+
const webhooks = read('server/services/webhooks.js');
|
|
31
|
+
assert.match(webhooks, /PIXCODE_WEBHOOK_EVENT_TYPES/, 'Webhook service should declare supported event taxonomy.');
|
|
32
|
+
assert.match(webhooks, /run\.completed/, 'Webhook taxonomy should include run.completed.');
|
|
33
|
+
assert.match(webhooks, /approval\.needed/, 'Webhook taxonomy should include approval.needed.');
|
|
34
|
+
assert.match(webhooks, /deliverWebhookEvent/, 'Webhook service should deliver signed outbound events.');
|
|
35
|
+
|
|
36
|
+
const webhookRoutes = read('server/routes/webhooks.js');
|
|
37
|
+
assert.match(webhookRoutes, /router\.get\('\/'/, 'Webhook routes should list configured webhooks.');
|
|
38
|
+
assert.match(webhookRoutes, /router\.post\('\/test'/, 'Webhook routes should support test delivery.');
|
|
39
|
+
|
|
40
|
+
const remote = read('server/routes/remote.js');
|
|
41
|
+
assert.match(remote, /\/control-room/, 'Remote API should expose the control room snapshot.');
|
|
42
|
+
assert.match(remote, /\/console-layout/, 'Remote API should expose mobile console layout metadata.');
|
|
43
|
+
|
|
44
|
+
const controlRoom = read('server/services/control-room.js');
|
|
45
|
+
assert.match(controlRoom, /buildControlRoomSnapshot/, 'Control room should build a multi-project snapshot.');
|
|
46
|
+
assert.match(controlRoom, /maxProjects = 4/, 'Control room should cap the live overview at four projects.');
|
|
47
|
+
assert.match(controlRoom, /mobileFirst/, 'Control room should include mobile-first console metadata.');
|
|
48
|
+
|
|
49
|
+
const publicApi = read('server/routes/public-api.js');
|
|
50
|
+
assert.match(publicApi, /\/sdk\/typescript/, 'Public API should expose a TypeScript SDK starter.');
|
|
51
|
+
assert.match(publicApi, /\/cookbook/, 'Public API should expose a curl cookbook.');
|
|
52
|
+
|
|
53
|
+
const manifest = read('server/services/public-api-manifest.js');
|
|
54
|
+
assert.match(manifest, /buildTypeScriptSdkStarter/, 'Public API manifest should generate typed TypeScript SDK examples.');
|
|
55
|
+
assert.match(manifest, /webhooks/, 'Public API manifest should document webhook endpoints.');
|
|
56
|
+
|
|
57
|
+
const appTypes = read('src/types/app.ts');
|
|
58
|
+
assert.match(appTypes, /'remote'/, 'Frontend tabs should include the remote console.');
|
|
59
|
+
|
|
60
|
+
const mainContent = read('src/components/main-content/view/MainContent.tsx');
|
|
61
|
+
assert.match(mainContent, /RemoteConsole/, 'Main content should render the remote console tab.');
|
|
62
|
+
|
|
63
|
+
const tabSwitcher = read('src/components/main-content/view/subcomponents/MainContentTabSwitcher.tsx');
|
|
64
|
+
assert.match(tabSwitcher, /tabs\.remote/, 'Tab switcher should expose the remote console tab.');
|
|
65
|
+
|
|
66
|
+
const remoteConsole = read('src/components/remote-console/RemoteConsole.tsx');
|
|
67
|
+
assert.match(remoteConsole, /control-room/, 'Remote console should load control-room snapshots.');
|
|
68
|
+
assert.match(remoteConsole, /approval queue/i, 'Remote console should show the approval queue.');
|
|
69
|
+
assert.match(remoteConsole, /webhook/i, 'Remote console should show webhook health.');
|
|
70
|
+
|
|
71
|
+
const docs = read('docs/self-hosted-agent-control-room.md');
|
|
72
|
+
assert.match(docs, /Remote Control/, 'Docs should explain remote control workflows.');
|
|
73
|
+
assert.match(docs, /Webhook/, 'Docs should explain webhook automation.');
|
|
74
|
+
assert.match(docs, /Telegram/, 'Docs should explain Telegram control.');
|
|
75
|
+
|
|
76
|
+
console.log('v1.43 remote control smoke passed');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
|
|
9
|
+
function read(relativePath) {
|
|
10
|
+
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const templates = read('server/modules/orchestration/workflows/workflow-templates.ts');
|
|
14
|
+
assert.match(templates, /PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL/, 'Workflow templates should declare a stable protocol id.');
|
|
15
|
+
assert.match(templates, /pixcode\.workflow-template\.v1/, 'Workflow templates should use the v1 protocol id.');
|
|
16
|
+
assert.match(templates, /bug_fix_team/, 'Bug fix team template is missing.');
|
|
17
|
+
assert.match(templates, /pr_review_team/, 'PR review team template is missing.');
|
|
18
|
+
assert.match(templates, /frontend_polish/, 'Frontend polish template is missing.');
|
|
19
|
+
assert.match(templates, /release_manager/, 'Release manager template is missing.');
|
|
20
|
+
assert.match(templates, /dependency_audit/, 'Dependency audit template is missing.');
|
|
21
|
+
assert.match(templates, /agentSlots/, 'Templates should use provider-independent agent slots.');
|
|
22
|
+
assert.match(templates, /acceptanceCriteria/, 'Templates should include acceptance criteria.');
|
|
23
|
+
assert.match(templates, /applyWorkflowTemplateToMetadata/, 'Templates should be applicable to run metadata.');
|
|
24
|
+
|
|
25
|
+
const routes = read('server/modules/orchestration/workflows/workflow.routes.ts');
|
|
26
|
+
assert.match(routes, /workflows\/templates/, 'Workflow routes should expose templates.');
|
|
27
|
+
assert.match(routes, /WORKFLOW_TEMPLATE_NOT_FOUND/, 'Workflow template start route should validate template ids.');
|
|
28
|
+
assert.match(routes, /applyWorkflowTemplateToMetadata/, 'Workflow routes should apply templates before starting runs.');
|
|
29
|
+
|
|
30
|
+
const trace = read('server/modules/orchestration/workflows/workflow-trace.ts');
|
|
31
|
+
assert.match(trace, /workflow\.trace\.template/, 'Trace timeline should surface template metadata.');
|
|
32
|
+
|
|
33
|
+
const page = read('src/components/orchestration/OrchestrationPage.tsx');
|
|
34
|
+
assert.match(page, /WorkflowTemplate/, 'Orchestration page should type workflow templates.');
|
|
35
|
+
assert.match(page, /applyTemplate/, 'Orchestration page should let users apply a template before launch.');
|
|
36
|
+
assert.match(page, /workflowTemplate/, 'Template run metadata should be sent with orchestration runs.');
|
|
37
|
+
|
|
38
|
+
const en = read('src/i18n/locales/en/common.json');
|
|
39
|
+
const tr = read('src/i18n/locales/tr/common.json');
|
|
40
|
+
assert.match(en, /"templates"/, 'English template UI label is missing.');
|
|
41
|
+
assert.match(tr, /"templates"/, 'Turkish template UI label is missing.');
|
|
42
|
+
|
|
43
|
+
console.log('workflow templates smoke passed');
|
package/server/index.js
CHANGED
|
@@ -78,6 +78,7 @@ import messagesRoutes from './routes/messages.js';
|
|
|
78
78
|
import diagnosticsRoutes from './routes/diagnostics.js';
|
|
79
79
|
import remoteRoutes from './routes/remote.js';
|
|
80
80
|
import publicApiRoutes from './routes/public-api.js';
|
|
81
|
+
import webhooksRoutes from './routes/webhooks.js';
|
|
81
82
|
import liveViewRoutes, { createLiveViewPublicRouter } from './routes/live-view.js';
|
|
82
83
|
import providerRoutes from './modules/providers/provider.routes.js';
|
|
83
84
|
import {
|
|
@@ -406,6 +407,9 @@ app.use('/api/remote', authenticateToken, remoteRoutes);
|
|
|
406
407
|
// Public automation manifest (protected so private host details only go to signed-in clients)
|
|
407
408
|
app.use('/api/public', authenticateToken, publicApiRoutes);
|
|
408
409
|
|
|
410
|
+
// Outbound webhook automation (protected)
|
|
411
|
+
app.use('/api/webhooks', authenticateToken, webhooksRoutes);
|
|
412
|
+
|
|
409
413
|
// Project Live View (protected control API + public share proxy)
|
|
410
414
|
app.use('/api/live-view', authenticateToken, liveViewRoutes);
|
|
411
415
|
|
|
@@ -31,6 +31,16 @@ export {
|
|
|
31
31
|
export { createOrchestrationTaskRouter } from './tasks/orchestration-task.routes.js';
|
|
32
32
|
export { orchestrationTaskService } from './tasks/orchestration-task.service.js';
|
|
33
33
|
export { createWorkflowRouter } from './workflows/workflow.routes.js';
|
|
34
|
+
export {
|
|
35
|
+
listPendingApprovals,
|
|
36
|
+
resolvePermissionApproval,
|
|
37
|
+
} from './workflows/approval-queue.js';
|
|
38
|
+
export {
|
|
39
|
+
PIXCODE_WORKFLOW_TEMPLATE_PROTOCOL,
|
|
40
|
+
applyWorkflowTemplateToMetadata,
|
|
41
|
+
builtInWorkflowTemplates,
|
|
42
|
+
getWorkflowTemplate,
|
|
43
|
+
} from './workflows/workflow-templates.js';
|
|
34
44
|
export { workflowRunner } from './workflows/workflow-runner.js';
|
|
35
45
|
export { workflowStore } from './workflows/workflow-store.js';
|
|
36
46
|
export { workspaceManager } from './workspace/workspace-manager.js';
|
|
@@ -66,6 +76,10 @@ export type {
|
|
|
66
76
|
OrchestrationTask,
|
|
67
77
|
OrchestrationTaskState,
|
|
68
78
|
} from './tasks/orchestration-task.types.js';
|
|
79
|
+
export type {
|
|
80
|
+
WorkflowTemplate,
|
|
81
|
+
WorkflowTemplateAgentSlot,
|
|
82
|
+
} from './workflows/workflow-templates.js';
|
|
69
83
|
export type {
|
|
70
84
|
Workflow,
|
|
71
85
|
WorkflowNode,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { WorkflowRun } from '@/modules/orchestration/workflows/workflow.types.js';
|
|
2
|
+
import { workflowStore } from '@/modules/orchestration/workflows/workflow-store.js';
|
|
3
|
+
|
|
4
|
+
export type ApprovalDecisionSource = 'ui' | 'telegram' | 'api';
|
|
5
|
+
|
|
6
|
+
export type ApprovalQueueItem = Record<string, unknown> & {
|
|
7
|
+
id: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
workflowId: string;
|
|
10
|
+
status: string;
|
|
11
|
+
requestedAt?: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function readRunApprovals(run: WorkflowRun): Array<Record<string, unknown>> {
|
|
15
|
+
const approvals = run.metadata?.pendingPermissionApprovals;
|
|
16
|
+
return Array.isArray(approvals)
|
|
17
|
+
? approvals.filter((approval): approval is Record<string, unknown> => Boolean(approval && typeof approval === 'object'))
|
|
18
|
+
: [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function normalizeApproval(run: WorkflowRun, approval: Record<string, unknown>): ApprovalQueueItem | null {
|
|
22
|
+
const id = typeof approval.id === 'string' && approval.id.trim() ? approval.id : null;
|
|
23
|
+
if (!id) return null;
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
...approval,
|
|
27
|
+
id,
|
|
28
|
+
runId: run.id,
|
|
29
|
+
workflowId: run.workflowId,
|
|
30
|
+
status: typeof approval.status === 'string' ? approval.status : 'pending',
|
|
31
|
+
requestedAt: typeof approval.requestedAt === 'number' ? approval.requestedAt : run.startedAt,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function listPendingApprovals(options: {
|
|
36
|
+
projectId?: string;
|
|
37
|
+
includeResolved?: boolean;
|
|
38
|
+
} = {}): ApprovalQueueItem[] {
|
|
39
|
+
const items: ApprovalQueueItem[] = [];
|
|
40
|
+
for (const run of workflowStore.listRuns()) {
|
|
41
|
+
if (options.projectId && run.metadata?.projectId !== options.projectId) continue;
|
|
42
|
+
for (const approval of readRunApprovals(run)) {
|
|
43
|
+
const item = normalizeApproval(run, approval);
|
|
44
|
+
if (!item) continue;
|
|
45
|
+
if (!options.includeResolved && item.status !== 'pending') continue;
|
|
46
|
+
items.push(item);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return items.sort((a, b) => Number(b.requestedAt ?? 0) - Number(a.requestedAt ?? 0));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolvePermissionApproval({
|
|
54
|
+
approvalId,
|
|
55
|
+
allow,
|
|
56
|
+
source = 'api',
|
|
57
|
+
resolvedBy,
|
|
58
|
+
message,
|
|
59
|
+
}: {
|
|
60
|
+
approvalId: string;
|
|
61
|
+
allow: boolean;
|
|
62
|
+
source?: ApprovalDecisionSource; // source: 'ui' | 'telegram' | 'api'
|
|
63
|
+
resolvedBy?: string | number | null;
|
|
64
|
+
message?: string;
|
|
65
|
+
}): {
|
|
66
|
+
runId: string;
|
|
67
|
+
pendingApprovals: ApprovalQueueItem[];
|
|
68
|
+
approvalHistory: ApprovalQueueItem[];
|
|
69
|
+
} | null {
|
|
70
|
+
for (const run of workflowStore.listRuns()) {
|
|
71
|
+
const approvals = readRunApprovals(run);
|
|
72
|
+
let changed = false;
|
|
73
|
+
const nextApprovals = approvals.map((approval) => {
|
|
74
|
+
if (approval.id !== approvalId) return approval;
|
|
75
|
+
changed = true;
|
|
76
|
+
return {
|
|
77
|
+
...approval,
|
|
78
|
+
status: allow ? 'allowed' : 'denied',
|
|
79
|
+
resolvedAt: Date.now(),
|
|
80
|
+
resolvedBy: resolvedBy ?? null,
|
|
81
|
+
decisionSource: source,
|
|
82
|
+
resolutionMessage: typeof message === 'string' && message.trim() ? message.trim() : undefined,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!changed) continue;
|
|
87
|
+
|
|
88
|
+
run.metadata = {
|
|
89
|
+
...run.metadata,
|
|
90
|
+
pendingPermissionApprovals: nextApprovals,
|
|
91
|
+
};
|
|
92
|
+
workflowStore.setRun(run);
|
|
93
|
+
|
|
94
|
+
const queueItems = nextApprovals
|
|
95
|
+
.map((approval) => normalizeApproval(run, approval))
|
|
96
|
+
.filter((approval): approval is ApprovalQueueItem => Boolean(approval));
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
runId: run.id,
|
|
100
|
+
pendingApprovals: queueItems.filter((approval) => approval.status === 'pending'),
|
|
101
|
+
approvalHistory: queueItems.filter((approval) => approval.status !== 'pending'),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
@@ -49,6 +49,8 @@ import {
|
|
|
49
49
|
notifyRunStopped,
|
|
50
50
|
notifyUserIfEnabled,
|
|
51
51
|
} from '@/services/notification-orchestrator.js';
|
|
52
|
+
// @ts-ignore — plain-JS service
|
|
53
|
+
import { dispatchWebhookEvent } from '@/services/webhooks.js';
|
|
52
54
|
|
|
53
55
|
const TERMINAL = new Set(['completed', 'failed', 'canceled']);
|
|
54
56
|
const SKIPPED = 'skipped';
|
|
@@ -1655,6 +1657,20 @@ class WorkflowRunner {
|
|
|
1655
1657
|
workflowStore.setRun(run);
|
|
1656
1658
|
orchestrationTaskService.updateFromWorkflowRun(run);
|
|
1657
1659
|
notifyWorkflowRunFinished(run);
|
|
1660
|
+
const webhookRunStatus = String(run.status);
|
|
1661
|
+
dispatchWebhookEvent({
|
|
1662
|
+
type: webhookRunStatus === 'completed'
|
|
1663
|
+
? 'run.completed'
|
|
1664
|
+
: webhookRunStatus === 'canceled'
|
|
1665
|
+
? 'run.canceled'
|
|
1666
|
+
: 'run.failed',
|
|
1667
|
+
payload: {
|
|
1668
|
+
runId: run.id,
|
|
1669
|
+
workflowId: run.workflowId,
|
|
1670
|
+
status: webhookRunStatus,
|
|
1671
|
+
error: readString(run.metadata?.error),
|
|
1672
|
+
},
|
|
1673
|
+
});
|
|
1658
1674
|
this.cancelingRuns.delete(run.id);
|
|
1659
1675
|
}
|
|
1660
1676
|
}
|
|
@@ -1687,6 +1703,15 @@ class WorkflowRunner {
|
|
|
1687
1703
|
|
|
1688
1704
|
if (decision.approvalRequest) {
|
|
1689
1705
|
notifyPermissionApprovalRequested(run, decision);
|
|
1706
|
+
dispatchWebhookEvent({
|
|
1707
|
+
type: 'approval.needed',
|
|
1708
|
+
payload: {
|
|
1709
|
+
runId: run.id,
|
|
1710
|
+
workflowId: run.workflowId,
|
|
1711
|
+
approvalId: decision.approvalRequest.id,
|
|
1712
|
+
capabilities: decision.capabilities,
|
|
1713
|
+
},
|
|
1714
|
+
});
|
|
1690
1715
|
}
|
|
1691
1716
|
}
|
|
1692
1717
|
|
|
@@ -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
|
: [];
|