@atolis-hq/wake 0.4.110 → 0.4.111
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/src/bootstrap/board-projection.d.ts +4 -0
- package/dist/src/bootstrap/board-projection.js +33 -19
- package/dist/src/bootstrap/composition-root.d.ts +3 -1
- package/dist/src/bootstrap/composition-root.js +21 -6
- package/dist/src/bootstrap/delegated-artifact-context.d.ts +15 -0
- package/dist/src/bootstrap/delegated-artifact-context.js +17 -0
- package/dist/src/bootstrap/initialise.js +20 -2
- package/dist/src/bootstrap/integration-runtime.js +1 -0
- package/dist/src/bootstrap/objective-title-context.d.ts +7 -0
- package/dist/src/bootstrap/objective-title-context.js +15 -0
- package/dist/src/bootstrap/surface-api-delivery.js +6 -1
- package/dist/src/bootstrap/surface-api-work-applications.js +39 -5
- package/dist/src/bootstrap/surface-api-workflow-diagrams.js +8 -4
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/conversations/application/control-plane-entry.d.ts +14 -0
- package/dist/src/conversations/application/control-plane-entry.js +16 -0
- package/dist/src/conversations/index.d.ts +1 -0
- package/dist/src/conversations/index.js +1 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.d.ts +2 -1
- package/dist/src/integrations/application/agent-run-publication-reactor.js +6 -17
- package/dist/src/integrations/application/agent-run-publication-target.d.ts +12 -0
- package/dist/src/integrations/application/agent-run-publication-target.js +31 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +4 -2
- package/dist/src/integrations/contracts/provider.d.ts +5 -0
- package/dist/src/integrations/github/application/inbound-translator.d.ts +7 -0
- package/dist/src/integrations/github/application/inbound-translator.js +46 -0
- package/dist/src/integrations/github/provider.js +1 -0
- package/dist/src/orchestration/application/conversation-command-reactor.js +6 -25
- package/dist/src/orchestration/application/delegated-work.d.ts +12 -2
- package/dist/src/orchestration/application/delegated-work.js +30 -3
- package/dist/src/orchestration/application/delegation-attention-state.d.ts +2 -0
- package/dist/src/orchestration/application/delegation-attention-state.js +11 -1
- package/dist/src/orchestration/application/delegation-attention.d.ts +9 -11
- package/dist/src/orchestration/application/delegation-attention.js +42 -23
- package/dist/src/orchestration/application/orchestration-service.d.ts +11 -4
- package/dist/src/orchestration/application/orchestration-service.js +22 -16
- package/dist/src/orchestration/application/prerequisite-readiness.d.ts +8 -0
- package/dist/src/orchestration/application/prerequisite-readiness.js +35 -0
- package/dist/src/orchestration/contracts/delegation-ports.d.ts +16 -0
- package/dist/src/orchestration/contracts/delegation.d.ts +6 -4
- package/dist/src/orchestration/contracts/delegation.js +13 -3
- package/dist/src/orchestration/contracts/vocabulary.d.ts +1 -0
- package/dist/src/orchestration/contracts/vocabulary.js +1 -0
- package/dist/src/orchestration/domain/delegated-brief.d.ts +8 -0
- package/dist/src/orchestration/domain/delegated-brief.js +35 -0
- package/dist/src/orchestration/index.d.ts +1 -1
- package/dist/src/resources/contracts/events.js +1 -0
- package/dist/src/resources/contracts/vocabulary.d.ts +2 -0
- package/dist/src/resources/contracts/vocabulary.js +2 -0
- package/dist/src/surfaces/api/contracts/board.d.ts +4 -0
- package/dist/src/surfaces/api/contracts/work.d.ts +9 -0
- package/dist/src/surfaces/mcp/delegation.js +2 -2
- package/dist/src/surfaces/web-assets/assets/index-CHhBIiQQ.js +1192 -0
- package/dist/src/surfaces/web-assets/assets/index-DKNzCDQl.css +1 -0
- package/dist/src/surfaces/web-assets/index.html +2 -2
- package/docker/Dockerfile.runtime +10 -1
- package/docker/Dockerfile.runtime.packaged +10 -1
- package/package.json +1 -1
- package/dist/src/orchestration/application/delegation-attention-escalations.d.ts +0 -11
- package/dist/src/orchestration/application/delegation-attention-escalations.js +0 -36
- package/dist/src/surfaces/web-assets/assets/index-CJVgp3N-.js +0 -1192
- package/dist/src/surfaces/web-assets/assets/index-EVgZ9q9N.css +0 -1
|
@@ -34,6 +34,10 @@ interface StoredCard {
|
|
|
34
34
|
readonly blockReason?: string;
|
|
35
35
|
readonly dwellSince: string;
|
|
36
36
|
readonly runCount: number;
|
|
37
|
+
/** Set on delegated children; present only for work created after delegation existed. */
|
|
38
|
+
readonly parentWorkItemKey?: string;
|
|
39
|
+
/** Delegated children created under this card's work item. */
|
|
40
|
+
readonly childCount?: number;
|
|
37
41
|
readonly activeRuns: Readonly<Record<string, StoredActiveRun>>;
|
|
38
42
|
readonly activeRun?: StoredActiveRun;
|
|
39
43
|
readonly lastRunAt?: string;
|
|
@@ -51,28 +51,42 @@ export function boardConditionCounts(view) {
|
|
|
51
51
|
return counts;
|
|
52
52
|
}, {});
|
|
53
53
|
}
|
|
54
|
+
function projectItemCreated(view, id, payload, occurredAt) {
|
|
55
|
+
const parentId = payload.delegation?.parentWorkItemId;
|
|
56
|
+
const parent = parentId === undefined ? undefined : view.cards[parentId];
|
|
57
|
+
const card = {
|
|
58
|
+
workItemKey: toWorkItemKey(id),
|
|
59
|
+
workItemId: id,
|
|
60
|
+
objective: payload.objective,
|
|
61
|
+
condition: BoardCondition.Ready,
|
|
62
|
+
dwellSince: occurredAt,
|
|
63
|
+
runCount: 0,
|
|
64
|
+
activeRuns: {},
|
|
65
|
+
totalTokens: 0,
|
|
66
|
+
inputTokens: 0,
|
|
67
|
+
outputTokens: 0,
|
|
68
|
+
cacheReadTokens: 0,
|
|
69
|
+
cacheWriteTokens: 0,
|
|
70
|
+
totalCostUsd: 0,
|
|
71
|
+
totalDurationMs: 0,
|
|
72
|
+
...(parentId === undefined ? {} : { parentWorkItemKey: toWorkItemKey(parentId) }),
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
...view,
|
|
76
|
+
cards: {
|
|
77
|
+
...view.cards,
|
|
78
|
+
[id]: card,
|
|
79
|
+
...(parent === undefined
|
|
80
|
+
? {}
|
|
81
|
+
: { [parent.workItemId]: { ...parent, childCount: (parent.childCount ?? 0) + 1 } }),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
54
85
|
function projectWork(view, event, occurredAt) {
|
|
55
86
|
const id = event.stream.id;
|
|
56
87
|
const data = event.event;
|
|
57
|
-
if (data.eventType === WorkEventType.ItemCreated)
|
|
58
|
-
|
|
59
|
-
workItemKey: toWorkItemKey(id),
|
|
60
|
-
workItemId: id,
|
|
61
|
-
objective: data.payload.objective,
|
|
62
|
-
condition: BoardCondition.Ready,
|
|
63
|
-
dwellSince: occurredAt,
|
|
64
|
-
runCount: 0,
|
|
65
|
-
activeRuns: {},
|
|
66
|
-
totalTokens: 0,
|
|
67
|
-
inputTokens: 0,
|
|
68
|
-
outputTokens: 0,
|
|
69
|
-
cacheReadTokens: 0,
|
|
70
|
-
cacheWriteTokens: 0,
|
|
71
|
-
totalCostUsd: 0,
|
|
72
|
-
totalDurationMs: 0,
|
|
73
|
-
};
|
|
74
|
-
return { ...view, cards: { ...view.cards, [id]: card } };
|
|
75
|
-
}
|
|
88
|
+
if (data.eventType === WorkEventType.ItemCreated)
|
|
89
|
+
return projectItemCreated(view, id, data.payload, occurredAt);
|
|
76
90
|
const current = view.cards[id];
|
|
77
91
|
if (current === undefined)
|
|
78
92
|
return view;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CheckpointStore, type EventJournal, type ProcessorRunSerialiser, type ProcessorStateStore, type ProjectionStore } from '@atolis-hq/eventing';
|
|
2
2
|
import { createPullRequestService, type ActivityRegistry } from '../activities/index.js';
|
|
3
|
-
import { OperatorInstructionsService, createArtifactService } from '../artifacts/index.js';
|
|
3
|
+
import { ArtifactContextService, OperatorInstructionsService, createArtifactService } from '../artifacts/index.js';
|
|
4
4
|
import { createControlPlaneService, createRunnerControlService, type ActivationScheduler, type ActivationSchedulerSubscriber, type IntakePipeline, type RunnerPipeline, type TriggerCheckpointStore, type TriggerConfig, type TriggerService } from '../control-plane/index.js';
|
|
5
5
|
import { createConversationService } from '../conversations/index.js';
|
|
6
6
|
import { GitWorkspaceProvider, RecoveryService, TranscriptStore, createExecutionService, type FakeScenarioResolver, type RepositoryCloneResolver, type Runner } from '../execution/index.js';
|
|
@@ -55,6 +55,7 @@ export interface CompositionRoot {
|
|
|
55
55
|
readonly activities: ActivityRegistry;
|
|
56
56
|
readonly work: ReturnType<typeof createWorkService>;
|
|
57
57
|
readonly artifacts: ReturnType<typeof createArtifactService>;
|
|
58
|
+
readonly artifactContexts: ArtifactContextService;
|
|
58
59
|
readonly operatorInstructions: OperatorInstructionsService;
|
|
59
60
|
readonly conversations: ReturnType<typeof createConversationService>;
|
|
60
61
|
readonly resources: ReturnType<typeof createResourceService>;
|
|
@@ -105,6 +106,7 @@ export declare function createDiagnosticRoot(wakeRoot: string): Promise<{
|
|
|
105
106
|
subscriptionRunSerialiser: ProcessorRunSerialiser;
|
|
106
107
|
work: import("../work/index.js").WorkService;
|
|
107
108
|
artifacts: import("../artifacts/index.js").ArtifactService;
|
|
109
|
+
artifactContexts: ArtifactContextService;
|
|
108
110
|
operatorInstructions: OperatorInstructionsService;
|
|
109
111
|
conversations: import("../conversations/index.js").ConversationService;
|
|
110
112
|
resources: import("../resources/index.js").ResourceService;
|
|
@@ -2,24 +2,26 @@ import { acquireFileLock } from '@atolis-hq/eventing-filesystem';
|
|
|
2
2
|
import { createPullRequestService } from '../activities/index.js';
|
|
3
3
|
import { ArtifactContextService, FileArtifactMcpSessionStore, FileArtifactStore, OperatorInstructionsService, createArtifactService, createDelegationArtifacts, } from '../artifacts/index.js';
|
|
4
4
|
import { DispatchPolicy, createActivationScheduler, createActivationSchedulerSubscriber, createControlPlaneService, createDurableRunnerIneligibility, createRunnerControlService, } from '../control-plane/index.js';
|
|
5
|
-
import { createConversationService } from '../conversations/index.js';
|
|
5
|
+
import { createConversationService, postControlPlaneEntry } from '../conversations/index.js';
|
|
6
6
|
import { ExecutionCancellationReason, GitWorkspaceProvider, RecoveryService, RunStatus, TranscriptStore, createExecutionService, createLocalProcessInspector, createRepositoryAssignments, createRunnerMemoryProfileDecorator, isActiveRunStatus, resolveGitSource, } from '../execution/index.js';
|
|
7
7
|
import { createGitHubAgentContextReader, gitHubProviderDefinition, gitHubRepositoryIdentity, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
|
|
8
8
|
import { createDelegationOutputs, createDeliveryIntegrationVerification, } from '../integrations/index.js';
|
|
9
9
|
import { SystemClock, UlidIdGenerator } from '../kernel/index.js';
|
|
10
10
|
import { compileWorkflow, createAgentActivityClassifier, createOrchestrationService, } from '../orchestration/index.js';
|
|
11
|
-
import { createResourceLookup, createResourceService, resourceId, } from '../resources/index.js';
|
|
11
|
+
import { ResourceCorrelationProvenance, ResourceCorrelationRole, createResourceLookup, createResourceService, resourceId, } from '../resources/index.js';
|
|
12
12
|
import { createWorkService } from '../work/index.js';
|
|
13
13
|
import { createFileActivationSchedulerSerialiser } from './activation-scheduler-serialiser.js';
|
|
14
14
|
import { createBuiltInActivityRegistry } from './activity-registry.js';
|
|
15
15
|
import { createArtifactMcpProvisioner } from './artifact-mcp.js';
|
|
16
16
|
import { createArtifactTriggerContext } from './artifact-trigger-context.js';
|
|
17
17
|
import { loadConfig } from './config/load-config.js';
|
|
18
|
+
import { delegatedGrantReferences, withDelegatedGrants } from './delegated-artifact-context.js';
|
|
18
19
|
import { createDelegationAuthority } from './delegation-authority.js';
|
|
19
20
|
import { createDeliveryIntegration } from './delivery-integration.js';
|
|
20
21
|
import { EventProcessorRuntime } from './event-processor-runtime.js';
|
|
21
22
|
import { loadFakeScenarios } from './fake-scenarios.js';
|
|
22
23
|
import { composeIntegrationRuntime, composeProviders } from './integration-runtime.js';
|
|
24
|
+
import { withObjectiveTitle } from './objective-title-context.js';
|
|
23
25
|
import { resolveWakePaths } from './paths.js';
|
|
24
26
|
import { composePersistence } from './persistence-composition.js';
|
|
25
27
|
import { createRunnerQuotaReporter } from './runner-quota-reporter.js';
|
|
@@ -54,10 +56,10 @@ async function createApplicationServices(wakeRoot, options = {}) {
|
|
|
54
56
|
const resources = createResourceService(journal, lookup);
|
|
55
57
|
const pullRequests = createPullRequestService(journal, work, resources);
|
|
56
58
|
const activities = options.activities ??
|
|
57
|
-
createBuiltInActivityRegistry(journal, pullRequests, resources, wakeRoot, createGitHubAgentContextReader(journal, resources, {
|
|
59
|
+
createBuiltInActivityRegistry(journal, pullRequests, resources, wakeRoot, withObjectiveTitle(createGitHubAgentContextReader(journal, resources, {
|
|
58
60
|
publicUiUrl: config.surfaces.web.publicUrl,
|
|
59
61
|
githubAdapters: githubAdapters(config),
|
|
60
|
-
}, conversations),
|
|
62
|
+
}, conversations), work),
|
|
61
63
|
// Resolved lazily: Orchestration is composed after the registry it compiles against.
|
|
62
64
|
{ authorize: (request) => orchestration.authorizeParentAction(request) });
|
|
63
65
|
const workflowNotices = [];
|
|
@@ -93,6 +95,17 @@ async function createApplicationServices(wakeRoot, options = {}) {
|
|
|
93
95
|
pullRequests,
|
|
94
96
|
providers: () => providerInstances.promise,
|
|
95
97
|
})),
|
|
98
|
+
messages: {
|
|
99
|
+
post: (input, context) => postControlPlaneEntry(conversations, input, context),
|
|
100
|
+
},
|
|
101
|
+
resources: {
|
|
102
|
+
async relateChild({ childWorkItemId, parentWorkItemId }, context) {
|
|
103
|
+
const primary = (await resources.correlationsForWork(parentWorkItemId)).find((correlation) => correlation.role === ResourceCorrelationRole.Primary);
|
|
104
|
+
if (primary === undefined)
|
|
105
|
+
return;
|
|
106
|
+
await resources.correlate(primary.resourceId, childWorkItemId, ResourceCorrelationRole.Secondary, context, ResourceCorrelationProvenance.Delegated);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
96
109
|
runHasEnded: async (runId) => {
|
|
97
110
|
const run = (await execution.list()).find((entry) => entry.runId === runId);
|
|
98
111
|
return (run !== undefined &&
|
|
@@ -142,7 +155,7 @@ async function createApplicationServices(wakeRoot, options = {}) {
|
|
|
142
155
|
wakeRoot: paths.wakeRoot,
|
|
143
156
|
now: () => clock.now().toISOString(),
|
|
144
157
|
nextId: () => ids.next('artifact'),
|
|
145
|
-
sharedContext: artifactTriggerContext.provision,
|
|
158
|
+
sharedContext: withDelegatedGrants(artifactTriggerContext.provision, delegatedGrantReferences({ work, contexts: artifactContexts })),
|
|
146
159
|
operatorInstructions,
|
|
147
160
|
journal,
|
|
148
161
|
}),
|
|
@@ -185,6 +198,7 @@ async function createApplicationServices(wakeRoot, options = {}) {
|
|
|
185
198
|
subscriptionRunSerialiser,
|
|
186
199
|
work,
|
|
187
200
|
artifacts,
|
|
201
|
+
artifactContexts,
|
|
188
202
|
operatorInstructions,
|
|
189
203
|
conversations,
|
|
190
204
|
resources,
|
|
@@ -214,7 +228,7 @@ export async function createDiagnosticRoot(wakeRoot) {
|
|
|
214
228
|
return { ...base, providers: instances, providerFailures: failures };
|
|
215
229
|
}
|
|
216
230
|
export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
217
|
-
const { providerInstances, config, fakeScenarios, workflowNotices, paths, maintenance, clock, ids, journal, projections, checkpoints, processorState, subscriptionRunSerialiser, work, artifacts, operatorInstructions, conversations, resources, pullRequests, lookup, orchestration, execution, recovery, transcriptStore, runnerControls, controlPlane, isRuntimePaused, activities, runners, artifactTriggerContext, workspaces, } = await createApplicationServices(wakeRoot, options);
|
|
231
|
+
const { providerInstances, config, fakeScenarios, workflowNotices, paths, maintenance, clock, ids, journal, projections, checkpoints, processorState, subscriptionRunSerialiser, work, artifacts, artifactContexts, operatorInstructions, conversations, resources, pullRequests, lookup, orchestration, execution, recovery, transcriptStore, runnerControls, controlPlane, isRuntimePaused, activities, runners, artifactTriggerContext, workspaces, } = await createApplicationServices(wakeRoot, options);
|
|
218
232
|
const processorRuntime = new EventProcessorRuntime(journal, checkpoints, subscriptionRunSerialiser, clock);
|
|
219
233
|
const activationScheduler = createActivationScheduler(orchestration, {
|
|
220
234
|
...execution,
|
|
@@ -290,6 +304,7 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
|
290
304
|
activities,
|
|
291
305
|
work,
|
|
292
306
|
artifacts,
|
|
307
|
+
artifactContexts,
|
|
293
308
|
operatorInstructions,
|
|
294
309
|
conversations,
|
|
295
310
|
resources,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArtifactContextService, ArtifactRevisionReference } from '../artifacts/index.js';
|
|
2
|
+
import type { WorkService } from '../work/index.js';
|
|
3
|
+
/** Accepted artifact revisions a parent granted to one of its delegated children. */
|
|
4
|
+
export declare function delegatedGrantReferences(input: {
|
|
5
|
+
readonly work: Pick<WorkService, 'get'>;
|
|
6
|
+
readonly contexts: Pick<ArtifactContextService, 'childReferences'>;
|
|
7
|
+
}): (workItemId: string) => Promise<readonly ArtifactRevisionReference[]>;
|
|
8
|
+
type SharedContext = (workItemId: string) => Promise<{
|
|
9
|
+
readonly sharedReferences?: readonly ArtifactRevisionReference[];
|
|
10
|
+
readonly currentMemory?: ArtifactRevisionReference | null;
|
|
11
|
+
readonly contextScope?: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Makes a child's granted references readable by its activations, beside trigger-shared context. */
|
|
14
|
+
export declare function withDelegatedGrants(shared: SharedContext, grants: (workItemId: string) => Promise<readonly ArtifactRevisionReference[]>): SharedContext;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Accepted artifact revisions a parent granted to one of its delegated children. */
|
|
2
|
+
export function delegatedGrantReferences(input) {
|
|
3
|
+
return async (workItemId) => {
|
|
4
|
+
const parent = (await input.work.get(workItemId))?.delegation?.parentWorkItemId;
|
|
5
|
+
return parent === undefined ? [] : input.contexts.childReferences(parent, workItemId);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/** Makes a child's granted references readable by its activations, beside trigger-shared context. */
|
|
9
|
+
export function withDelegatedGrants(shared, grants) {
|
|
10
|
+
return async (workItemId) => {
|
|
11
|
+
const base = await shared(workItemId);
|
|
12
|
+
const granted = await grants(workItemId);
|
|
13
|
+
return granted.length === 0
|
|
14
|
+
? base
|
|
15
|
+
: { ...base, sharedReferences: [...(base.sharedReferences ?? []), ...granted] };
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -411,6 +411,15 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \\
|
|
|
411
411
|
&& apt-get update \\
|
|
412
412
|
&& apt-get install -y --no-install-recommends gh
|
|
413
413
|
|
|
414
|
+
# gh extensions resolve from the data dir under the container home, which is bind-mounted at
|
|
415
|
+
# runtime and would hide anything installed there. Install the latest release system-wide here; the
|
|
416
|
+
# entrypoint links it into the home at startup. Agents link PRs with: gh stack link.
|
|
417
|
+
# Bump this date to force a fresh install instead of an indefinitely cached layer.
|
|
418
|
+
ARG GH_STACK_CACHE_BUST=2026-10-23
|
|
419
|
+
RUN echo "gh-stack cache bust: \${GH_STACK_CACHE_BUST}" \\
|
|
420
|
+
&& XDG_DATA_HOME=/usr/local/lib/wake-gh gh extension install github/gh-stack \\
|
|
421
|
+
&& chmod -R a+rX /usr/local/lib/wake-gh
|
|
422
|
+
|
|
414
423
|
RUN --mount=type=cache,target=/root/.npm \\
|
|
415
424
|
npm install -g @anthropic-ai/claude-code @openai/codex
|
|
416
425
|
|
|
@@ -476,7 +485,7 @@ ENV WAKE_MAIN_JS=/app/dist/src/main.js
|
|
|
476
485
|
# Startup ownership repair is best effort because bind-mounted paths or host
|
|
477
486
|
# permissions may prevent chown. The bounded direct-child pass avoids traversing
|
|
478
487
|
# accumulated runtime data.
|
|
479
|
-
ENTRYPOINT ["sh", "-c", "set -eu; mkdir -p /wake/.wake /wake/workspaces /wake/.wake/auth; chown wake:wake /wake/.wake /wake/workspaces /wake/.wake/auth || true; find /wake/.wake -mindepth 1 -maxdepth 1 -type d -exec chown wake:wake {} + || true; find /wake/.wake/auth -mindepth 1 -maxdepth 1 -type f -exec chown wake:wake {} + || true; if [ -n \\"\${WAKE_HOME_INIT_DIRS:-}\\" ]; then printf '%s\\n' \\"$WAKE_HOME_INIT_DIRS\\" | while IFS= read -r directory; do case \\"$directory\\" in \\"\${WAKE_HOME_INIT_ROOT:-}\\"/*) mkdir -p \\"$directory\\"; chown wake:wake \\"$directory\\" ;; *) exit 1 ;; esac; done; fi; exec su wake -s /bin/sh -c 'HOME=/home/wake exec node \\"$WAKE_MAIN_JS\\" sandbox-entrypoint --wake-root /wake'"]
|
|
488
|
+
ENTRYPOINT ["sh", "-c", "set -eu; mkdir -p /wake/.wake /wake/workspaces /wake/.wake/auth; chown wake:wake /wake/.wake /wake/workspaces /wake/.wake/auth || true; find /wake/.wake -mindepth 1 -maxdepth 1 -type d -exec chown wake:wake {} + || true; find /wake/.wake/auth -mindepth 1 -maxdepth 1 -type f -exec chown wake:wake {} + || true; { mkdir -p /home/wake/.local/share/gh/extensions && ln -sfn /usr/local/lib/wake-gh/gh/extensions/gh-stack /home/wake/.local/share/gh/extensions/gh-stack && chown wake:wake /home/wake/.local /home/wake/.local/share /home/wake/.local/share/gh /home/wake/.local/share/gh/extensions; } || true; if [ -n \\"\${WAKE_HOME_INIT_DIRS:-}\\" ]; then printf '%s\\n' \\"$WAKE_HOME_INIT_DIRS\\" | while IFS= read -r directory; do case \\"$directory\\" in \\"\${WAKE_HOME_INIT_ROOT:-}\\"/*) mkdir -p \\"$directory\\"; chown wake:wake \\"$directory\\" ;; *) exit 1 ;; esac; done; fi; exec su wake -s /bin/sh -c 'HOME=/home/wake exec node \\"$WAKE_MAIN_JS\\" sandbox-entrypoint --wake-root /wake'"]
|
|
480
489
|
`;
|
|
481
490
|
const packagedDockerfile = `# syntax=docker/dockerfile:1
|
|
482
491
|
FROM node:24-bookworm-slim
|
|
@@ -494,6 +503,15 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \\
|
|
|
494
503
|
&& apt-get update \\
|
|
495
504
|
&& apt-get install -y --no-install-recommends gh
|
|
496
505
|
|
|
506
|
+
# gh extensions resolve from the data dir under the container home, which is bind-mounted at
|
|
507
|
+
# runtime and would hide anything installed there. Install the latest release system-wide here; the
|
|
508
|
+
# entrypoint links it into the home at startup. Agents link PRs with: gh stack link.
|
|
509
|
+
# Bump this date to force a fresh install instead of an indefinitely cached layer.
|
|
510
|
+
ARG GH_STACK_CACHE_BUST=2026-10-23
|
|
511
|
+
RUN echo "gh-stack cache bust: \${GH_STACK_CACHE_BUST}" \\
|
|
512
|
+
&& XDG_DATA_HOME=/usr/local/lib/wake-gh gh extension install github/gh-stack \\
|
|
513
|
+
&& chmod -R a+rX /usr/local/lib/wake-gh
|
|
514
|
+
|
|
497
515
|
ARG WAKE_VERSION=0.1.0
|
|
498
516
|
RUN --mount=type=cache,target=/root/.npm \\
|
|
499
517
|
npm install -g @anthropic-ai/claude-code @openai/codex "@atolis-hq/wake@\${WAKE_VERSION}"
|
|
@@ -543,7 +561,7 @@ EXPOSE 4317
|
|
|
543
561
|
# Startup ownership repair is best effort because bind-mounted paths or host
|
|
544
562
|
# permissions may prevent chown. The bounded direct-child pass avoids traversing
|
|
545
563
|
# accumulated runtime data.
|
|
546
|
-
ENTRYPOINT ["sh", "-c", "set -eu; mkdir -p /wake/.wake /wake/workspaces /wake/.wake/auth; chown wake:wake /wake/.wake /wake/workspaces /wake/.wake/auth || true; find /wake/.wake -mindepth 1 -maxdepth 1 -type d -exec chown wake:wake {} + || true; find /wake/.wake/auth -mindepth 1 -maxdepth 1 -type f -exec chown wake:wake {} + || true; if [ -n \\"\${WAKE_HOME_INIT_DIRS:-}\\" ]; then printf '%s\\n' \\"$WAKE_HOME_INIT_DIRS\\" | while IFS= read -r directory; do case \\"$directory\\" in \\"\${WAKE_HOME_INIT_ROOT:-}\\"/*) mkdir -p \\"$directory\\"; chown wake:wake \\"$directory\\" ;; *) exit 1 ;; esac; done; fi; exec su wake -s /bin/sh -c 'HOME=/home/wake exec wake sandbox-entrypoint'"]
|
|
564
|
+
ENTRYPOINT ["sh", "-c", "set -eu; mkdir -p /wake/.wake /wake/workspaces /wake/.wake/auth; chown wake:wake /wake/.wake /wake/workspaces /wake/.wake/auth || true; find /wake/.wake -mindepth 1 -maxdepth 1 -type d -exec chown wake:wake {} + || true; find /wake/.wake/auth -mindepth 1 -maxdepth 1 -type f -exec chown wake:wake {} + || true; { mkdir -p /home/wake/.local/share/gh/extensions && ln -sfn /usr/local/lib/wake-gh/gh/extensions/gh-stack /home/wake/.local/share/gh/extensions/gh-stack && chown wake:wake /home/wake/.local /home/wake/.local/share /home/wake/.local/share/gh /home/wake/.local/share/gh/extensions; } || true; if [ -n \\"\${WAKE_HOME_INIT_DIRS:-}\\" ]; then printf '%s\\n' \\"$WAKE_HOME_INIT_DIRS\\" | while IFS= read -r directory; do case \\"$directory\\" in \\"\${WAKE_HOME_INIT_ROOT:-}\\"/*) mkdir -p \\"$directory\\"; chown wake:wake \\"$directory\\" ;; *) exit 1 ;; esac; done; fi; exec su wake -s /bin/sh -c 'HOME=/home/wake exec wake sandbox-entrypoint'"]
|
|
547
565
|
`;
|
|
548
566
|
const triagePrompt = `---
|
|
549
567
|
maxTurns: 40
|
|
@@ -171,6 +171,7 @@ export async function composeIntegrationRuntime(input) {
|
|
|
171
171
|
runs,
|
|
172
172
|
resources: input.resources,
|
|
173
173
|
orchestration: input.orchestration,
|
|
174
|
+
work: input.work,
|
|
174
175
|
conversations: input.conversations,
|
|
175
176
|
...(replies === undefined ? {} : { replies }),
|
|
176
177
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentContextReader } from '../activities/index.js';
|
|
2
|
+
import type { WorkService } from '../work/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Work with no provider ticket, such as a delegated child, has no title to read. Its
|
|
5
|
+
* objective is its title, so fall back to that; ticket text stays authoritative when present.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withObjectiveTitle(reader: AgentContextReader, work: Pick<WorkService, 'get'>): AgentContextReader;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work with no provider ticket, such as a delegated child, has no title to read. Its
|
|
3
|
+
* objective is its title, so fall back to that; ticket text stays authoritative when present.
|
|
4
|
+
*/
|
|
5
|
+
export function withObjectiveTitle(reader, work) {
|
|
6
|
+
return {
|
|
7
|
+
async forWorkItem(workItemId, options) {
|
|
8
|
+
const context = await reader.forWorkItem(workItemId, options);
|
|
9
|
+
if (context.title !== '')
|
|
10
|
+
return context;
|
|
11
|
+
const objective = (await work.get(workItemId))?.objective;
|
|
12
|
+
return objective === undefined ? context : { ...context, title: objective };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DelegationOutputKind, WorkflowArtifactOutputKind } from '../orchestration/index.js';
|
|
2
2
|
import { presentResource, toWorkItemKey, } from '../surfaces/index.js';
|
|
3
|
+
import { primaryExternalRef } from './external-ref.js';
|
|
3
4
|
export async function presentDelivery(root, work) {
|
|
4
5
|
if (root.orchestration?.deliveryTree === undefined)
|
|
5
6
|
return {};
|
|
@@ -21,9 +22,13 @@ export async function presentDelivery(root, work) {
|
|
|
21
22
|
...presentHeader(work, cohorts, attention, qa === undefined ? undefined : { ...qa, staleOutputs: stale }),
|
|
22
23
|
children: await Promise.all(cohorts.flatMap((cohort) => cohort.children.map(async (child) => {
|
|
23
24
|
const availability = delivery.availability(child.workItemId);
|
|
24
|
-
const
|
|
25
|
+
const correlations = await root.resources.correlationsForWork(child.workItemId);
|
|
26
|
+
const resources = await Promise.all(correlations.map((entry) => root.resources.get(entry.resourceId)));
|
|
27
|
+
const externalRef = await primaryExternalRef(root, child.workItemId, correlations, resources.filter((entry) => entry !== null));
|
|
25
28
|
return {
|
|
26
29
|
workItemKey: toWorkItemKey(child.workItemId),
|
|
30
|
+
workItemId: child.workItemId,
|
|
31
|
+
...(externalRef === undefined ? {} : { externalRef }),
|
|
27
32
|
parentWorkItemKey: toWorkItemKey(cohort.parentWorkItemId),
|
|
28
33
|
objective: child.objective,
|
|
29
34
|
workflowName: child.workflowName,
|
|
@@ -7,6 +7,7 @@ import { ApprovalAuthorityKind, conversationCommand, ConversationSurfaceCapabili
|
|
|
7
7
|
import { workCorrelationsProjection, } from '../resources/index.js';
|
|
8
8
|
import { ApiCommandStatus, fromWorkItemKey, presentResource, presentRun, presentWorkflowInstance, presentWorkItem, toWorkItemKey, } from '../surfaces/index.js';
|
|
9
9
|
import { workItemId, WorkStatus } from '../work/index.js';
|
|
10
|
+
import { delegatedGrantReferences } from './delegated-artifact-context.js';
|
|
10
11
|
import { primaryExternalRef } from './external-ref.js';
|
|
11
12
|
import { presentDelivery } from './surface-api-delivery.js';
|
|
12
13
|
import { presentPrimaryWorkflow } from './surface-api-merge-policy.js';
|
|
@@ -259,10 +260,13 @@ async function presentArtifacts(root, id) {
|
|
|
259
260
|
const partial = root;
|
|
260
261
|
if (partial.artifacts === undefined || partial.orchestration?.listAll === undefined)
|
|
261
262
|
return [];
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return (await
|
|
263
|
+
const workflows = await partial.orchestration.listAll();
|
|
264
|
+
const accepted = new Set(workflows.filter((workflow) => workflow.workItemId === id).flatMap((w) => w.acceptedOutcomes));
|
|
265
|
+
const own = (await partial.artifacts.latestPublished(id, async (activationId) => accepted.has(activationId))).map((artifact) => presentArtifact(id, artifact));
|
|
266
|
+
return [...own, ...(await contextArtifacts(root, id, workflows))];
|
|
267
|
+
}
|
|
268
|
+
function presentArtifact(owner, artifact) {
|
|
269
|
+
return {
|
|
266
270
|
revisionId: artifact.revisionId,
|
|
267
271
|
producer: artifact.producer,
|
|
268
272
|
path: artifact.path,
|
|
@@ -270,7 +274,37 @@ async function presentArtifacts(root, id) {
|
|
|
270
274
|
...(artifact.mediaType === undefined ? {} : { mediaType: artifact.mediaType }),
|
|
271
275
|
...(artifact.byteLength === undefined ? {} : { byteLength: artifact.byteLength }),
|
|
272
276
|
...(artifact.digest === undefined ? {} : { digest: artifact.digest }),
|
|
273
|
-
href: `/api/v1/work-items/${encodeURIComponent(toWorkItemKey(
|
|
277
|
+
href: `/api/v1/work-items/${encodeURIComponent(toWorkItemKey(owner))}/artifacts/${encodeURIComponent(artifact.revisionId)}`,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Artifacts other work items published into this one's context. Resolution reuses the
|
|
282
|
+
* visibility rules an activation is held to, so the screen cannot list what an agent cannot read.
|
|
283
|
+
*/
|
|
284
|
+
async function contextArtifacts(root, id, workflows) {
|
|
285
|
+
const partial = root;
|
|
286
|
+
if (partial.artifactContexts === undefined || partial.work === undefined)
|
|
287
|
+
return [];
|
|
288
|
+
const granted = await delegatedGrantReferences({
|
|
289
|
+
work: partial.work,
|
|
290
|
+
contexts: partial.artifactContexts,
|
|
291
|
+
})(id);
|
|
292
|
+
if (granted.length === 0)
|
|
293
|
+
return [];
|
|
294
|
+
const acceptedAnywhere = new Set(workflows.flatMap((workflow) => workflow.acceptedOutcomes));
|
|
295
|
+
const visible = await partial.artifacts.visibleTo({
|
|
296
|
+
workItemId: id,
|
|
297
|
+
producer: 'artifact-view',
|
|
298
|
+
runId: 'artifact-view',
|
|
299
|
+
activationId: 'artifact-view',
|
|
300
|
+
readableProducers: new Set(),
|
|
301
|
+
sharedReferences: granted,
|
|
302
|
+
}, async (activationId) => acceptedAnywhere.has(activationId));
|
|
303
|
+
return visible
|
|
304
|
+
.filter((artifact) => artifact.access === 'shared')
|
|
305
|
+
.map((artifact) => ({
|
|
306
|
+
...presentArtifact(artifact.workItemId, artifact),
|
|
307
|
+
source: { workItemKey: toWorkItemKey(artifact.workItemId), relation: 'granted' },
|
|
274
308
|
}));
|
|
275
309
|
}
|
|
276
310
|
function safeMediaType(value) {
|
|
@@ -9,9 +9,13 @@ export function createWorkflowDiagramApplications(root, now) {
|
|
|
9
9
|
const overlay = workItemKey === undefined
|
|
10
10
|
? undefined
|
|
11
11
|
: await loadOverlay(root, fromWorkItemKey(workItemKey));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// Work that has no primary instance yet (e.g. a delegated child still waiting on its
|
|
13
|
+
// prerequisites) has nothing to overlay; that is not an error.
|
|
14
|
+
const definitions = workItemKey !== undefined && overlay === undefined
|
|
15
|
+
? []
|
|
16
|
+
: overlay === undefined
|
|
17
|
+
? root.orchestration.listCurrentDefinitions().map((entry) => entry.definition)
|
|
18
|
+
: [await root.orchestration.definitionFor(overlay.primary)];
|
|
15
19
|
return {
|
|
16
20
|
data: {
|
|
17
21
|
diagrams: definitions.map((definition) => presentWorkflowDiagram(definition, overlay)),
|
|
@@ -87,7 +91,7 @@ async function loadOverlay(root, workItemId) {
|
|
|
87
91
|
const workflows = await root.orchestration.listForWorkItem(workItemId);
|
|
88
92
|
const primary = workflows.find((workflow) => workflow.parentWorkflowInstanceId === undefined);
|
|
89
93
|
if (primary === undefined)
|
|
90
|
-
|
|
94
|
+
return undefined;
|
|
91
95
|
const runs = (await root.execution.list()).filter((run) => workflows.some((workflow) => workflow.workflowInstanceId === run.workflowInstanceId));
|
|
92
96
|
return {
|
|
93
97
|
primary,
|
|
@@ -124,6 +124,6 @@ export function resolveWakeVersion(options = {}) {
|
|
|
124
124
|
return `g${headHash.slice(0, 7)}`;
|
|
125
125
|
return '0.1.0-dev';
|
|
126
126
|
}
|
|
127
|
-
export const wakeVersion = "v0.4.
|
|
127
|
+
export const wakeVersion = "v0.4.111";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
|
+
import type { WorkItemId } from '../../work/index.js';
|
|
3
|
+
import type { ConversationService } from './conversation-service.js';
|
|
4
|
+
/**
|
|
5
|
+
* Posts a message authored by Wake on someone's behalf (a delegating parent's assignment or
|
|
6
|
+
* reply) to a work item's conversation, creating the conversation if needed. Both steps are
|
|
7
|
+
* idempotent, so a replayed command records the message once.
|
|
8
|
+
*/
|
|
9
|
+
export declare function postControlPlaneEntry(conversations: Pick<ConversationService, 'createForWorkItem' | 'record'>, input: {
|
|
10
|
+
readonly workItemId: WorkItemId;
|
|
11
|
+
readonly entryId: string;
|
|
12
|
+
readonly authorId: string;
|
|
13
|
+
readonly body: string;
|
|
14
|
+
}, context: CommandContext): Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { conversationIdForWorkItem } from '../contracts/identifiers.js';
|
|
2
|
+
import { ConversationOriginKind } from '../contracts/vocabulary.js';
|
|
3
|
+
/**
|
|
4
|
+
* Posts a message authored by Wake on someone's behalf (a delegating parent's assignment or
|
|
5
|
+
* reply) to a work item's conversation, creating the conversation if needed. Both steps are
|
|
6
|
+
* idempotent, so a replayed command records the message once.
|
|
7
|
+
*/
|
|
8
|
+
export async function postControlPlaneEntry(conversations, input, context) {
|
|
9
|
+
await conversations.createForWorkItem(input.workItemId, context);
|
|
10
|
+
await conversations.record({
|
|
11
|
+
conversationId: conversationIdForWorkItem(input.workItemId),
|
|
12
|
+
entryId: input.entryId,
|
|
13
|
+
body: input.body,
|
|
14
|
+
origin: { kind: ConversationOriginKind.ControlPlane, actorId: input.authorId },
|
|
15
|
+
}, context);
|
|
16
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './application/conversation-projection.js';
|
|
2
2
|
export * from './application/conversation-service.js';
|
|
3
|
+
export * from './application/control-plane-entry.js';
|
|
3
4
|
export * from './contracts/commands.js';
|
|
4
5
|
export * from './contracts/events.js';
|
|
5
6
|
export * from './contracts/event-factory.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './application/conversation-projection.js';
|
|
2
2
|
export * from './application/conversation-service.js';
|
|
3
|
+
export * from './application/control-plane-entry.js';
|
|
3
4
|
export * from './contracts/commands.js';
|
|
4
5
|
export * from './contracts/events.js';
|
|
5
6
|
export * from './contracts/event-factory.js';
|
|
@@ -3,6 +3,7 @@ import { type ConversationService } from '../../conversations/index.js';
|
|
|
3
3
|
import { type RunRepository } from '../../execution/index.js';
|
|
4
4
|
import { selectWorkflowOrchestrationEvent, type OrchestrationService } from '../../orchestration/index.js';
|
|
5
5
|
import type { ResourceService } from '../../resources/index.js';
|
|
6
|
+
import type { WorkService } from '../../work/index.js';
|
|
6
7
|
import { type ReplyPublicationConfig } from '../contracts/reply-routing.js';
|
|
7
8
|
/** Projects terminal agent runs into one durable outbound intent per configured resource. */
|
|
8
9
|
export declare class AgentRunPublicationReactor {
|
|
@@ -13,6 +14,7 @@ export declare class AgentRunPublicationReactor {
|
|
|
13
14
|
readonly runs: RunRepository;
|
|
14
15
|
readonly resources: Pick<ResourceService, 'correlationsForWork' | 'get'>;
|
|
15
16
|
readonly orchestration: Pick<OrchestrationService, 'listAll'>;
|
|
17
|
+
readonly work?: Pick<WorkService, 'get'> | undefined;
|
|
16
18
|
readonly conversations?: Pick<ConversationService, 'createForWorkItem' | 'record'>;
|
|
17
19
|
readonly replies?: ReplyPublicationConfig | undefined;
|
|
18
20
|
});
|
|
@@ -21,6 +23,5 @@ export declare class AgentRunPublicationReactor {
|
|
|
21
23
|
private publish;
|
|
22
24
|
private publishMergeWait;
|
|
23
25
|
private recordConversationEntry;
|
|
24
|
-
private resourceForTarget;
|
|
25
26
|
private stageForActivation;
|
|
26
27
|
}
|
|
@@ -3,13 +3,14 @@ import { BuiltInActivityName } from '../../activities/index.js';
|
|
|
3
3
|
import { conversationIdForWorkItem, ConversationOriginKind, } from '../../conversations/index.js';
|
|
4
4
|
import { RunStatus } from '../../execution/index.js';
|
|
5
5
|
import { OrchestrationEventType, OrchestrationStreamKind, selectWorkflowOrchestrationEvent, } from '../../orchestration/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resourceStream } from '../../resources/index.js';
|
|
7
7
|
import { ReplyTarget } from '../contracts/reply-routing.js';
|
|
8
8
|
import { createDeliveryIntentEventData } from '../delivery/contracts/event-factory.js';
|
|
9
9
|
import { DeliveryIntentEventType } from '../delivery/contracts/intents.js';
|
|
10
10
|
import { defaultReplyPublication, selectReplyTarget, } from '../github/application/reply-target-selector.js';
|
|
11
11
|
import { projectTerminalAgentRunReport } from './terminal-agent-run-report.js';
|
|
12
12
|
import { agentRunReportInput, mergeWaitComment } from './agent-run-publication-report.js';
|
|
13
|
+
import { labelledForSharedResource, resourceForTarget } from './agent-run-publication-target.js';
|
|
13
14
|
/** Projects terminal agent runs into one durable outbound intent per configured resource. */
|
|
14
15
|
export class AgentRunPublicationReactor {
|
|
15
16
|
dependencies;
|
|
@@ -71,9 +72,10 @@ export class AgentRunPublicationReactor {
|
|
|
71
72
|
const target = selectReplyTarget({ stage, outcome: report.outcome }, replies.rules, replies.default);
|
|
72
73
|
if (target === ReplyTarget.None)
|
|
73
74
|
return;
|
|
74
|
-
const resource = await this.
|
|
75
|
+
const resource = await resourceForTarget(this.dependencies.resources, workflow.workItemId, target);
|
|
75
76
|
if (resource === undefined)
|
|
76
77
|
return;
|
|
78
|
+
const published = await labelledForSharedResource(this.dependencies.work, workflow.workItemId, resource, report);
|
|
77
79
|
const stream = resourceStream(resource.resourceId);
|
|
78
80
|
const sequence = (await this.dependencies.journal.readStream(stream)).length;
|
|
79
81
|
try {
|
|
@@ -96,7 +98,7 @@ export class AgentRunPublicationReactor {
|
|
|
96
98
|
conversationId: conversationIdForWorkItem(workflow.workItemId),
|
|
97
99
|
conversationEntryId: `agent-run:${run.runId}`,
|
|
98
100
|
}),
|
|
99
|
-
report,
|
|
101
|
+
report: published,
|
|
100
102
|
},
|
|
101
103
|
}),
|
|
102
104
|
]);
|
|
@@ -118,7 +120,7 @@ export class AgentRunPublicationReactor {
|
|
|
118
120
|
const target = selectReplyTarget({ stage: workflow.currentStage, outcome: 'DONE' }, replies.rules, replies.default);
|
|
119
121
|
if (target === ReplyTarget.None)
|
|
120
122
|
return;
|
|
121
|
-
const resource = await this.
|
|
123
|
+
const resource = await resourceForTarget(this.dependencies.resources, workflow.workItemId, target);
|
|
122
124
|
if (resource === undefined)
|
|
123
125
|
return;
|
|
124
126
|
const stream = resourceStream(resource.resourceId);
|
|
@@ -168,19 +170,6 @@ export class AgentRunPublicationReactor {
|
|
|
168
170
|
},
|
|
169
171
|
}, { ...context, commandId: `agent-run:${runId}` });
|
|
170
172
|
}
|
|
171
|
-
async resourceForTarget(workItemId, target) {
|
|
172
|
-
const correlations = await this.dependencies.resources.correlationsForWork(workItemId);
|
|
173
|
-
const primary = () => correlations.find((value) => value.role === ResourceCorrelationRole.Primary);
|
|
174
|
-
if (target === ReplyTarget.Primary)
|
|
175
|
-
return primary();
|
|
176
|
-
const kind = target === ReplyTarget.Issue ? BuiltInResourceKind.Issue : BuiltInResourceKind.PullRequest;
|
|
177
|
-
for (const correlation of correlations) {
|
|
178
|
-
const resource = await this.dependencies.resources.get(correlation.resourceId);
|
|
179
|
-
if (resource?.kind === kind)
|
|
180
|
-
return correlation;
|
|
181
|
-
}
|
|
182
|
-
return primary();
|
|
183
|
-
}
|
|
184
173
|
async stageForActivation(workflowInstanceId, activationId) {
|
|
185
174
|
const events = await this.dependencies.journal.readStream({
|
|
186
175
|
kind: OrchestrationStreamKind.WorkflowInstance,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ResourceCorrelationView, type ResourceService } from '../../resources/index.js';
|
|
2
|
+
import type { WorkService } from '../../work/index.js';
|
|
3
|
+
import { ReplyTarget, type ReplyPublicationConfig } from '../contracts/reply-routing.js';
|
|
4
|
+
/** The resource a work item's reply should be published on, or undefined when it has none. */
|
|
5
|
+
export declare function resourceForTarget(resources: Pick<ResourceService, 'correlationsForWork' | 'get'>, workItemId: Parameters<ResourceService['correlationsForWork']>[0], target: Exclude<ReplyPublicationConfig['default'], typeof ReplyTarget.None>): Promise<ResourceCorrelationView | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* A delegated child publishes onto its parent's resource, shared with its siblings, so its
|
|
8
|
+
* comment names the work it speaks for. The child's own conversation entry stays unlabelled.
|
|
9
|
+
*/
|
|
10
|
+
export declare function labelledForSharedResource<Report extends {
|
|
11
|
+
readonly displayBody: string;
|
|
12
|
+
}>(work: Pick<WorkService, 'get'> | undefined, workItemId: Parameters<ResourceService['correlationsForWork']>[0], resource: ResourceCorrelationView, report: Report): Promise<Report>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BuiltInResourceKind, ResourceCorrelationProvenance, ResourceCorrelationRole, } from '../../resources/index.js';
|
|
2
|
+
import { ReplyTarget } from '../contracts/reply-routing.js';
|
|
3
|
+
/** The resource a work item's reply should be published on, or undefined when it has none. */
|
|
4
|
+
export async function resourceForTarget(resources, workItemId, target) {
|
|
5
|
+
const correlations = await resources.correlationsForWork(workItemId);
|
|
6
|
+
const primary = () => correlations.find((value) => value.role === ResourceCorrelationRole.Primary);
|
|
7
|
+
const delegated = () => correlations.find((value) => value.provenance === ResourceCorrelationProvenance.Delegated);
|
|
8
|
+
// A child has no primary resource of its own until it reports a PR; until then it speaks on
|
|
9
|
+
// the resource its parent delegated it from.
|
|
10
|
+
if (target === ReplyTarget.Primary)
|
|
11
|
+
return primary() ?? delegated();
|
|
12
|
+
const kind = target === ReplyTarget.Issue ? BuiltInResourceKind.Issue : BuiltInResourceKind.PullRequest;
|
|
13
|
+
for (const correlation of correlations) {
|
|
14
|
+
const resource = await resources.get(correlation.resourceId);
|
|
15
|
+
if (resource?.kind === kind)
|
|
16
|
+
return correlation;
|
|
17
|
+
}
|
|
18
|
+
return primary();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A delegated child publishes onto its parent's resource, shared with its siblings, so its
|
|
22
|
+
* comment names the work it speaks for. The child's own conversation entry stays unlabelled.
|
|
23
|
+
*/
|
|
24
|
+
export async function labelledForSharedResource(work, workItemId, resource, report) {
|
|
25
|
+
if (resource.provenance !== ResourceCorrelationProvenance.Delegated)
|
|
26
|
+
return report;
|
|
27
|
+
const objective = (await work?.get(workItemId))?.objective;
|
|
28
|
+
if (objective === undefined)
|
|
29
|
+
return report;
|
|
30
|
+
return { ...report, displayBody: `**Child work:** ${objective}\n\n${report.displayBody}` };
|
|
31
|
+
}
|