@atolis-hq/wake 0.4.67 → 0.4.69
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/activities/agent/agent-activity-definition.d.ts +1 -2
- package/dist/src/activities/agent/agent-activity-definition.js +6 -2
- package/dist/src/activities/agent/agent-activity.d.ts +2 -3
- package/dist/src/activities/agent/agent-activity.js +2 -2
- package/dist/src/activities/index.d.ts +0 -1
- package/dist/src/activities/index.js +0 -1
- package/dist/src/artifacts/application/artifact-context-service.js +1 -0
- package/dist/src/artifacts/application/artifact-service.js +9 -4
- package/dist/src/artifacts/application/operator-instructions-projection.d.ts +4 -0
- package/dist/src/artifacts/application/operator-instructions-projection.js +19 -0
- package/dist/src/artifacts/application/operator-instructions-service.d.ts +25 -0
- package/dist/src/artifacts/application/operator-instructions-service.js +110 -0
- package/dist/src/artifacts/contracts/context-event-factory.js +2 -0
- package/dist/src/artifacts/contracts/context-events.d.ts +5 -1
- package/dist/src/artifacts/contracts/context-events.js +17 -2
- package/dist/src/artifacts/contracts/context.d.ts +17 -0
- package/dist/src/artifacts/contracts/context.js +11 -0
- package/dist/src/artifacts/contracts/paths.d.ts +3 -0
- package/dist/src/artifacts/contracts/paths.js +10 -0
- package/dist/src/artifacts/index.d.ts +2 -0
- package/dist/src/artifacts/index.js +2 -0
- package/dist/src/artifacts/infrastructure/file-artifact-store.d.ts +6 -0
- package/dist/src/artifacts/infrastructure/file-artifact-store.js +12 -5
- package/dist/src/artifacts/infrastructure/mcp-server.d.ts +2 -1
- package/dist/src/artifacts/infrastructure/mcp-server.js +22 -0
- package/dist/src/artifacts/infrastructure/mcp-session-store.d.ts +2 -1
- package/dist/src/artifacts/infrastructure/mcp-session-store.js +5 -1
- package/dist/src/bootstrap/artifact-mcp.d.ts +4 -8
- package/dist/src/bootstrap/artifact-mcp.js +54 -29
- package/dist/src/bootstrap/composition-root.d.ts +2 -1
- package/dist/src/bootstrap/composition-root.js +5 -1
- package/dist/src/bootstrap/initialise.js +87 -1
- package/dist/src/bootstrap/persistence-composition.js +4 -1
- package/dist/src/bootstrap/projection-runtime.js +2 -1
- package/dist/src/bootstrap/surface-api-execution-applications.js +16 -1
- package/dist/src/bootstrap/surface-api-trigger-applications.js +77 -4
- package/dist/src/bootstrap/surface-cli-applications.js +1 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/execution/application/execution-activity.d.ts +4 -0
- package/dist/src/execution/application/execution-activity.js +19 -0
- package/dist/src/execution/contracts/event-factory.js +2 -0
- package/dist/src/execution/contracts/events.d.ts +5 -0
- package/dist/src/execution/contracts/events.js +7 -0
- package/dist/src/execution/contracts/views.d.ts +4 -0
- package/dist/src/execution/domain/run.js +3 -0
- package/dist/src/integrations/github/contracts/vocabulary.d.ts +0 -15
- package/dist/src/integrations/github/contracts/vocabulary.js +0 -15
- package/dist/src/integrations/index.d.ts +0 -1
- package/dist/src/integrations/index.js +0 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts +5 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +2 -2
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +3 -1
- package/dist/src/surfaces/api/contracts/execution.d.ts +7 -0
- package/dist/src/surfaces/api/contracts/triggers.d.ts +14 -0
- package/dist/src/surfaces/api/http-server.d.ts +1 -0
- package/dist/src/surfaces/api/http-server.js +6 -2
- package/dist/src/surfaces/api/presenters/execution.js +3 -0
- package/dist/src/surfaces/api/routes/applications.d.ts +8 -2
- package/dist/src/surfaces/api/routes/commands.js +47 -10
- package/dist/src/surfaces/web-assets/assets/index-DVapiQjj.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/package.json +1 -1
- package/prompts/triage-assign.md +38 -13
- package/dist/src/activities/agent/delivery-oversight-input.d.ts +0 -7
- package/dist/src/activities/agent/delivery-oversight-input.js +0 -8
- package/dist/src/integrations/github/infrastructure/oversight-mcp.d.ts +0 -15
- package/dist/src/integrations/github/infrastructure/oversight-mcp.js +0 -169
- package/dist/src/surfaces/web-assets/assets/index-DMS1vQy3.js +0 -1192
|
@@ -30,5 +30,4 @@ export * from './fake/durable-delivery-provider.js';
|
|
|
30
30
|
export * from './fake/external-sink.js';
|
|
31
31
|
export * from './fake/external-source.js';
|
|
32
32
|
export * from './fake/provider.js';
|
|
33
|
-
export * from './github/infrastructure/oversight-mcp.js';
|
|
34
33
|
export * from './application/conversation-command-feedback.js';
|
|
@@ -30,5 +30,4 @@ export * from './fake/durable-delivery-provider.js';
|
|
|
30
30
|
export * from './fake/external-sink.js';
|
|
31
31
|
export * from './fake/external-source.js';
|
|
32
32
|
export * from './fake/provider.js';
|
|
33
|
-
export * from './github/infrastructure/oversight-mcp.js';
|
|
34
33
|
export * from './application/conversation-command-feedback.js';
|
|
@@ -2,9 +2,13 @@ import type { EventData, EventEnvelope, StreamRef } from '../contracts/events.js
|
|
|
2
2
|
import type { JournalChangeSignal } from '../subscriptions/journal-change-signal.js';
|
|
3
3
|
export declare class WrongExpectedSequenceError extends Error {
|
|
4
4
|
}
|
|
5
|
+
export interface JournalReadOptions {
|
|
6
|
+
/** Observe committed appends from other hosts without using a bounded freshness cache. */
|
|
7
|
+
readonly fresh?: boolean;
|
|
8
|
+
}
|
|
5
9
|
export interface EventJournal {
|
|
6
10
|
appendToStream(stream: StreamRef, expectedSequence: number, events: readonly EventData[]): Promise<readonly EventEnvelope[]>;
|
|
7
|
-
readStream(stream: StreamRef): Promise<readonly EventEnvelope[]>;
|
|
11
|
+
readStream(stream: StreamRef, options?: JournalReadOptions): Promise<readonly EventEnvelope[]>;
|
|
8
12
|
/** Optional bounded, cancellable snapshot reader for adapters with a streaming source. */
|
|
9
13
|
scanAll?(signal?: AbortSignal): AsyncIterable<EventEnvelope>;
|
|
10
14
|
readAll(afterGlobalPosition: number, limit?: number): Promise<readonly EventEnvelope[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-journal.d.ts","sourceRoot":"","sources":["../../src/store/event-journal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAErF,qBAAa,0BAA2B,SAAQ,KAAK;CAAG;AAExD,MAAM,WAAW,YAAY;IAC3B,cAAc,CACZ,MAAM,EAAE,SAAS,EACjB,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;IACrC,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"event-journal.d.ts","sourceRoot":"","sources":["../../src/store/event-journal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAErF,qBAAa,0BAA2B,SAAQ,KAAK;CAAG;AAExD,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,cAAc,CACZ,MAAM,EAAE,SAAS,EACjB,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;IACrC,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;IAC/F,0FAA0F;IAC1F,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAC7D,OAAO,CAAC,mBAAmB,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;IACxF,UAAU,CAAC,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;IAI9F,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,kBAAkB,CAChB,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IAGjB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventData, EventEnvelope, EventingClock, EventJournal, JournalChangeSignal, StreamRef } from '@atolis-hq/eventing';
|
|
1
|
+
import type { EventData, EventEnvelope, EventingClock, EventJournal, JournalChangeSignal, JournalReadOptions, StreamRef } from '@atolis-hq/eventing';
|
|
2
2
|
export interface FileEventJournalWatcher {
|
|
3
3
|
unref(): void;
|
|
4
4
|
close(): void;
|
|
@@ -27,7 +27,7 @@ export declare class FileEventJournal implements EventJournal {
|
|
|
27
27
|
private entryValidationGeneration;
|
|
28
28
|
appendToStream(stream: StreamRef, expectedSequence: number, drafts: readonly EventData[]): Promise<readonly EventEnvelope[]>;
|
|
29
29
|
private nextSegmentFile;
|
|
30
|
-
readStream(stream: StreamRef): Promise<readonly EventEnvelope<EventData<string, unknown>, StreamRef<string, string>>[]>;
|
|
30
|
+
readStream(stream: StreamRef, options?: JournalReadOptions): Promise<readonly EventEnvelope<EventData<string, unknown>, StreamRef<string, string>>[]>;
|
|
31
31
|
/** Live readers bypass the full-history cache and stop at captured segment sizes. */
|
|
32
32
|
scanAll(signal?: AbortSignal): AsyncIterable<EventEnvelope>;
|
|
33
33
|
private scanSegment;
|
package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-event-journal.d.ts","sourceRoot":"","sources":["../src/file-event-journal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACV,MAAM,qBAAqB,CAAC;AAW7B,MAAM,WAAW,uBAAuB;IACtC,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;CACrD;AAED,MAAM,MAAM,8BAA8B,GAAG,CAC3C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,IAAI,KACf,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEtC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,8BAA8B,CAAC;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;CACvC;AAOD,qBAAa,gBAAiB,YAAW,YAAY;IAIjD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;gBAG1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,uBAA4B;IAKxD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAsC;IACzE,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAA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AAC,qBAAqB;YAQf,eAAe;YAMf,YAAY;YAYZ,IAAI;YAYJ,kBAAkB;YAmBlB,kBAAkB;IAkBhC,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,0BAA0B;YAQpB,mBAAmB;IA0BjC,OAAO,CAAC,mBAAmB;YAwBb,eAAe;CAkD9B"}
|
|
@@ -91,8 +91,10 @@ export class FileEventJournal {
|
|
|
91
91
|
// the entire history. A missing or stale manifest degrades to scan()'s
|
|
92
92
|
// full parse rather than to incorrect data. The next successful append
|
|
93
93
|
// rebuilds the derived manifest.
|
|
94
|
-
async readStream(stream) {
|
|
94
|
+
async readStream(stream, options = {}) {
|
|
95
95
|
const streamKey = key(stream);
|
|
96
|
+
if (options.fresh === true)
|
|
97
|
+
this.invalidateValidatedEntries();
|
|
96
98
|
const entries = await this.readEntriesForRead();
|
|
97
99
|
if (this.cached !== undefined) {
|
|
98
100
|
if (sameEntries(this.cached.entries, entries))
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export interface RunResponse {
|
|
2
|
+
readonly operatorInstructions?: {
|
|
3
|
+
readonly contextScope: string;
|
|
4
|
+
readonly revisionId: string | null;
|
|
5
|
+
readonly content?: string;
|
|
6
|
+
readonly author?: string;
|
|
7
|
+
readonly occurredAt?: string;
|
|
8
|
+
};
|
|
2
9
|
readonly runId: string;
|
|
3
10
|
readonly activationId: string;
|
|
4
11
|
readonly activity: string;
|
|
@@ -8,6 +8,13 @@ export declare const TriggerStatus: {
|
|
|
8
8
|
};
|
|
9
9
|
export type TriggerStatus = ValueOf<typeof TriggerStatus>;
|
|
10
10
|
export interface TriggerResponse {
|
|
11
|
+
readonly operatorInstructions?: {
|
|
12
|
+
readonly contextScope: string;
|
|
13
|
+
readonly revisionId: string;
|
|
14
|
+
readonly content: string;
|
|
15
|
+
readonly author: string;
|
|
16
|
+
readonly occurredAt: string;
|
|
17
|
+
} | null;
|
|
11
18
|
readonly triggerId: string;
|
|
12
19
|
readonly status: TriggerStatus;
|
|
13
20
|
readonly definition: TriggerConfig | null;
|
|
@@ -20,3 +27,10 @@ export interface TriggerResponse {
|
|
|
20
27
|
readonly workItemKey: string;
|
|
21
28
|
})[];
|
|
22
29
|
}
|
|
30
|
+
export interface OrphanedInstructionsResponse {
|
|
31
|
+
readonly contextScope: string;
|
|
32
|
+
readonly revisionId: string;
|
|
33
|
+
readonly content: string | null;
|
|
34
|
+
readonly author: string;
|
|
35
|
+
readonly occurredAt: string;
|
|
36
|
+
}
|
|
@@ -18,6 +18,7 @@ export interface ApiDispatcher {
|
|
|
18
18
|
}
|
|
19
19
|
export interface SurfaceHttpServerOptions {
|
|
20
20
|
readonly dispatcher: ApiDispatcher;
|
|
21
|
+
readonly operatorInstructionsMaxWriteBytes?: number;
|
|
21
22
|
readonly credentials: SurfaceCredentials;
|
|
22
23
|
readonly assets?: AssetSource;
|
|
23
24
|
readonly auth?: {
|
|
@@ -80,7 +80,7 @@ export function createSurfaceHttpServer(options) {
|
|
|
80
80
|
if (!authDisabled && request.session.get(SurfaceSessionAttribute.Operator) !== true)
|
|
81
81
|
return reply.code(401).send({ status: 401, title: 'Unauthorized' });
|
|
82
82
|
});
|
|
83
|
-
|
|
83
|
+
const dispatchProtected = async (request, reply) => {
|
|
84
84
|
const controller = new AbortController();
|
|
85
85
|
const abort = () => controller.abort();
|
|
86
86
|
const close = () => {
|
|
@@ -111,7 +111,11 @@ export function createSurfaceHttpServer(options) {
|
|
|
111
111
|
contentType: 'application/problem+json',
|
|
112
112
|
}, request.method === 'HEAD');
|
|
113
113
|
return sendFastifyJson(reply, result, request.method === 'HEAD');
|
|
114
|
-
}
|
|
114
|
+
};
|
|
115
|
+
protectedApi.post('/triggers/:triggerId/commands/instructions', {
|
|
116
|
+
bodyLimit: 6 * (options.operatorInstructionsMaxWriteBytes ?? 25 * 1024 * 1024) + 4096,
|
|
117
|
+
}, dispatchProtected);
|
|
118
|
+
protectedApi.all('/*', dispatchProtected);
|
|
115
119
|
done();
|
|
116
120
|
}, { prefix: '/api/v1' });
|
|
117
121
|
app.route({
|
|
@@ -18,6 +18,9 @@ export function presentRun(value) {
|
|
|
18
18
|
? outcomeSentinels[value.outcome.kind]
|
|
19
19
|
: value.status.toUpperCase()));
|
|
20
20
|
return {
|
|
21
|
+
...(value.operatorInstructions === undefined
|
|
22
|
+
? {}
|
|
23
|
+
: { operatorInstructions: value.operatorInstructions }),
|
|
21
24
|
runId: value.runId,
|
|
22
25
|
activationId: value.activationId,
|
|
23
26
|
activity: value.activity,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RunStatus } from '../../../execution/index.js';
|
|
2
2
|
import type { AnalyticsReport, ReportDescriptor, ReportWindowId } from '../../../kernel/index.js';
|
|
3
|
-
import type { ApiCommandResult, AuditEventResponse, BoardCardResponse, BoardResponse, CommandsResponse, ConfigurationResponse, ControlPlaneStatusResponse, ConversationMessageRequest, HealthResponse, MetricsResponse, ResourceItemResponse, ResourceResponse, ResponseMeta, RunnerResponse, RunResponse, RunTranscriptResponse, StatusResponse, TriggerResponse, WebhookSetupResponse, WorkDetailResponse, WorkflowDiagramsResponse, WorkflowInstanceResponse, WorkItemResponse, WorkItemTranscriptResponse } from '../contracts/index.js';
|
|
3
|
+
import type { ApiCommandResult, AuditEventResponse, BoardCardResponse, BoardResponse, CommandsResponse, ConfigurationResponse, ControlPlaneStatusResponse, ConversationMessageRequest, HealthResponse, MetricsResponse, OrphanedInstructionsResponse, ResourceItemResponse, ResourceResponse, ResponseMeta, RunnerResponse, RunResponse, RunTranscriptResponse, StatusResponse, TriggerResponse, WebhookSetupResponse, WorkDetailResponse, WorkflowDiagramsResponse, WorkflowInstanceResponse, WorkItemResponse, WorkItemTranscriptResponse } from '../contracts/index.js';
|
|
4
4
|
import type { AnalyticsSummaryResponse } from '../contracts/observability.js';
|
|
5
5
|
export interface CollectionQuery {
|
|
6
6
|
readonly cursor?: {
|
|
@@ -55,8 +55,14 @@ export interface ApiApplications {
|
|
|
55
55
|
clearMaintenance?(command: ApiClearMaintenanceRequest): Promise<ApiCommandResult>;
|
|
56
56
|
};
|
|
57
57
|
readonly triggers?: {
|
|
58
|
-
list(): Promise<ApiResourceResult<readonly TriggerResponse[]
|
|
58
|
+
list(): Promise<ApiResourceResult<readonly TriggerResponse[]> & {
|
|
59
|
+
readonly orphanedInstructions?: readonly OrphanedInstructionsResponse[];
|
|
60
|
+
}>;
|
|
59
61
|
detail(id: string): Promise<ApiResourceResult<TriggerResponse> | undefined>;
|
|
62
|
+
saveInstructions?(id: string, command: ApiCommandRequest & {
|
|
63
|
+
readonly content: string;
|
|
64
|
+
readonly expectedRevisionId: string | null;
|
|
65
|
+
}): Promise<ApiCommandResult>;
|
|
60
66
|
pause(id: string, command: ApiCommandRequest): Promise<ApiCommandResult>;
|
|
61
67
|
resume(id: string, command: ApiCommandRequest): Promise<ApiCommandResult>;
|
|
62
68
|
};
|
|
@@ -13,19 +13,15 @@ export async function dispatchCommand(applications, url, body) {
|
|
|
13
13
|
const maintenance = await dispatchMaintenanceClear(applications, url.pathname, body);
|
|
14
14
|
if (maintenance !== undefined)
|
|
15
15
|
return maintenance;
|
|
16
|
+
const instructions = await dispatchInstructions(applications, url.pathname, body);
|
|
17
|
+
if (instructions !== undefined)
|
|
18
|
+
return instructions;
|
|
16
19
|
const request = commandRequest(body);
|
|
17
20
|
if (isHttpResponse(request))
|
|
18
21
|
return request;
|
|
19
|
-
const trigger =
|
|
20
|
-
if (trigger !==
|
|
21
|
-
|
|
22
|
-
if (id instanceof ApiPathError)
|
|
23
|
-
return invalidPath(id.message);
|
|
24
|
-
if (applications.triggers === undefined)
|
|
25
|
-
return unavailable('triggers');
|
|
26
|
-
const operation = trigger[2] === 'pause' ? applications.triggers.pause : applications.triggers.resume;
|
|
27
|
-
return accepted(await operation(id, request), applications.now(), 200);
|
|
28
|
-
}
|
|
22
|
+
const trigger = await dispatchTriggerCommand(applications, url.pathname, request);
|
|
23
|
+
if (trigger !== undefined)
|
|
24
|
+
return trigger;
|
|
29
25
|
const control = await dispatchControlCommand(applications, url.pathname, request);
|
|
30
26
|
if (control !== undefined)
|
|
31
27
|
return control;
|
|
@@ -211,3 +207,44 @@ function isHttpResponse(value) {
|
|
|
211
207
|
'status' in value &&
|
|
212
208
|
typeof value.status === 'number');
|
|
213
209
|
}
|
|
210
|
+
async function dispatchInstructions(applications, pathname, body) {
|
|
211
|
+
const instructions = /^\/api\/v1\/triggers\/([^/]+)\/commands\/instructions$/.exec(pathname);
|
|
212
|
+
if (instructions !== null) {
|
|
213
|
+
const id = decodePathSegment(instructions[1]);
|
|
214
|
+
if (id instanceof ApiPathError)
|
|
215
|
+
return invalidPath(id.message);
|
|
216
|
+
if (!isObject(body) ||
|
|
217
|
+
Object.keys(body).some((key) => !['idempotencyKey', 'content', 'expectedRevisionId'].includes(key)))
|
|
218
|
+
return invalidRequest('', 'Expected idempotencyKey, content and expectedRevisionId');
|
|
219
|
+
const request = commandRequest({ idempotencyKey: body.idempotencyKey });
|
|
220
|
+
if (isHttpResponse(request))
|
|
221
|
+
return request;
|
|
222
|
+
if (typeof body.content !== 'string')
|
|
223
|
+
return invalidRequest('content', 'Must be a string');
|
|
224
|
+
if (body.expectedRevisionId !== null &&
|
|
225
|
+
(typeof body.expectedRevisionId !== 'string' || body.expectedRevisionId.length === 0))
|
|
226
|
+
return invalidRequest('expectedRevisionId', 'Must be a revision ID or null');
|
|
227
|
+
const save = applications.triggers?.saveInstructions;
|
|
228
|
+
if (save === undefined)
|
|
229
|
+
return unavailable('operator-instructions');
|
|
230
|
+
return accepted(await save(id, {
|
|
231
|
+
...request,
|
|
232
|
+
content: body.content,
|
|
233
|
+
expectedRevisionId: body.expectedRevisionId,
|
|
234
|
+
}), applications.now(), 200);
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
async function dispatchTriggerCommand(applications, pathname, request) {
|
|
239
|
+
const trigger = /^\/api\/v1\/triggers\/([^/]+)\/commands\/(pause|resume)$/.exec(pathname);
|
|
240
|
+
if (trigger !== null) {
|
|
241
|
+
const id = decodePathSegment(trigger[1]);
|
|
242
|
+
if (id instanceof ApiPathError)
|
|
243
|
+
return invalidPath(id.message);
|
|
244
|
+
if (applications.triggers === undefined)
|
|
245
|
+
return unavailable('triggers');
|
|
246
|
+
const operation = trigger[2] === 'pause' ? applications.triggers.pause : applications.triggers.resume;
|
|
247
|
+
return accepted(await operation(id, request), applications.now(), 200);
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|