@atolis-hq/wake 0.4.72 → 0.4.74

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.
@@ -0,0 +1,3 @@
1
+ import { type PromptTemplate } from '../execution/index.js';
2
+ import type { ResolvedWakeModulesConfig } from './config/root-schema.js';
3
+ export declare function runnerToolNotices(config: ResolvedWakeModulesConfig, templates?: ReadonlyMap<string, PromptTemplate>): string[];
@@ -0,0 +1,31 @@
1
+ import { BuiltInActivityName, agentActivityDefinition } from '../activities/index.js';
2
+ import { RunnerKind } from '../execution/index.js';
3
+ export function runnerToolNotices(config, templates = new Map()) {
4
+ const notices = [];
5
+ for (const [workflowName, workflow] of Object.entries(config.orchestration.workflows)) {
6
+ for (const [stageName, stage] of Object.entries(workflow.stages)) {
7
+ if (stage.activity !== BuiltInActivityName.Agent)
8
+ continue;
9
+ if (!hasToolList(stage.with, templates))
10
+ continue;
11
+ const pool = stage.execution?.runnerPool ?? config.execution.defaultRunnerPool;
12
+ const codexRunners = (config.execution.runnerPools[pool] ?? []).filter((runner) => config.execution.agentRunners?.[runner]?.kind === RunnerKind.CodexCli);
13
+ for (const runner of codexRunners) {
14
+ notices.push(`Workflow "${workflowName}" stage "${stageName}": allowedTools is advisory and is not enforced by Codex runner "${runner}" (pool "${pool}").`);
15
+ }
16
+ }
17
+ }
18
+ return notices;
19
+ }
20
+ function hasToolList(input, templates) {
21
+ const parsed = agentActivityDefinition.inputSchema.safeParse(input);
22
+ if (!parsed.success)
23
+ return false;
24
+ const stage = parsed.data;
25
+ if (stage.template !== undefined && !templates.has(stage.template))
26
+ return false;
27
+ const templateTools = stage.template === undefined
28
+ ? undefined
29
+ : templates.get(stage.template)?.frontmatter.allowedTools;
30
+ return (stage.allowedTools ?? templateTools ?? []).length > 0;
31
+ }
@@ -19,6 +19,7 @@ import { createNpmUpdatePort } from './npm-update-port.js';
19
19
  import { runtimeProjectionDefinitions } from './projection-runtime.js';
20
20
  import { createRunnerRegistry } from './runner-registry.js';
21
21
  import { createOneShotRunnerAdvance, createResidentRunnerAdvance, withFinalProjectionCatchUp, } from './runner-tick-adapter.js';
22
+ import { runnerToolNotices } from './runner-tool-notices.js';
22
23
  import { createSelfUpdateApplication, } from './self-update-application.js';
23
24
  import { createSelfUpdateFailureLog } from './self-update-failure-log.js';
24
25
  import { createSourceUpdatePort } from './source-update-port.js';
@@ -660,6 +661,7 @@ function spawnDocker(arguments_, onChunk, cwd, options) {
660
661
  async function doctorDiagnostics(root) {
661
662
  const failures = [];
662
663
  const notices = [];
664
+ const templates = new Map();
663
665
  try {
664
666
  createRunnerRegistry(root.config.execution, root.fakeScenarios).resolve(root.config.execution.defaultRunnerPool);
665
667
  }
@@ -674,12 +676,13 @@ async function doctorDiagnostics(root) {
674
676
  }
675
677
  for (const name of referencedPromptTemplateNames(root.config.orchestration.workflows)) {
676
678
  try {
677
- await loadPromptTemplate(root.paths.wakeRoot, name);
679
+ templates.set(name, await loadPromptTemplate(root.paths.wakeRoot, name));
678
680
  }
679
681
  catch (error) {
680
682
  failures.push(`prompt template "${name}" is not readable: ${error.message}`);
681
683
  }
682
684
  }
685
+ notices.push(...runnerToolNotices(root.config, templates));
683
686
  await checkProviders(root, failures, notices);
684
687
  await checkMaintenanceLease(root, failures);
685
688
  notices.push(...(await dockerSandboxHealthNotices(root)));
@@ -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.72";
127
+ export const wakeVersion = "v0.4.74";
128
128
  /** The registry-installable version used by packaged sandbox images. */
129
129
  export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
@@ -47,7 +47,8 @@ export function consumedTriggerRequest(request, reason) {
47
47
  coordinationKey: request.coordinationKey,
48
48
  source: request.source,
49
49
  disposition: TriggerRequestDisposition.Skipped,
50
- manualOutcome: request.manualOutcome?.disposition === ManualTriggerDisposition.Started
50
+ manualOutcome: request.manualOutcome !== undefined &&
51
+ request.manualOutcome.disposition !== ManualTriggerDisposition.Skipped
51
52
  ? { disposition: ManualTriggerDisposition.Skipped, reason }
52
53
  : request.manualOutcome,
53
54
  },
@@ -26,6 +26,7 @@ export async function requestManualTrigger(ports, triggerId, context) {
26
26
  disposition: active
27
27
  ? ManualTriggerDisposition.Coalesced
28
28
  : ManualTriggerDisposition.Started,
29
+ ...activeWorkItem(view, coordinationKey),
29
30
  }
30
31
  : { disposition: ManualTriggerDisposition.Skipped, reason };
31
32
  const source = {
@@ -72,11 +73,32 @@ async function recoverManualOutcome(ports, triggerId, context) {
72
73
  return resolvePausedRequest(ports, request, pauseCleared, context);
73
74
  }
74
75
  async function resolvePausedRequest(ports, request, pauseCleared, context) {
75
- if (request?.manualOutcome?.disposition !== ManualTriggerDisposition.Started || !pauseCleared)
76
- return request?.manualOutcome;
76
+ if (request?.manualOutcome === undefined)
77
+ return undefined;
78
+ if (settledManualOutcome(request.manualOutcome))
79
+ return request.manualOutcome;
77
80
  const history = await ports.dependencies.history();
78
- if (history.some((invocation) => invocation.claim.triggerId === request.triggerId &&
79
- invocation.claim.sources.some((source) => sourceIdentity(source) === sourceIdentity(request.source))))
81
+ const invocation = history.find((invocation) => invocation.claim.triggerId === request.triggerId &&
82
+ invocation.claim.sources.some((source) => sourceIdentity(source) === sourceIdentity(request.source)));
83
+ if (request.manualOutcome.disposition === ManualTriggerDisposition.Coalesced &&
84
+ (!pauseCleared || invocation !== undefined))
85
+ return request.manualOutcome;
86
+ if (invocation?.startedAt !== undefined) {
87
+ const outcome = {
88
+ disposition: ManualTriggerDisposition.Started,
89
+ workItemId: invocation.claim.workItemId,
90
+ };
91
+ await ports.emit({
92
+ eventType: ControlEventType.TriggerRequestRecorded,
93
+ payload: {
94
+ ...request,
95
+ disposition: TriggerRequestDisposition.Started,
96
+ manualOutcome: outcome,
97
+ },
98
+ }, context, 'trigger:result:' + request.triggerId + ':' + sourceIdentity(request.source));
99
+ return outcome;
100
+ }
101
+ if (!pauseCleared || invocation !== undefined)
80
102
  return request.manualOutcome;
81
103
  // Pause clears unclaimed requests, but a committed claim still recovers normally.
82
104
  const fact = consumedTriggerRequest(request, TriggerSkipReason.Paused);
@@ -93,3 +115,11 @@ function matchingManualRequest(event, triggerId, commandId) {
93
115
  return event.event.payload;
94
116
  return undefined;
95
117
  }
118
+ function activeWorkItem(view, coordinationKey) {
119
+ const invocation = view.invocations.find((entry) => entry.claim.coordinationKey === coordinationKey && entry.result === undefined);
120
+ return invocation === undefined ? {} : { activeWorkItemId: invocation.claim.workItemId };
121
+ }
122
+ function settledManualOutcome(outcome) {
123
+ return (outcome.disposition === ManualTriggerDisposition.Skipped ||
124
+ (outcome.disposition === ManualTriggerDisposition.Started && outcome.workItemId !== undefined));
125
+ }
@@ -34,7 +34,9 @@ export const triggerProjection = {
34
34
  ].slice(0, maximumTriggerSources),
35
35
  },
36
36
  }
37
- : withoutCoalesced(previous.coalesced, request),
37
+ : request.disposition === TriggerRequestDisposition.Started
38
+ ? previous.coalesced
39
+ : withoutCoalesced(previous.coalesced, request),
38
40
  };
39
41
  }
40
42
  case ControlEventType.TriggerInvocationClaimed: {
@@ -19,7 +19,11 @@ export declare const RunnerPauseCause: {
19
19
  readonly Quota: "quota";
20
20
  };
21
21
  export declare const ControlEventNamespace: "control-plane.";
22
+ declare const manualStartedShape: {
23
+ started: boolean;
24
+ };
22
25
  export declare const TriggerRequestDisposition: {
26
+ readonly Started: keyof typeof manualStartedShape;
23
27
  readonly Coalesced: "coalesced";
24
28
  readonly Skipped: "skipped";
25
29
  };
@@ -28,9 +32,6 @@ export declare const TriggerSourceKind: {
28
32
  readonly Cron: "cron";
29
33
  readonly Manual: "manual";
30
34
  };
31
- declare const manualStartedShape: {
32
- started: boolean;
33
- };
34
35
  export declare const ManualTriggerDisposition: {
35
36
  readonly Started: keyof typeof manualStartedShape;
36
37
  readonly Coalesced: "coalesced";
@@ -38,8 +39,10 @@ export declare const ManualTriggerDisposition: {
38
39
  };
39
40
  export declare const manualTriggerOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
41
  disposition: z.ZodLiteral<"started">;
42
+ workItemId: z.ZodOptional<z.ZodString>;
41
43
  }, z.core.$strict>, z.ZodObject<{
42
44
  disposition: z.ZodLiteral<"coalesced">;
45
+ activeWorkItemId: z.ZodOptional<z.ZodString>;
43
46
  }, z.core.$strict>, z.ZodObject<{
44
47
  disposition: z.ZodLiteral<"skipped">;
45
48
  reason: z.ZodEnum<{
@@ -17,17 +17,31 @@ export const ControlEventType = {
17
17
  };
18
18
  export const RunnerPauseCause = { Manual: 'manual', Quota: 'quota' };
19
19
  export const ControlEventNamespace = 'control-plane.';
20
- export const TriggerRequestDisposition = { Coalesced: 'coalesced', Skipped: 'skipped' };
21
- export const TriggerSourceKind = { Event: 'event', Cron: 'cron', Manual: 'manual' };
22
20
  const manualStartedShape = { started: true };
21
+ export const TriggerRequestDisposition = {
22
+ Started: Object.keys(manualStartedShape)[0],
23
+ Coalesced: 'coalesced',
24
+ Skipped: 'skipped',
25
+ };
26
+ export const TriggerSourceKind = { Event: 'event', Cron: 'cron', Manual: 'manual' };
23
27
  export const ManualTriggerDisposition = {
24
28
  Started: Object.keys(manualStartedShape)[0],
25
29
  Coalesced: TriggerRequestDisposition.Coalesced,
26
30
  Skipped: TriggerRequestDisposition.Skipped,
27
31
  };
28
32
  export const manualTriggerOutcomeSchema = z.discriminatedUnion('disposition', [
29
- z.object({ disposition: z.literal(ManualTriggerDisposition.Started) }).strict(),
30
- z.object({ disposition: z.literal(ManualTriggerDisposition.Coalesced) }).strict(),
33
+ z
34
+ .object({
35
+ disposition: z.literal(ManualTriggerDisposition.Started),
36
+ workItemId: z.string().min(1).optional(),
37
+ })
38
+ .strict(),
39
+ z
40
+ .object({
41
+ disposition: z.literal(ManualTriggerDisposition.Coalesced),
42
+ activeWorkItemId: z.string().min(1).optional(),
43
+ })
44
+ .strict(),
31
45
  z
32
46
  .object({
33
47
  disposition: z.literal(ManualTriggerDisposition.Skipped),
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { RunnerKind } from './vocabulary.js';
2
3
  export declare const executionConfigSchema: z.ZodObject<{
3
4
  agentRunners: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
4
5
  model: z.ZodOptional<z.ZodString>;
@@ -69,7 +70,7 @@ export declare const executionConfigSchema: z.ZodObject<{
69
70
  }, z.core.$strict>;
70
71
  export interface ExecutionConfig {
71
72
  readonly agentRunners?: Readonly<Record<string, {
72
- readonly kind: 'claude-cli' | 'codex-cli' | 'cursor-cli' | 'command' | 'fake';
73
+ readonly kind: RunnerKind;
73
74
  readonly command?: string;
74
75
  readonly model?: string;
75
76
  readonly effort?: string;
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { RunnerKind } from './vocabulary.js';
2
3
  const isReservedFlag = (arg) => arg === '--output-format' || arg === '--resume';
3
4
  const agentRunnerBase = {
4
5
  model: z.string().trim().min(1).optional(),
@@ -21,11 +22,11 @@ export const executionConfigSchema = z
21
22
  agentRunners: z
22
23
  .record(z.string().trim().min(1), z
23
24
  .discriminatedUnion('kind', [
24
- commandRunner('claude-cli'),
25
- commandRunner('codex-cli'),
26
- commandRunner('cursor-cli'),
27
- commandRunner('command'),
28
- z.object({ kind: z.literal('fake'), ...agentRunnerBase }).strict(),
25
+ commandRunner(RunnerKind.ClaudeCli),
26
+ commandRunner(RunnerKind.CodexCli),
27
+ commandRunner(RunnerKind.CursorCli),
28
+ commandRunner(RunnerKind.Command),
29
+ z.object({ kind: z.literal(RunnerKind.Fake), ...agentRunnerBase }).strict(),
29
30
  ])
30
31
  .refine((value) => !value.args.some(isReservedFlag), {
31
32
  message: 'args must not contain --output-format or --resume',
@@ -48,3 +48,11 @@ export declare const TranscriptGroupKind: {
48
48
  readonly Run: string;
49
49
  };
50
50
  export type TranscriptGroupKind = ValueOf<typeof TranscriptGroupKind>;
51
+ export declare const RunnerKind: {
52
+ readonly ClaudeCli: "claude-cli";
53
+ readonly CodexCli: "codex-cli";
54
+ readonly CursorCli: "cursor-cli";
55
+ readonly Command: "command";
56
+ readonly Fake: "fake";
57
+ };
58
+ export type RunnerKind = ValueOf<typeof RunnerKind>;
@@ -46,3 +46,10 @@ export const TranscriptGroupKind = {
46
46
  Session: transcriptGroupKinds[0],
47
47
  Run: transcriptGroupKinds[1],
48
48
  };
49
+ export const RunnerKind = {
50
+ ClaudeCli: 'claude-cli',
51
+ CodexCli: 'codex-cli',
52
+ CursorCli: 'cursor-cli',
53
+ Command: 'command',
54
+ Fake: 'fake',
55
+ };
@@ -64,7 +64,9 @@ export const TriggerSourceKindValue = {
64
64
  Cron: 'cron',
65
65
  Manual: 'manual',
66
66
  };
67
+ const manualStartedShape = { started: true };
67
68
  export const TriggerRequestDispositionValue = {
69
+ Started: Object.keys(manualStartedShape)[0],
68
70
  Coalesced: 'coalesced',
69
71
  Skipped: 'skipped',
70
72
  };
@@ -82,7 +84,6 @@ export const TriggerFinishedStatusValue = {
82
84
  Completed: triggerFinishedStatuses[0],
83
85
  Superseded: triggerFinishedStatuses[1],
84
86
  };
85
- const manualStartedShape = { started: true };
86
87
  export const ManualTriggerDispositionValue = {
87
88
  Started: Object.keys(manualStartedShape)[0],
88
89
  Coalesced: TriggerRequestDispositionValue.Coalesced,