@diff-review-system/drs 4.0.1 → 4.1.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 (139) hide show
  1. package/.pi/agents/review/unified-reviewer.md +2 -6
  2. package/.pi/agents/task/review-assistant.md +22 -0
  3. package/.pi/workflows/github-pr-fix-review-issues-stacked.yaml +10 -4
  4. package/.pi/workflows/github-pr-review-post.yaml +0 -1
  5. package/.pi/workflows/github-pr-review.yaml +14 -8
  6. package/.pi/workflows/github-pr-visual-explain.yaml +46 -1
  7. package/.pi/workflows/gitlab-mr-fix-review-issues-stacked.yaml +10 -4
  8. package/.pi/workflows/gitlab-mr-review.yaml +14 -8
  9. package/.pi/workflows/gitlab-mr-visual-explain.yaml +46 -1
  10. package/.pi/workflows/local-fix-review-issues.yaml +13 -6
  11. package/.pi/workflows/local-review.yaml +7 -1
  12. package/.pi/workflows/local-visual-explain.yaml +46 -1
  13. package/.pi/workflows/temporal-control-smoke.yaml +63 -0
  14. package/README.md +39 -0
  15. package/dist/cli/index.js +211 -4
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/cli/init.d.ts +6 -1
  18. package/dist/cli/init.d.ts.map +1 -1
  19. package/dist/cli/init.js +29 -10
  20. package/dist/cli/init.js.map +1 -1
  21. package/dist/cli/run-agent.d.ts +2 -7
  22. package/dist/cli/run-agent.d.ts.map +1 -1
  23. package/dist/cli/run-agent.js.map +1 -1
  24. package/dist/cli/workflow-executor-selection.d.ts +3 -0
  25. package/dist/cli/workflow-executor-selection.d.ts.map +1 -0
  26. package/dist/cli/workflow-executor-selection.js +15 -0
  27. package/dist/cli/workflow-executor-selection.js.map +1 -0
  28. package/dist/cli/workflow.d.ts +38 -42
  29. package/dist/cli/workflow.d.ts.map +1 -1
  30. package/dist/cli/workflow.js +190 -838
  31. package/dist/cli/workflow.js.map +1 -1
  32. package/dist/lib/agent-result.d.ts +8 -0
  33. package/dist/lib/agent-result.d.ts.map +1 -0
  34. package/dist/lib/agent-result.js +2 -0
  35. package/dist/lib/agent-result.js.map +1 -0
  36. package/dist/lib/config.d.ts +21 -0
  37. package/dist/lib/config.d.ts.map +1 -1
  38. package/dist/lib/config.js.map +1 -1
  39. package/dist/lib/output-paths.d.ts +0 -1
  40. package/dist/lib/output-paths.d.ts.map +1 -1
  41. package/dist/lib/output-paths.js +0 -1
  42. package/dist/lib/output-paths.js.map +1 -1
  43. package/dist/lib/project-setup.d.ts +10 -0
  44. package/dist/lib/project-setup.d.ts.map +1 -0
  45. package/dist/lib/project-setup.js +25 -0
  46. package/dist/lib/project-setup.js.map +1 -0
  47. package/dist/lib/review-artifact-store.d.ts +16 -0
  48. package/dist/lib/review-artifact-store.d.ts.map +1 -0
  49. package/dist/lib/review-artifact-store.js +84 -0
  50. package/dist/lib/review-artifact-store.js.map +1 -0
  51. package/dist/lib/review-artifact.d.ts.map +1 -1
  52. package/dist/lib/review-artifact.js +1 -0
  53. package/dist/lib/review-artifact.js.map +1 -1
  54. package/dist/lib/review-core.d.ts +1 -0
  55. package/dist/lib/review-core.d.ts.map +1 -1
  56. package/dist/lib/review-core.js +11 -14
  57. package/dist/lib/review-core.js.map +1 -1
  58. package/dist/lib/review-parser.d.ts.map +1 -1
  59. package/dist/lib/review-parser.js +15 -12
  60. package/dist/lib/review-parser.js.map +1 -1
  61. package/dist/lib/skills.d.ts +16 -0
  62. package/dist/lib/skills.d.ts.map +1 -0
  63. package/dist/lib/skills.js +140 -0
  64. package/dist/lib/skills.js.map +1 -0
  65. package/dist/lib/workflow/artifact-store.d.ts +71 -0
  66. package/dist/lib/workflow/artifact-store.d.ts.map +1 -0
  67. package/dist/lib/workflow/artifact-store.js +121 -0
  68. package/dist/lib/workflow/artifact-store.js.map +1 -0
  69. package/dist/lib/workflow/compiled-plan.d.ts +87 -0
  70. package/dist/lib/workflow/compiled-plan.d.ts.map +1 -0
  71. package/dist/lib/workflow/compiled-plan.js +62 -0
  72. package/dist/lib/workflow/compiled-plan.js.map +1 -0
  73. package/dist/lib/workflow/executor.d.ts +18 -0
  74. package/dist/lib/workflow/executor.d.ts.map +1 -0
  75. package/dist/lib/workflow/executor.js +2 -0
  76. package/dist/lib/workflow/executor.js.map +1 -0
  77. package/dist/lib/workflow/graph.d.ts +30 -0
  78. package/dist/lib/workflow/graph.d.ts.map +1 -0
  79. package/dist/lib/workflow/graph.js +139 -0
  80. package/dist/lib/workflow/graph.js.map +1 -0
  81. package/dist/lib/workflow/input.d.ts +4 -0
  82. package/dist/lib/workflow/input.d.ts.map +1 -0
  83. package/dist/lib/workflow/input.js +4 -0
  84. package/dist/lib/workflow/input.js.map +1 -0
  85. package/dist/lib/workflow/node-executor.d.ts +19 -0
  86. package/dist/lib/workflow/node-executor.d.ts.map +1 -0
  87. package/dist/lib/workflow/node-executor.js +2 -0
  88. package/dist/lib/workflow/node-executor.js.map +1 -0
  89. package/dist/lib/workflow/planning.d.ts +51 -0
  90. package/dist/lib/workflow/planning.d.ts.map +1 -0
  91. package/dist/lib/workflow/planning.js +814 -0
  92. package/dist/lib/workflow/planning.js.map +1 -0
  93. package/dist/lib/workflow/types.d.ts +66 -0
  94. package/dist/lib/workflow/types.d.ts.map +1 -0
  95. package/dist/lib/workflow/types.js +2 -0
  96. package/dist/lib/workflow/types.js.map +1 -0
  97. package/dist/lib/write-json-output.d.ts.map +1 -1
  98. package/dist/lib/write-json-output.js +3 -8
  99. package/dist/lib/write-json-output.js.map +1 -1
  100. package/dist/pi/sdk.d.ts.map +1 -1
  101. package/dist/pi/sdk.js +6 -2
  102. package/dist/pi/sdk.js.map +1 -1
  103. package/dist/runtime/built-in-paths.d.ts +1 -0
  104. package/dist/runtime/built-in-paths.d.ts.map +1 -1
  105. package/dist/runtime/built-in-paths.js +7 -0
  106. package/dist/runtime/built-in-paths.js.map +1 -1
  107. package/dist/temporal/activities.d.ts +26 -0
  108. package/dist/temporal/activities.d.ts.map +1 -0
  109. package/dist/temporal/activities.js +219 -0
  110. package/dist/temporal/activities.js.map +1 -0
  111. package/dist/temporal/config.d.ts +4 -0
  112. package/dist/temporal/config.d.ts.map +1 -0
  113. package/dist/temporal/config.js +36 -0
  114. package/dist/temporal/config.js.map +1 -0
  115. package/dist/temporal/executor.d.ts +7 -0
  116. package/dist/temporal/executor.d.ts.map +1 -0
  117. package/dist/temporal/executor.js +233 -0
  118. package/dist/temporal/executor.js.map +1 -0
  119. package/dist/temporal/retry-policy.d.ts +28 -0
  120. package/dist/temporal/retry-policy.d.ts.map +1 -0
  121. package/dist/temporal/retry-policy.js +56 -0
  122. package/dist/temporal/retry-policy.js.map +1 -0
  123. package/dist/temporal/types.d.ts +86 -0
  124. package/dist/temporal/types.d.ts.map +1 -0
  125. package/dist/temporal/types.js +2 -0
  126. package/dist/temporal/types.js.map +1 -0
  127. package/dist/temporal/worker.d.ts +3 -0
  128. package/dist/temporal/worker.d.ts.map +1 -0
  129. package/dist/temporal/worker.js +18 -0
  130. package/dist/temporal/worker.js.map +1 -0
  131. package/dist/temporal/workflow-id.d.ts +27 -0
  132. package/dist/temporal/workflow-id.d.ts.map +1 -0
  133. package/dist/temporal/workflow-id.js +53 -0
  134. package/dist/temporal/workflow-id.js.map +1 -0
  135. package/dist/temporal/workflows.d.ts +6 -0
  136. package/dist/temporal/workflows.d.ts.map +1 -0
  137. package/dist/temporal/workflows.js +342 -0
  138. package/dist/temporal/workflows.js.map +1 -0
  139. package/package.json +6 -1
@@ -0,0 +1,219 @@
1
+ import { ApplicationFailure, Context } from '@temporalio/activity';
2
+ import { mkdir, stat } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import simpleGit from 'simple-git';
5
+ import { loadConfig } from '../lib/config.js';
6
+ import { runWorkflowNodeLocally } from '../cli/workflow.js';
7
+ import { getLogger } from '../lib/logger.js';
8
+ import { isArtifactRef, shouldInline, LocalWorkflowArtifactStore, } from '../lib/workflow/artifact-store.js';
9
+ function safePathSegment(value) {
10
+ return value.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'unknown';
11
+ }
12
+ async function pathExists(path) {
13
+ try {
14
+ await stat(path);
15
+ return true;
16
+ }
17
+ catch (error) {
18
+ if (error.code === 'ENOENT') {
19
+ return false;
20
+ }
21
+ throw error;
22
+ }
23
+ }
24
+ function serializedSize(value) {
25
+ if (typeof value === 'string')
26
+ return Buffer.byteLength(value, 'utf-8');
27
+ return Buffer.byteLength(JSON.stringify(value, null, 2), 'utf-8');
28
+ }
29
+ function getCurrentActivityAttempt() {
30
+ try {
31
+ return Context.current().info.attempt;
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ export function isNonRetryableProviderFailure(error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ const normalized = message.toLowerCase();
40
+ const authOrConfigFailure = normalized.includes('authentication failed') ||
41
+ normalized.includes('unauthorized') ||
42
+ normalized.includes('invalid api key') ||
43
+ normalized.includes('api key') ||
44
+ normalized.includes('401') ||
45
+ normalized.includes('403') ||
46
+ normalized.includes('failed to resolve model') ||
47
+ (normalized.includes('model') && normalized.includes('not found')) ||
48
+ normalized.includes('model configuration is invalid');
49
+ const quotaFailure = normalized.includes('monthly usage limit') ||
50
+ normalized.includes('usage limit reached') ||
51
+ normalized.includes('quota') ||
52
+ normalized.includes('insufficient_quota') ||
53
+ normalized.includes('billing') ||
54
+ normalized.includes('available balance');
55
+ return authOrConfigFailure || quotaFailure;
56
+ }
57
+ export function resolveActivityIdempotencyContext(input) {
58
+ const scheduled = input.idempotencyContext;
59
+ if (!scheduled)
60
+ return undefined;
61
+ return {
62
+ workflowId: scheduled.workflowId,
63
+ runId: scheduled.runId,
64
+ nodeId: scheduled.nodeId,
65
+ attempt: getCurrentActivityAttempt() ?? scheduled.attempt ?? 1,
66
+ idempotencyKey: scheduled.idempotencyKey,
67
+ };
68
+ }
69
+ export async function prepareWorkspaceActivity(input) {
70
+ const workspaceDir = join(input.workspace.root, safePathSegment(input.workflowId), safePathSegment(input.runId));
71
+ const repoDir = join(workspaceDir, 'repo');
72
+ const logger = getLogger();
73
+ const logContext = {
74
+ component: 'temporal-activity',
75
+ workflowId: input.workflowId,
76
+ runId: input.runId,
77
+ workspaceMode: input.workspace.mode,
78
+ repoDir,
79
+ };
80
+ logger.debug('Temporal workspace preparation started', logContext);
81
+ await mkdir(workspaceDir, { recursive: true });
82
+ if (await pathExists(join(repoDir, '.git'))) {
83
+ const git = simpleGit(repoDir);
84
+ await git.fetch(['origin', input.workspace.ref, '--tags']);
85
+ await git.checkout(input.workspace.ref);
86
+ }
87
+ else {
88
+ await simpleGit().clone(input.workspace.repoUrl, repoDir, ['--no-checkout']);
89
+ const git = simpleGit(repoDir);
90
+ await git.fetch(['origin', input.workspace.ref, '--tags']);
91
+ await git.checkout(input.workspace.ref);
92
+ }
93
+ logger.debug('Temporal workspace preparation completed', logContext);
94
+ return { workingDir: repoDir };
95
+ }
96
+ /**
97
+ * Run the activity: executes one node locally, then offloads large outputs
98
+ * to the artifact store so Temporal history only carries refs.
99
+ */
100
+ export async function runWorkflowNodeActivity(input) {
101
+ const config = loadConfig(input.workingDir);
102
+ const idempotencyContext = resolveActivityIdempotencyContext(input);
103
+ const startedAt = Date.now();
104
+ const logContext = {
105
+ component: 'temporal-activity',
106
+ workflowId: idempotencyContext?.workflowId,
107
+ runId: idempotencyContext?.runId,
108
+ nodeId: input.nodeId,
109
+ attempt: idempotencyContext?.attempt,
110
+ action: input.node.action,
111
+ agent: input.node.agent,
112
+ };
113
+ const logger = getLogger();
114
+ logger.debug('Temporal activity started', logContext);
115
+ // Hydrate artifact refs in the node context so template rendering can
116
+ // access actual artifact values. The workflow passes hydrated artifacts,
117
+ // but hydrating here makes the activity resilient when called directly.
118
+ const store = new LocalWorkflowArtifactStore(input.workingDir, 'temporal');
119
+ try {
120
+ await hydrateContext(input.context.artifacts, store);
121
+ const result = await runWorkflowNodeLocally(config, input.nodeId, input.node, {
122
+ debug: input.options?.debug,
123
+ thinkingLevel: input.options?.thinkingLevel,
124
+ idempotencyContext,
125
+ workingDir: input.workingDir,
126
+ jsonOutput: true,
127
+ trace: false,
128
+ }, input.workingDir, input.context);
129
+ const finalResult = input.offloadArtifacts
130
+ ? await offloadNodeResult(result, input.nodeId, store, {
131
+ mode: 'ref-large-values',
132
+ inlineMaxBytes: input.artifactInlineMaxBytes ?? 64 * 1024,
133
+ })
134
+ : result;
135
+ logger.debug('Temporal activity completed', logContext, {
136
+ durationMs: Date.now() - startedAt,
137
+ status: finalResult.status ?? 'success',
138
+ });
139
+ return finalResult;
140
+ }
141
+ catch (error) {
142
+ logger.error('Temporal activity failed', logContext, {
143
+ durationMs: Date.now() - startedAt,
144
+ error: error instanceof Error ? error.message : String(error),
145
+ });
146
+ if (isNonRetryableProviderFailure(error)) {
147
+ throw ApplicationFailure.nonRetryable(error instanceof Error ? error.message : String(error), 'NonRetryableProviderFailure');
148
+ }
149
+ throw error;
150
+ }
151
+ }
152
+ async function offloadNodeResult(result, nodeId, store, policy) {
153
+ const offloaded = { ...result };
154
+ for (const field of ['output', 'response']) {
155
+ const value = offloaded[field];
156
+ if (value !== undefined && value !== null && !isArtifactRef(value)) {
157
+ if (!shouldInline(serializedSize(value), policy)) {
158
+ const ref = await store.put(`${nodeId}-${field}`, value);
159
+ offloaded[field] = ref;
160
+ }
161
+ }
162
+ }
163
+ if (offloaded.outputs) {
164
+ const newOutputs = {};
165
+ for (const [name, value] of Object.entries(offloaded.outputs)) {
166
+ if (value !== undefined &&
167
+ value !== null &&
168
+ !isArtifactRef(value) &&
169
+ !shouldInline(serializedSize(value), policy)) {
170
+ const ref = await store.put(`${nodeId}-outputs-${name}`, value);
171
+ newOutputs[name] = ref;
172
+ }
173
+ else {
174
+ newOutputs[name] = value;
175
+ }
176
+ }
177
+ offloaded.outputs = newOutputs;
178
+ }
179
+ if (offloaded.responses && Array.isArray(offloaded.responses)) {
180
+ const offloadedResponses = await Promise.all(offloaded.responses.map(async (entry, index) => {
181
+ if (entry === null || entry === undefined || isArtifactRef(entry))
182
+ return entry;
183
+ if (shouldInline(serializedSize(entry), policy))
184
+ return entry;
185
+ const ref = await store.put(`${nodeId}-responses-${index}`, entry);
186
+ return ref;
187
+ }));
188
+ offloaded.responses = offloadedResponses;
189
+ }
190
+ return offloaded;
191
+ }
192
+ /**
193
+ * Resolve a targeted set of artifact refs to their actual values. Called by
194
+ * the Temporal workflow only for the specific artifact keys referenced by
195
+ * upcoming control-flow expressions (if/switch/loop), so large values that
196
+ * are not needed for branching stay as refs and never enter workflow state or
197
+ * event history.
198
+ */
199
+ export async function resolveArtifactRefsActivity(input) {
200
+ const store = new LocalWorkflowArtifactStore(input.workingDir, 'temporal');
201
+ const resolved = {};
202
+ for (const [key, ref] of Object.entries(input.refs)) {
203
+ resolved[key] = await store.get(ref);
204
+ }
205
+ return resolved;
206
+ }
207
+ /**
208
+ * Hydrate artifact refs within a template context before rendering node
209
+ * templates in the worker process. Called by activities that need to read
210
+ * prior artifact values.
211
+ */
212
+ export async function hydrateContext(context, store) {
213
+ for (const [key, value] of Object.entries(context)) {
214
+ if (isArtifactRef(value)) {
215
+ context[key] = await store.get(value);
216
+ }
217
+ }
218
+ }
219
+ //# sourceMappingURL=activities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities.js","sourceRoot":"","sources":["../../src/temporal/activities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,0BAA0B,GAC3B,M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,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAgC,EAChC,KAAiC;IAEjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DRSConfig } from '../lib/config.js';
2
+ import type { TemporalConfig } from './types.js';
3
+ export declare function resolveTemporalConfig(config: DRSConfig): TemporalConfig;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/temporal/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAajD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CA4BvE"}
@@ -0,0 +1,36 @@
1
+ const DEFAULT_TEMPORAL_CONFIG = {
2
+ address: 'localhost:7233',
3
+ namespace: 'default',
4
+ taskQueue: 'drs-workflows',
5
+ workflowIdPrefix: 'drs',
6
+ workspace: {
7
+ mode: 'local',
8
+ root: '/tmp/drs-temporal-workspaces',
9
+ },
10
+ };
11
+ export function resolveTemporalConfig(config) {
12
+ const configured = config.temporal ?? {};
13
+ const configuredWorkspace = configured.workspace ?? {};
14
+ const envMode = process.env.DRS_TEMPORAL_WORKSPACE_MODE;
15
+ const mode = envMode === 'managed' || envMode === 'local' ? envMode : configuredWorkspace.mode;
16
+ return {
17
+ ...DEFAULT_TEMPORAL_CONFIG,
18
+ ...configured,
19
+ address: process.env.DRS_TEMPORAL_ADDRESS ?? configured.address ?? DEFAULT_TEMPORAL_CONFIG.address,
20
+ namespace: process.env.DRS_TEMPORAL_NAMESPACE ??
21
+ configured.namespace ??
22
+ DEFAULT_TEMPORAL_CONFIG.namespace,
23
+ taskQueue: process.env.DRS_TEMPORAL_TASK_QUEUE ??
24
+ configured.taskQueue ??
25
+ DEFAULT_TEMPORAL_CONFIG.taskQueue,
26
+ workspace: {
27
+ ...DEFAULT_TEMPORAL_CONFIG.workspace,
28
+ ...configuredWorkspace,
29
+ ...(mode ? { mode } : {}),
30
+ ...(process.env.DRS_TEMPORAL_WORKSPACE_ROOT
31
+ ? { root: process.env.DRS_TEMPORAL_WORKSPACE_ROOT }
32
+ : {}),
33
+ },
34
+ };
35
+ }
36
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/temporal/config.ts"],"names":[],"mappings":"AAGA,MAAM,uBAAuB,GAAmB;IAC9C,OAAO,EAAE,gBAAgB;IACzB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,eAAe;IAC1B,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE;QACT,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,8BAA8B;KACrC;CACF,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IACzC,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;IACxD,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;IAE/F,OAAO;QACL,GAAG,uBAAuB;QAC1B,GAAG,UAAU;QACb,OAAO,EACL,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,UAAU,CAAC,OAAO,IAAI,uBAAuB,CAAC,OAAO;QAC3F,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAClC,UAAU,CAAC,SAAS;YACpB,uBAAuB,CAAC,SAAS;QACnC,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,uBAAuB;YACnC,UAAU,CAAC,SAAS;YACpB,uBAAuB,CAAC,SAAS;QACnC,SAAS,EAAE;YACT,GAAG,uBAAuB,CAAC,SAAS;YACpC,GAAG,mBAAmB;YACtB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B;gBACzC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE;gBACnD,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { DRSConfig } from '../lib/config.js';
2
+ import type { WorkflowExecutor } from '../lib/workflow/executor.js';
3
+ import type { WorkflowRunOptions, WorkflowRunResult } from '../lib/workflow/types.js';
4
+ export declare class TemporalWorkflowExecutor implements WorkflowExecutor {
5
+ run(config: DRSConfig, workflowName: string, options?: WorkflowRunOptions): Promise<WorkflowRunResult>;
6
+ }
7
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/temporal/executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAkLtF,qBAAa,wBAAyB,YAAW,gBAAgB;IACzD,GAAG,CACP,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC;CA2H9B"}
@@ -0,0 +1,233 @@
1
+ import { mkdir, readFile, writeFile } from 'fs/promises';
2
+ import { dirname } from 'path';
3
+ import { Connection, Client, WorkflowExecutionAlreadyStartedError } from '@temporalio/client';
4
+ import chalk from 'chalk';
5
+ import simpleGit from 'simple-git';
6
+ import { getLogger } from '../lib/logger.js';
7
+ import { resolveWithinWorkingDir } from '../lib/path-utils.js';
8
+ import { saveWorkflowArtifact } from '../lib/workflow-artifacts.js';
9
+ import { compileWorkflowPlan } from '../lib/workflow/compiled-plan.js';
10
+ import { normalizeWorkflowBooleanLike } from '../lib/workflow/planning.js';
11
+ import { resolveTemporalConfig } from './config.js';
12
+ import { deriveTemporalWorkflowId } from './workflow-id.js';
13
+ async function writeWorkflowFile(workingDir, outputPath, content) {
14
+ const resolved = resolveWithinWorkingDir(workingDir, outputPath, 'write');
15
+ await mkdir(dirname(resolved), { recursive: true });
16
+ await writeFile(resolved, content, 'utf-8');
17
+ }
18
+ function formatWorkflowJson(result) {
19
+ return JSON.stringify(result, null, 2);
20
+ }
21
+ async function saveTemporalWorkflowTrace(workingDir, workflowName, startedAt, result, temporal, handle, options) {
22
+ const saved = await saveWorkflowArtifact(workingDir, {
23
+ kind: 'trace',
24
+ scope: {
25
+ platform: 'temporal',
26
+ projectId: workflowName,
27
+ subject: 'workflow',
28
+ },
29
+ payload: {
30
+ schemaVersion: 1,
31
+ executor: 'temporal',
32
+ workflowName,
33
+ temporal: {
34
+ workflowId: handle.workflowId,
35
+ runId: handle.firstExecutionRunId,
36
+ namespace: temporal.namespace,
37
+ taskQueue: temporal.taskQueue,
38
+ },
39
+ startedAt,
40
+ completedAt: new Date().toISOString(),
41
+ inputs: result.inputs,
42
+ nodes: result.nodes,
43
+ artifacts: result.artifacts,
44
+ loop: result.loop,
45
+ output: result.output,
46
+ },
47
+ });
48
+ if (!options.jsonOutput) {
49
+ console.log(chalk.green(`\n✓ Temporal trace saved to ${saved.latestPath}`));
50
+ }
51
+ }
52
+ function validateResolvedWorkflowInput(key, input, value) {
53
+ if (input.required === true && value.trim() === '') {
54
+ throw new Error(`Workflow input "${key}" is required.`);
55
+ }
56
+ if (input.type === 'boolean') {
57
+ if (normalizeWorkflowBooleanLike(value) === undefined) {
58
+ throw new Error(`Workflow input "${key}" must be a boolean value.`);
59
+ }
60
+ return;
61
+ }
62
+ if (input.type === 'number') {
63
+ if (value.trim() === '' || !Number.isFinite(Number(value))) {
64
+ throw new Error(`Workflow input "${key}" must be a number.`);
65
+ }
66
+ return;
67
+ }
68
+ if (input.type === 'enum') {
69
+ const allowedValues = input.values?.map(String) ?? [];
70
+ if (allowedValues.length === 0) {
71
+ throw new Error(`Workflow input "${key}" with type enum must define values.`);
72
+ }
73
+ if (!allowedValues.includes(value)) {
74
+ throw new Error(`Workflow input "${key}" must be one of: ${allowedValues.join(', ')}.`);
75
+ }
76
+ return;
77
+ }
78
+ if (input.type !== 'string') {
79
+ throw new Error(`Workflow input "${key}" has unsupported type "${input.type}".`);
80
+ }
81
+ }
82
+ async function resolveManagedWorkspaceInput(workingDir, temporal) {
83
+ if (temporal.workspace.mode !== 'managed') {
84
+ return undefined;
85
+ }
86
+ const git = simpleGit(workingDir);
87
+ const configuredRepoUrl = process.env.DRS_TEMPORAL_WORKSPACE_REPO_URL;
88
+ const repoUrl = configuredRepoUrl ?? String(await git.remote(['get-url', 'origin']));
89
+ const ref = process.env.DRS_TEMPORAL_WORKSPACE_REF ?? (await git.revparse(['HEAD']));
90
+ return {
91
+ mode: 'managed',
92
+ root: temporal.workspace.root,
93
+ repoUrl: repoUrl.trim(),
94
+ ref: ref.trim(),
95
+ };
96
+ }
97
+ async function resolveCompiledPlanInputs(inputs, options, workingDir) {
98
+ const values = {};
99
+ for (const [key, input] of Object.entries(inputs)) {
100
+ const hasValue = input.value !== undefined || input.default !== undefined;
101
+ const hasFile = input.file !== undefined;
102
+ if (hasValue && hasFile) {
103
+ throw new Error(`Workflow input "${key}" cannot define both value/default and file.`);
104
+ }
105
+ if (hasValue) {
106
+ values[key] = String(input.value ?? input.default ?? '');
107
+ }
108
+ else if (hasFile) {
109
+ const inputPath = resolveWithinWorkingDir(workingDir, input.file ?? '', 'read');
110
+ values[key] = await readFile(inputPath, 'utf-8');
111
+ }
112
+ else {
113
+ values[key] = '';
114
+ }
115
+ }
116
+ for (const [key, value] of Object.entries(options.inputs ?? {})) {
117
+ values[key] = value;
118
+ }
119
+ for (const [key, filePath] of Object.entries(options.inputFiles ?? {})) {
120
+ const resolvedPath = resolveWithinWorkingDir(workingDir, filePath, 'read');
121
+ values[key] = await readFile(resolvedPath, 'utf-8');
122
+ }
123
+ for (const [key, input] of Object.entries(inputs)) {
124
+ validateResolvedWorkflowInput(key, input, values[key] ?? '');
125
+ }
126
+ return values;
127
+ }
128
+ export class TemporalWorkflowExecutor {
129
+ async run(config, workflowName, options = {}) {
130
+ const workingDir = options.workingDir ?? process.cwd();
131
+ const temporal = resolveTemporalConfig(config);
132
+ const plan = compileWorkflowPlan(config, workflowName, { workingDir });
133
+ const inputs = await resolveCompiledPlanInputs(plan.inputs, options, workingDir);
134
+ const logger = getLogger();
135
+ const startedAt = new Date().toISOString();
136
+ const connection = await Connection.connect({ address: temporal.address });
137
+ try {
138
+ const client = new Client({ connection, namespace: temporal.namespace });
139
+ const workflowId = options.workflowId ??
140
+ deriveTemporalWorkflowId(temporal.workflowIdPrefix, workflowName, inputs);
141
+ const workspace = await resolveManagedWorkspaceInput(workingDir, temporal);
142
+ const workflowInput = {
143
+ plan,
144
+ inputs,
145
+ workingDir,
146
+ options: {
147
+ debug: options.debug,
148
+ thinkingLevel: options.thinkingLevel,
149
+ },
150
+ ...(workspace ? { workspace } : {}),
151
+ };
152
+ let handle;
153
+ let isDuplicate = false;
154
+ try {
155
+ handle = await client.workflow.start('drsWorkflow', {
156
+ taskQueue: temporal.taskQueue,
157
+ workflowId,
158
+ args: [workflowInput],
159
+ });
160
+ }
161
+ catch (error) {
162
+ if (error instanceof WorkflowExecutionAlreadyStartedError) {
163
+ isDuplicate = true;
164
+ handle = client.workflow.getHandle(workflowId);
165
+ logger.debug('Temporal workflow already running — joining existing run', {
166
+ component: 'temporal-executor',
167
+ workflow: workflowName,
168
+ workflowId,
169
+ namespace: temporal.namespace,
170
+ taskQueue: temporal.taskQueue,
171
+ });
172
+ }
173
+ else {
174
+ throw error;
175
+ }
176
+ }
177
+ const runId = handle.firstExecutionRunId ?? '';
178
+ const logContext = {
179
+ component: 'temporal-executor',
180
+ workflow: workflowName,
181
+ workflowId: handle.workflowId,
182
+ runId,
183
+ namespace: temporal.namespace,
184
+ taskQueue: temporal.taskQueue,
185
+ ...(isDuplicate ? { duplicate: true } : {}),
186
+ };
187
+ logger.debug(isDuplicate ? 'Temporal workflow already running' : 'Temporal workflow started', logContext);
188
+ if (options.wait === false) {
189
+ const result = {
190
+ timestamp: new Date().toISOString(),
191
+ workflow: workflowName,
192
+ inputs,
193
+ nodes: {},
194
+ artifacts: {},
195
+ loop: {},
196
+ output: {
197
+ workflowId: handle.workflowId,
198
+ runId,
199
+ },
200
+ };
201
+ if (options.jsonOutput) {
202
+ console.log(formatWorkflowJson(result));
203
+ }
204
+ else {
205
+ console.log(`Temporal workflow ${isDuplicate ? 'already running' : 'started'}: ${handle.workflowId}${runId ? ` (run ${runId})` : ''}`);
206
+ }
207
+ return result;
208
+ }
209
+ const result = await handle.result();
210
+ logger.debug('Temporal workflow completed', logContext);
211
+ if (options.trace) {
212
+ await saveTemporalWorkflowTrace(workingDir, workflowName, startedAt, result, temporal, { workflowId: handle.workflowId, firstExecutionRunId: runId }, options);
213
+ }
214
+ if (options.outputPath) {
215
+ await writeWorkflowFile(workingDir, options.outputPath, formatWorkflowJson(result));
216
+ if (!options.jsonOutput) {
217
+ console.log(chalk.green(`\n✓ Workflow output saved to ${options.outputPath}`));
218
+ }
219
+ }
220
+ if (options.jsonOutput) {
221
+ console.log(formatWorkflowJson(result));
222
+ }
223
+ else if (typeof result.output === 'string' && result.output.trim()) {
224
+ console.log(`\n${result.output}`);
225
+ }
226
+ return result;
227
+ }
228
+ finally {
229
+ await connection.close();
230
+ }
231
+ }
232
+ }
233
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/temporal/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAA8B,MAAM,kCAAkC,CAAC;AAEnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,KAAK,UAAU,iBAAiB,CAC9B,UAAkB,EAClB,UAAkB,EAClB,OAAe;IAEf,MAAM,QAAQ,GAAG,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,E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,UAAU,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;gBACpF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,gCAAgC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;gBACjF,CAAC;YACH,CAAC;YAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;YAC1C,CAAC;iBAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBACrE,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACpC,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import type { WorkflowNodeConfig } from '../lib/config.js';
2
+ import type { RetryPolicy } from '@temporalio/common';
3
+ export type TemporalNodeRetryMode = 'retryable' | 'no-retry';
4
+ export declare const TEMPORAL_NO_RETRY_ACTIONS: Set<NonNullable<"write" | "git-diff" | "git-add" | "git-branch" | "git-commit" | "git-push" | "has-diff" | "stack-guard" | "review-threshold" | "save-artifact" | "load-artifact" | "artifact-exists" | "create-review-artifact" | "review-artifact-status" | "review-artifact-add-finding" | "review-artifact-update-findings" | "verify-fix" | "review-artifact-promote-finding" | "review-artifact-resolve-finding" | "create-change-request" | "create-pr" | "create-mr" | "change-source" | "review" | "review-context" | "describe" | "code-quality-report" | "post-comment" | "post-review-comments" | "post-fix-status" | undefined>>;
5
+ /**
6
+ * Retry policy for retryable DRS workflow activities (read-only actions and
7
+ * non-writing agent nodes).
8
+ *
9
+ * Temporal's default activity retry is effectively unlimited
10
+ * (`maximumAttempts: Infinity`) with exponential backoff. Without an explicit
11
+ * cap, a transiently failing activity (model 5xx, rate limit, network blip)
12
+ * can retry for a very long time. This policy bounds retries so a persistently
13
+ * failing activity fails the workflow in minutes rather than hours or days.
14
+ *
15
+ * - `maximumAttempts: 5` — enough to ride out transient failures, bounded.
16
+ * - `initialInterval: 1s` with `backoffCoefficient: 2` — standard exponential
17
+ * backoff (1s, 2s, 4s, 8s between attempts).
18
+ * - `maximumInterval: 1 minute` — caps backoff growth so later retries don't
19
+ * stall for too long.
20
+ * - `nonRetryableErrorTypes: ['NonRetryableProviderFailure']` —
21
+ * defense-in-depth: provider quota/auth failures are already converted to
22
+ * `ApplicationFailure.nonRetryable` in the activity, but listing the type
23
+ * here ensures Temporal never retries them even if the non-retryable flag
24
+ * is lost in serialization.
25
+ */
26
+ export declare const TEMPORAL_RETRYABLE_ACTIVITY_POLICY: RetryPolicy;
27
+ export declare function getTemporalNodeRetryMode(node: WorkflowNodeConfig): TemporalNodeRetryMode;
28
+ //# sourceMappingURL=retry-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../../src/temporal/retry-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,UAAU,CAAC;AAE7D,eAAO,MAAM,yBAAyB,+mBAiBpC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kCAAkC,EAAE,WAMhD,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,qBAAqB,CAUxF"}
@@ -0,0 +1,56 @@
1
+ export const TEMPORAL_NO_RETRY_ACTIONS = new Set([
2
+ 'write',
3
+ 'git-add',
4
+ 'git-branch',
5
+ 'git-commit',
6
+ 'git-push',
7
+ 'save-artifact',
8
+ 'review-artifact-add-finding',
9
+ 'review-artifact-update-findings',
10
+ 'review-artifact-promote-finding',
11
+ 'review-artifact-resolve-finding',
12
+ 'create-change-request',
13
+ 'create-pr',
14
+ 'create-mr',
15
+ 'post-comment',
16
+ 'post-review-comments',
17
+ 'post-fix-status',
18
+ ]);
19
+ /**
20
+ * Retry policy for retryable DRS workflow activities (read-only actions and
21
+ * non-writing agent nodes).
22
+ *
23
+ * Temporal's default activity retry is effectively unlimited
24
+ * (`maximumAttempts: Infinity`) with exponential backoff. Without an explicit
25
+ * cap, a transiently failing activity (model 5xx, rate limit, network blip)
26
+ * can retry for a very long time. This policy bounds retries so a persistently
27
+ * failing activity fails the workflow in minutes rather than hours or days.
28
+ *
29
+ * - `maximumAttempts: 5` — enough to ride out transient failures, bounded.
30
+ * - `initialInterval: 1s` with `backoffCoefficient: 2` — standard exponential
31
+ * backoff (1s, 2s, 4s, 8s between attempts).
32
+ * - `maximumInterval: 1 minute` — caps backoff growth so later retries don't
33
+ * stall for too long.
34
+ * - `nonRetryableErrorTypes: ['NonRetryableProviderFailure']` —
35
+ * defense-in-depth: provider quota/auth failures are already converted to
36
+ * `ApplicationFailure.nonRetryable` in the activity, but listing the type
37
+ * here ensures Temporal never retries them even if the non-retryable flag
38
+ * is lost in serialization.
39
+ */
40
+ export const TEMPORAL_RETRYABLE_ACTIVITY_POLICY = {
41
+ maximumAttempts: 5,
42
+ initialInterval: '1 second',
43
+ backoffCoefficient: 2,
44
+ maximumInterval: '1 minute',
45
+ nonRetryableErrorTypes: ['NonRetryableProviderFailure'],
46
+ };
47
+ export function getTemporalNodeRetryMode(node) {
48
+ if (node.action && TEMPORAL_NO_RETRY_ACTIONS.has(node.action)) {
49
+ return 'no-retry';
50
+ }
51
+ if ((node.agent || node.agentsFrom) && node.writes) {
52
+ return 'no-retry';
53
+ }
54
+ return 'retryable';
55
+ }
56
+ //# sourceMappingURL=retry-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../../src/temporal/retry-policy.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAA4C;IAC1F,OAAO;IACP,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,eAAe;IACf,6BAA6B;IAC7B,iCAAiC;IACjC,iCAAiC;IACjC,iCAAiC;IACjC,uBAAuB;IACvB,WAAW;IACX,WAAW;IACX,cAAc;IACd,sBAAsB;IACtB,iBAAiB;CAClB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAgB;IAC7D,eAAe,EAAE,CAAC;IAClB,eAAe,EAAE,UAAU;IAC3B,kBAAkB,EAAE,CAAC;IACrB,eAAe,EAAE,UAAU;IAC3B,sBAAsB,EAAE,CAAC,6BAA6B,CAAC;CACxD,CAAC;AAEF,MAAM,UAAU,wBAAwB,CAAC,IAAwB;IAC/D,IAAI,IAAI,CAAC,MAAM,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACnD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}