@fbincon/claude-code-statusline 3.6.0 → 3.7.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 (178) hide show
  1. package/README.md +77 -75
  2. package/candidate.json +331 -279
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js +23 -5
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js.map +1 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +43 -1
  6. package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -1
  7. package/node_modules/@fbincon/statusline-cli/dist/src/help.js +2 -1
  8. package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
  9. package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js +2 -1
  10. package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js.map +1 -1
  11. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js +2 -1
  12. package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js.map +1 -1
  13. package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.js +1 -1
  14. package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js +2 -1
  15. package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js.map +1 -1
  16. package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js +11 -3
  17. package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js.map +1 -1
  18. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.d.ts +35 -0
  19. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js +75 -0
  20. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js.map +1 -0
  21. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.d.ts +12 -0
  22. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js +99 -0
  23. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js.map +1 -0
  24. package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js +5 -3
  25. package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js.map +1 -1
  26. package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.d.ts +6 -0
  27. package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.js +12 -0
  28. package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.js.map +1 -0
  29. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.d.ts +9 -4
  30. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js +84 -18
  31. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js.map +1 -1
  32. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +1 -1
  33. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  34. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +9 -5
  35. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +4 -0
  36. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +1 -0
  37. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/appearance.ts +3 -1
  38. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/cost-rate.ts +9 -0
  39. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +6 -1
  40. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +3 -1
  41. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts +102 -0
  42. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/groups.ts +89 -0
  43. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/indicators.ts +20 -0
  44. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-manager.ts +20 -17
  45. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-validation.ts +5 -4
  46. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +23 -11
  47. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +288 -6
  48. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +3 -1
  49. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +21 -17
  50. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +5 -1
  51. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +1 -0
  52. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +7 -1
  53. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/hooks/observe.ts +27 -2
  54. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/generated-contracts.ts +1 -1
  55. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +6 -6
  56. package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.d.ts +123 -0
  57. package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js +168 -0
  58. package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js.map +1 -1
  59. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +2 -2
  60. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js.map +1 -1
  61. package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +2 -2
  62. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +22 -12
  63. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
  64. package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js +6 -0
  65. package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js.map +1 -1
  66. package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +8 -1
  67. package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -1
  68. package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js +2 -0
  69. package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js.map +1 -1
  70. package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js +8 -6
  71. package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js.map +1 -1
  72. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +1 -1
  73. package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -1
  74. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +1 -1
  75. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +1 -1
  76. package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -1
  77. package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.d.ts +1 -1
  78. package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.js +1 -1
  79. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +42 -9
  80. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +5 -5
  81. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
  82. package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js +3 -1
  83. package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js.map +1 -1
  84. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +10 -5
  85. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  86. package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.d.ts +7 -0
  87. package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.js +8 -0
  88. package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.js.map +1 -0
  89. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +2 -0
  90. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +5 -1
  91. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  92. package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +3 -1
  93. package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -1
  94. package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.d.ts +23 -0
  95. package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js +131 -0
  96. package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js.map +1 -0
  97. package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.d.ts +18 -0
  98. package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js +103 -0
  99. package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js.map +1 -0
  100. package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.d.ts +11 -0
  101. package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js +18 -0
  102. package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js.map +1 -0
  103. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.d.ts +3 -2
  104. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js +20 -11
  105. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js.map +1 -1
  106. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js +6 -4
  107. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js.map +1 -1
  108. package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js +20 -4
  109. package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js.map +1 -1
  110. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +282 -0
  111. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +288 -6
  112. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  113. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.d.ts +4 -0
  114. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js +5 -1
  115. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js.map +1 -1
  116. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.d.ts +4 -0
  117. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js +5 -1
  118. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js.map +1 -1
  119. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.d.ts +4 -0
  120. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js +5 -1
  121. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js.map +1 -1
  122. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.d.ts +4 -0
  123. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js +5 -1
  124. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js.map +1 -1
  125. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.d.ts +4 -0
  126. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js +5 -1
  127. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js.map +1 -1
  128. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.d.ts +4 -0
  129. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js +5 -1
  130. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js.map +1 -1
  131. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  132. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  133. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.d.ts +2 -2
  134. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js +6 -3
  135. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js.map +1 -1
  136. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +4 -0
  137. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
  138. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.d.ts +7 -0
  139. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +124 -0
  140. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -0
  141. package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.d.ts +4 -0
  142. package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js +48 -0
  143. package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js.map +1 -0
  144. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +12 -1
  145. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
  146. package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.d.ts +3 -0
  147. package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js +14 -0
  148. package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js.map +1 -1
  149. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +1 -1
  150. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
  151. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +11 -1
  152. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
  153. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +1 -1
  154. package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.d.ts +2 -1
  155. package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js +2 -1
  156. package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js.map +1 -1
  157. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +48 -1
  158. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +48 -1
  159. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +48 -1
  160. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +48 -1
  161. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +48 -1
  162. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +48 -1
  163. package/node_modules/@fbincon/statusline-platform/dist/src/files.d.ts +3 -0
  164. package/node_modules/@fbincon/statusline-platform/dist/src/files.js +7 -2
  165. package/node_modules/@fbincon/statusline-platform/dist/src/files.js.map +1 -1
  166. package/node_modules/@fbincon/statusline-platform/dist/src/source-files.js +18 -3
  167. package/node_modules/@fbincon/statusline-platform/dist/src/source-files.js.map +1 -1
  168. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +5 -0
  169. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  170. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +6 -0
  171. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  172. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +2 -0
  173. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  174. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +1 -1
  175. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  176. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +12 -1
  177. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  178. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ import type { AutomaticStatus, SourceContext, SourceDefinition, SourceJob, SourceRegistry } from '@fbincon/statusline-core/contracts/ui';
2
+ export declare const LEASE_MS = 15000;
3
+ export interface Lease {
4
+ id: string;
5
+ session: string;
6
+ epoch: string;
7
+ seq: number;
8
+ expires: number;
9
+ closed: boolean;
10
+ keys: string[];
11
+ }
12
+ export interface Schedule {
13
+ key: string;
14
+ source_id: string;
15
+ job_id: string | null;
16
+ processed: string | null;
17
+ next: number;
18
+ failures: number;
19
+ paused: string | null;
20
+ last_attempt: string | null;
21
+ last_success: string | null;
22
+ }
23
+ export interface AutomaticState {
24
+ version: 1;
25
+ leases: Lease[];
26
+ schedules: Schedule[];
27
+ }
28
+ export declare function readAutomatic(directory: string): AutomaticState;
29
+ export declare function writeAutomatic(directory: string, state: AutomaticState): void;
30
+ export declare function sourceRegistry(directory: string): SourceRegistry;
31
+ export declare function automaticRequested(directory: string): boolean;
32
+ export declare function refreshIdentity(source: SourceDefinition, context: SourceContext): string;
33
+ export declare function activeLease(state: AutomaticState, identity: string, now: number): boolean;
34
+ export declare function automaticJobActive(directory: string, job: SourceJob, now: number): boolean;
35
+ export declare function automaticStatus(directory: string, source: SourceDefinition, context: SourceContext, now: number, jobs: SourceJob[]): AutomaticStatus;
@@ -0,0 +1,75 @@
1
+ /** Local scheduling state. Reading it never starts a process or refresh. */
2
+ import { join } from 'node:path';
3
+ import { emptyRegistry, registry, SOURCE_FILENAME, observationContext, MAX_SOURCE_BYTES } from '@fbincon/statusline-core/extensions/model';
4
+ import { readJson } from '@fbincon/statusline-core/json-read';
5
+ import { sourceError } from '@fbincon/statusline-core/extensions/model';
6
+ import { object } from '@fbincon/statusline-core/config/validation';
7
+ import { revision } from '@fbincon/statusline-platform/hash';
8
+ import { readSourceFile } from '@fbincon/statusline-platform/source-files';
9
+ import { decodeUtf8 } from '@fbincon/statusline-platform/utf8';
10
+ import { privateDirectory, atomicWrite } from '@fbincon/statusline-platform/files';
11
+ import { safeTarget } from '../integration/paths.js';
12
+ import { authRevision } from './context.js';
13
+ export const LEASE_MS = 15000;
14
+ const path = (directory) => join(directory, 'statusline_runtime', 'sources', 'automatic.json');
15
+ const hash = (v) => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v);
16
+ export function readAutomatic(directory) {
17
+ const bytes = readSourceFile(path(directory));
18
+ if (!bytes)
19
+ return { version: 1, leases: [], schedules: [] };
20
+ const value = JSON.parse(decodeUtf8(bytes));
21
+ if (!object(value) || value.version !== 1 || !Array.isArray(value.leases) || !Array.isArray(value.schedules) || value.leases.length > 64 || value.schedules.length > 512 ||
22
+ !value.leases.every(l => object(l) && hash(l.id) && typeof l.session === 'string' && typeof l.epoch === 'string' && Number.isSafeInteger(l.seq) && typeof l.expires === 'number' && Number.isFinite(l.expires) && typeof l.closed === 'boolean' && Array.isArray(l.keys) && l.keys.length <= 128 && l.keys.every(hash)) ||
23
+ !value.schedules.every(s => object(s) && hash(s.key) && typeof s.source_id === 'string' && (s.job_id === null || typeof s.job_id === 'string') && (s.processed === null || typeof s.processed === 'string') && typeof s.next === 'number' && Number.isFinite(s.next) && Number.isSafeInteger(s.failures) && (s.paused === null || typeof s.paused === 'string') && [s.last_attempt, s.last_success].every(v => v === null || typeof v === 'string' && Number.isFinite(Date.parse(v)))))
24
+ throw new Error('Invalid automatic refresh state');
25
+ return value;
26
+ }
27
+ export function writeAutomatic(directory, state) {
28
+ const target = path(directory);
29
+ safeTarget(directory, target);
30
+ privateDirectory(join(directory, 'statusline_runtime', 'sources'));
31
+ safeTarget(directory, target);
32
+ const bytes = Buffer.from(JSON.stringify(state) + '\n');
33
+ if (bytes.length > MAX_SOURCE_BYTES)
34
+ throw new Error('Automatic refresh state exceeds its size limit');
35
+ atomicWrite(target, bytes);
36
+ }
37
+ export function sourceRegistry(directory) {
38
+ const bytes = readSourceFile(join(directory, SOURCE_FILENAME));
39
+ return bytes ? registry(readJson(decodeUtf8(bytes), { duplicate: () => sourceError('invalid'), constant: () => sourceError('type') })) : emptyRegistry();
40
+ }
41
+ export function automaticRequested(directory) {
42
+ return sourceRegistry(directory).automatic.some(p => p.enabled);
43
+ }
44
+ export function refreshIdentity(source, context) {
45
+ return revision({ source: source.id, revision: source.revision, settings: source.settings, context: observationContext(source, context), auth: source.kind === 'github' ? authRevision() : null });
46
+ }
47
+ export function activeLease(state, identity, now) {
48
+ return state.leases.some(l => !l.closed && l.expires > now && l.keys.includes(identity));
49
+ }
50
+ export function automaticJobActive(directory, job, now) {
51
+ if (job.trigger !== 'automatic')
52
+ return true;
53
+ const registry = sourceRegistry(directory), source = registry.sources.find(s => s.id === job.source_id), policy = registry.automatic.find(p => p.source_id === job.source_id);
54
+ return Boolean(source?.enabled && policy?.enabled && policy.review_revision === source.revision && policy.auth_revision === authRevision() && refreshIdentity(source, job.context) === job.identity && activeLease(readAutomatic(directory), job.identity, now));
55
+ }
56
+ export function automaticStatus(directory, source, context, now, jobs) {
57
+ const policy = sourceRegistry(directory).automatic.find(p => p.source_id === source.id);
58
+ const base = { state: 'off', reason: 'off', next_at: null, last_attempt: null, last_success: null, interval_seconds: policy?.interval_seconds ?? Math.max(60, Math.min(86400, source.ttl_seconds)) };
59
+ if (!policy?.enabled || !source.enabled)
60
+ return base;
61
+ if (policy.auth_revision !== authRevision())
62
+ return { ...base, state: 'paused', reason: 'identity' };
63
+ if (!context.head || !context.branch || context.branch !== source.settings.branch)
64
+ return { ...base, state: 'paused', reason: 'identity' };
65
+ const identity = refreshIdentity(source, context), state = readAutomatic(directory), schedule = state.schedules.find(s => s.key === identity);
66
+ const result = { ...base, last_attempt: schedule?.last_attempt ?? null, last_success: schedule?.last_success ?? null };
67
+ if (schedule?.paused)
68
+ return { ...result, state: 'paused', reason: schedule.paused };
69
+ if (!activeLease(state, identity, now))
70
+ return { ...result, state: 'waiting', reason: 'no_session' };
71
+ if (jobs.some(j => j.identity === identity && j.state === 'running'))
72
+ return { ...result, state: 'running', reason: 'running' };
73
+ return { ...result, state: schedule?.failures ? 'backoff' : 'waiting', reason: schedule?.failures ? 'retry' : 'scheduled', next_at: schedule ? new Date(schedule.next).toISOString() : null };
74
+ }
75
+ //# sourceMappingURL=automatic-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automatic-state.js","sourceRoot":"","sources":["../../../src/sources/automatic-state.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC3I,OAAO,EAAE,Q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MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAClM,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { contextFor } from './context.js';
2
+ import { SourceService } from './service.js';
3
+ export declare class AutomaticRefresh {
4
+ readonly sources: SourceService;
5
+ readonly context: typeof contextFor;
6
+ constructor(sources: SourceService, context?: typeof contextFor);
7
+ lifecycle(payload: unknown): {
8
+ backend_version: string;
9
+ enabled: boolean;
10
+ scheduled: number;
11
+ };
12
+ }
@@ -0,0 +1,99 @@
1
+ import { exact, integer } from '@fbincon/statusline-core/config/validation';
2
+ import { sourceId, sourceText, matchesScope, observationContext } from '@fbincon/statusline-core/extensions/model';
3
+ import { VERSION } from '@fbincon/statusline-core/release';
4
+ import { revision } from '@fbincon/statusline-platform/hash';
5
+ import { contextFor, authRevision } from './context.js';
6
+ import { readAutomatic, writeAutomatic, refreshIdentity, LEASE_MS } from './automatic-state.js';
7
+ const pauseReasons = new Set(['auth', 'authentication', 'forbidden', 'permission', 'account', 'identity', 'scope', 'ambiguous']);
8
+ export class AutomaticRefresh {
9
+ sources;
10
+ context;
11
+ constructor(sources, context = contextFor) {
12
+ this.sources = sources;
13
+ this.context = context;
14
+ }
15
+ lifecycle(payload) {
16
+ exact(payload, ['session_id', 'epoch', 'seq', 'project', 'host_version', 'event'], 'source lifecycle');
17
+ const session = sourceId(payload.session_id), epoch = sourceId(payload.epoch), seq = integer(payload.seq, 0, Number.MAX_SAFE_INTEGER, 'seq');
18
+ const project = sourceText(payload.project), host = sourceText(payload.host_version, 64), event = payload.event;
19
+ if (event !== 'tick' && event !== 'end')
20
+ throw new Error('Invalid lifecycle event');
21
+ const version = /^(\d+)\.(\d+)\.(\d+)$/.exec(host)?.slice(1).map(Number);
22
+ const supported = Boolean(version && (version[0] > 2 || version[0] === 2 && (version[1] > 1 || version[1] === 1 && version[2] >= 289)));
23
+ const directory = this.sources.configuration.context.configDir, now = this.sources.now(), id = revision([session, epoch]);
24
+ const actual = event === 'tick' && supported ? this.context(project, session, null) : null;
25
+ const requests = [];
26
+ const enabled = this.sources.configuration.io.lock(directory, () => {
27
+ const registry = this.sources.read(), state = readAutomatic(directory), allJobs = this.sources.jobs();
28
+ let lease = state.leases.find(l => l.id === id);
29
+ if (lease && (lease.closed || seq <= lease.seq))
30
+ return registry.automatic.some(p => p.enabled);
31
+ if (!lease) {
32
+ lease = { id, session, epoch, seq, expires: now + LEASE_MS, closed: false, keys: [] };
33
+ state.leases = state.leases.filter(l => l.expires > now - 86400000).slice(-63);
34
+ state.leases.push(lease);
35
+ }
36
+ lease.seq = seq;
37
+ lease.expires = now + LEASE_MS;
38
+ lease.closed = event === 'end' || !supported;
39
+ lease.keys = [];
40
+ if (actual && !lease.closed)
41
+ for (const policy of registry.automatic) {
42
+ const source = registry.sources.find(s => s.id === policy.source_id);
43
+ if (!policy.enabled || !source.enabled || policy.review_revision !== source.revision || policy.auth_revision !== authRevision() || !matchesScope(source.scope, actual) || !actual.head || !actual.branch || actual.branch !== source.settings.branch)
44
+ continue;
45
+ const context = observationContext(source, actual), key = refreshIdentity(source, context);
46
+ lease.keys.push(key);
47
+ let schedule = state.schedules.find(s => s.key === key);
48
+ if (!schedule) {
49
+ schedule = { key, source_id: source.id, job_id: null, processed: null, next: now, failures: 0, paused: null, last_attempt: null, last_success: null };
50
+ state.schedules.push(schedule);
51
+ }
52
+ const jobs = allJobs.filter(j => j.identity === key).sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at));
53
+ const latest = jobs[0];
54
+ if (latest && latest.state !== 'running' && latest.id !== schedule.processed) {
55
+ schedule.processed = latest.id;
56
+ schedule.last_attempt = latest.started_at;
57
+ if (latest.state === 'completed' && !pauseReasons.has(latest.reason)) {
58
+ schedule.failures = 0;
59
+ schedule.paused = null;
60
+ schedule.last_success = new Date(now).toISOString();
61
+ }
62
+ else if (latest.reason !== 'lease_expired' && latest.reason !== 'cancelled') {
63
+ schedule.failures = Math.min(10, schedule.failures + 1);
64
+ schedule.paused = pauseReasons.has(latest.reason) ? latest.reason : null;
65
+ }
66
+ schedule.next = now + Math.min(86400000, policy.interval_seconds * 1000 * 2 ** schedule.failures);
67
+ }
68
+ if (latest?.state === 'running' || schedule.paused || schedule.next > now)
69
+ continue;
70
+ // Reserve under the same configuration lock used by job creation.
71
+ schedule.next = now + 30000;
72
+ requests.push({ source: source.id, context, key });
73
+ }
74
+ const activeKeys = new Set(state.leases.filter(l => !l.closed && l.expires > now).flatMap(l => l.keys));
75
+ state.schedules = state.schedules.filter(s => activeKeys.has(s.key) || s.next > now - 86400000).slice(-512);
76
+ writeAutomatic(directory, state);
77
+ return registry.automatic.some(p => p.enabled);
78
+ });
79
+ this.sources.cancelInactiveAutomatic();
80
+ let scheduled = 0;
81
+ for (const request of requests) {
82
+ try {
83
+ const job = this.sources.start(request.source, request.context, 'automatic-' + id.slice(0, 32), 'automatic');
84
+ this.sources.configuration.io.lock(directory, () => {
85
+ const state = readAutomatic(directory), schedule = state.schedules.find(s => s.key === request.key);
86
+ if (schedule) {
87
+ schedule.job_id = job.id;
88
+ schedule.last_attempt = job.started_at;
89
+ }
90
+ writeAutomatic(directory, state);
91
+ });
92
+ scheduled++;
93
+ }
94
+ catch { /* Disabled/expired/revised while dispatching: next heartbeat reconciles. */ }
95
+ }
96
+ return { backend_version: VERSION, enabled, scheduled };
97
+ }
98
+ }
99
+ //# sourceMappingURL=automatic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automatic.js","sourceRoot":"","sources":["../../../src/sources/automatic.ts"],"names":[],"mappings":"AAEA,OA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,CAAC,OAAO,EAAE,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC7G,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;oBAC/C,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;oBACpG,IAAI,QAAQ,EAAE,CAAC;wBAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;wBAAC,QAAQ,CAAC,YAAY,GAAG,GAAG,CAAC,UAAU,CAAC;oBAAC,CAAC;oBACnF,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACrC,CAAC,CAAC,CAAC;gBACH,SAAS,EAAE,CAAC;YAChB,CAAC;YAAC,MAAM,CAAC,CAAC,4EAA4E,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC5D,CAAC;CACJ"}
@@ -18,7 +18,7 @@ export async function sourceCommand(args, configuration, language) {
18
18
  return '';
19
19
  }
20
20
  const p = [], flags = {};
21
- const values = ['--file', '--review', '--project', '--session', '--agent', '--instance', '--scope', '--profile', '--binding'];
21
+ const values = ['--file', '--review', '--project', '--session', '--agent', '--instance', '--scope', '--profile', '--binding', '--interval'];
22
22
  let literal = false;
23
23
  for (let i = 0; i < rest.length; i++) {
24
24
  const token = rest[i];
@@ -43,7 +43,7 @@ export async function sourceCommand(args, configuration, language) {
43
43
  else
44
44
  p.push(token);
45
45
  }
46
- if (!['list', 'add', 'edit', 'review', 'enable', 'disable', 'remove', 'bind', 'unbind', 'refresh', 'status', 'cancel', 'diagnose'].includes(action ?? '') || p.length !== (action === 'list' ? 0 : 1))
46
+ if (!['list', 'add', 'edit', 'review', 'enable', 'disable', 'remove', 'bind', 'unbind', 'refresh', 'status', 'cancel', 'diagnose', 'auto-on', 'auto-off'].includes(action ?? '') || p.length !== (action === 'list' ? 0 : 1))
47
47
  sourceError('invalid');
48
48
  const id = p[0], pretty = (value) => JSON.stringify(value, null, 2), current = service.read();
49
49
  if (action === 'list')
@@ -93,8 +93,10 @@ export async function sourceCommand(args, configuration, language) {
93
93
  sourceError('invalid');
94
94
  payload.source = { name: id, ttl_seconds: 300, scope: { project: null, session: null, agent: null }, ...source };
95
95
  }
96
- if (action === 'enable')
96
+ if (action === 'enable' || action === 'auto-on')
97
97
  payload.review_revision = flags['--review'];
98
+ if (action === 'auto-on' && flags['--interval'] !== undefined)
99
+ payload.interval_seconds = Number(flags['--interval']);
98
100
  if (action === 'unbind')
99
101
  payload.binding = flags['--binding'];
100
102
  if (action === 'bind') {
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/sources/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,wCAAwC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAe,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAQ,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,M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G,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { RuntimeContext } from '../runtime/context.js';
2
+ export declare function sourceLifecycle(context: RuntimeContext, payload: unknown): {
3
+ backend_version: string;
4
+ enabled: boolean;
5
+ scheduled: number;
6
+ };
@@ -0,0 +1,12 @@
1
+ /** Loaded only for the runtime v3 lifecycle operation, never ordinary observations. */
2
+ import { fileURLToPath } from 'node:url';
3
+ import { ConfigurationService } from '../config/service.js';
4
+ import { createStorage } from '../config/storage.js';
5
+ import { SourceService } from './service.js';
6
+ import { AutomaticRefresh } from './automatic.js';
7
+ export function sourceLifecycle(context, payload) {
8
+ const configuration = new ConfigurationService({ configDir: context.configDir, hostVersion: () => null,
9
+ launch: { executable: process.execPath, args: [fileURLToPath(new URL('../entry.js', import.meta.url))] } }, createStorage(() => new Date(context.nowMs())));
10
+ return new AutomaticRefresh(new SourceService(configuration, context.nowMs)).lifecycle(payload);
11
+ }
12
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/sources/lifecycle.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,MAAM,UAAU,eAAe,CAAC,OAAuB,EAAE,OAAgB;IACrE,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI;QAClG,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAChK,OAAO,IAAI,gBAAgB,CAAC,IAAI,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACpG,CAAC"}
@@ -1,10 +1,13 @@
1
- import type { SourceDefinition, SourceContext, SourceReference, SourceJob, SourcesResult, SourceMutationResult, SourceView } from '@fbincon/statusline-core/contracts/ui';
1
+ import type { SourceDefinition, SourceContext, SourceReference, SourceJob, SourcesResult, SourceMutationResult, SourceView, AutomaticStatus } from '@fbincon/statusline-core/contracts/ui';
2
2
  import type { ConfigurationService } from '../config/service.js';
3
+ import { refreshGithub } from './providers.js';
3
4
  export declare class SourceService {
4
5
  readonly configuration: ConfigurationService;
5
6
  readonly now: () => number;
7
+ readonly launchWorker?: ((job: SourceJob) => void) | undefined;
8
+ readonly githubRefresh: typeof refreshGithub;
6
9
  readonly root: string;
7
- constructor(configuration: ConfigurationService, now?: () => number);
10
+ constructor(configuration: ConfigurationService, now?: () => number, launchWorker?: ((job: SourceJob) => void) | undefined, githubRefresh?: typeof refreshGithub);
8
11
  read(): SourcesResult;
9
12
  review(id: unknown): {
10
13
  source: SourceDefinition;
@@ -17,10 +20,10 @@ export declare class SourceService {
17
20
  private readValue;
18
21
  private jobPath;
19
22
  job(id: unknown): SourceJob;
20
- private jobs;
23
+ jobs(): SourceJob[];
21
24
  private cancelSource;
22
25
  cancel(id: unknown): SourceJob;
23
- start(id: unknown, contextValue: unknown, owner: unknown): SourceJob;
26
+ start(id: unknown, contextValue: unknown, owner: unknown, trigger?: 'manual' | 'automatic'): SourceJob;
24
27
  private observationPath;
25
28
  private stored;
26
29
  private publish;
@@ -29,7 +32,9 @@ export declare class SourceService {
29
32
  source: SourceDefinition;
30
33
  view: SourceView;
31
34
  jobs: SourceJob[];
35
+ automatic: AutomaticStatus;
32
36
  };
37
+ cancelInactiveAutomatic(): void;
33
38
  work(id: string): Promise<void>;
34
39
  private prune;
35
40
  }
@@ -3,7 +3,7 @@ import { randomUUID } from 'node:crypto';
3
3
  import { join, resolve, isAbsolute } from 'node:path';
4
4
  import { readdirSync, statSync, unlinkSync, mkdirSync, rmdirSync } from 'node:fs';
5
5
  import { SOURCE_FILENAME, MAX_SOURCE_BYTES, emptyRegistry, registry, definition, sourceError, sourceId, sourceContext, matchesScope, sameContext, observationContext, sourceView, emptyObservation, stamp, scalar } from '@fbincon/statusline-core/extensions/model';
6
- import { object, ConfigError } from '@fbincon/statusline-core/config/validation';
6
+ import { object, ConfigError, integer } from '@fbincon/statusline-core/config/validation';
7
7
  import { readJson } from '@fbincon/statusline-core/json-read';
8
8
  import { revision } from '@fbincon/statusline-platform/hash';
9
9
  import { readSourceFile } from '@fbincon/statusline-platform/source-files';
@@ -15,14 +15,19 @@ import { jsonBytes, artifact } from '../config/storage.js';
15
15
  import { commit } from '../recovery/files.js';
16
16
  import { safeTarget } from '../integration/paths.js';
17
17
  import { contextFor, authRevision } from './context.js';
18
+ import { automaticJobActive, automaticStatus, refreshIdentity, readAutomatic, writeAutomatic } from './automatic-state.js';
18
19
  import { readLocal, refreshCommand, refreshGithub } from './providers.js';
19
20
  export class SourceService {
20
21
  configuration;
21
22
  now;
23
+ launchWorker;
24
+ githubRefresh;
22
25
  root;
23
- constructor(configuration, now = Date.now) {
26
+ constructor(configuration, now = Date.now, launchWorker, githubRefresh = refreshGithub) {
24
27
  this.configuration = configuration;
25
28
  this.now = now;
29
+ this.launchWorker = launchWorker;
30
+ this.githubRefresh = githubRefresh;
26
31
  this.root = join(configuration.context.configDir, 'statusline_runtime', 'sources');
27
32
  }
28
33
  read() {
@@ -69,13 +74,14 @@ export class SourceService {
69
74
  if (value.expected_revision !== current.revision)
70
75
  sourceError('conflict');
71
76
  const path = join(this.configuration.context.configDir, SOURCE_FILENAME), raw = readSourceFile(path);
72
- const state = registry({ version: 1, sources: current.sources, bindings: current.bindings });
77
+ const state = registry({ version: 2, sources: current.sources, bindings: current.bindings, automatic: current.automatic });
73
78
  let binding;
74
79
  const id = sourceId(value.id), selected = state.sources.find(s => s.id === id);
75
80
  if (value.action === 'add' || value.action === 'edit') {
76
81
  if (!object(value.source) || (value.action === 'add' ? selected !== undefined : selected === undefined))
77
82
  sourceError('conflict');
78
83
  const source = this.canonical(definition({ ...value.source, id, enabled: false, revision: randomUUID() }));
84
+ state.automatic = state.automatic.filter(p => p.source_id !== id);
79
85
  if (selected) {
80
86
  this.cancelSource(id);
81
87
  state.sources[state.sources.indexOf(selected)] = source;
@@ -86,18 +92,45 @@ export class SourceService {
86
92
  else {
87
93
  if (!selected)
88
94
  sourceError('not_found');
89
- if (value.action === 'enable') {
95
+ if (value.action === 'auto-on' || value.action === 'auto-off') {
96
+ if (selected.kind !== 'github')
97
+ sourceError('invalid');
98
+ const prior = state.automatic.find(p => p.source_id === id);
99
+ if (value.action === 'auto-on') {
100
+ if (!selected.enabled || value.review_revision !== selected.revision)
101
+ sourceError('review');
102
+ const interval = value.interval_seconds === undefined ? prior?.interval_seconds ?? Math.max(60, Math.min(86400, selected.ttl_seconds)) : integer(value.interval_seconds, 60, 86400, 'interval_seconds');
103
+ state.automatic = state.automatic.filter(p => p.source_id !== id);
104
+ state.automatic.push({ source_id: id, enabled: true, review_revision: selected.revision, interval_seconds: interval, auth_revision: authRevision() });
105
+ const scheduling = readAutomatic(this.configuration.context.configDir);
106
+ scheduling.schedules = scheduling.schedules.filter(s => s.source_id !== id);
107
+ const priorJobs = this.jobs().filter(j => j.source_id === id).sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at));
108
+ for (const job of priorJobs)
109
+ if (!scheduling.schedules.some(s => s.key === job.identity))
110
+ scheduling.schedules.push({ key: job.identity, source_id: id, job_id: job.id, processed: job.id, next: this.now(), failures: 0, paused: null, last_attempt: job.started_at, last_success: null });
111
+ scheduling.schedules = scheduling.schedules.slice(-512);
112
+ writeAutomatic(this.configuration.context.configDir, scheduling);
113
+ }
114
+ else {
115
+ if (prior)
116
+ prior.enabled = false;
117
+ this.cancelSource(id, true);
118
+ }
119
+ }
120
+ else if (value.action === 'enable') {
90
121
  if (value.review_revision !== selected.revision)
91
122
  sourceError('review');
92
123
  selected.enabled = true;
93
124
  }
94
125
  else if (value.action === 'disable') {
95
126
  this.cancelSource(id);
127
+ state.automatic = state.automatic.filter(p => p.source_id !== id);
96
128
  selected.enabled = false;
97
129
  }
98
130
  else if (value.action === 'remove') {
99
131
  this.cancelSource(id);
100
132
  state.sources = state.sources.filter(s => s.id !== id);
133
+ state.automatic = state.automatic.filter(p => p.source_id !== id);
101
134
  state.bindings = state.bindings.filter(b => b.source_id !== id);
102
135
  }
103
136
  else if (value.action === 'bind') {
@@ -135,7 +168,7 @@ export class SourceService {
135
168
  jobPath(id) { return join(this.root, 'jobs', sourceId(id) + '.json'); }
136
169
  job(id) {
137
170
  const value = this.readValue(this.jobPath(sourceId(id)));
138
- if (!object(value) || value.version !== 1 || !['running', 'completed', 'failed', 'cancelled'].includes(value.state))
171
+ if (!object(value) || ![1, 2].includes(value.version) || !['running', 'completed', 'failed', 'cancelled'].includes(value.state))
139
172
  sourceError('not_found');
140
173
  sourceId(value.id);
141
174
  sourceId(value.source_id);
@@ -144,7 +177,9 @@ export class SourceService {
144
177
  sourceContext(value.context);
145
178
  if (!stamp(value.started_at) || !stamp(value.deadline_at) || typeof value.reason !== 'string')
146
179
  sourceError('invalid');
147
- const job = value;
180
+ const job = (value.version === 1 ? { ...value, version: 2, trigger: 'manual', identity: revision([value.source_id, value.source_revision, value.context]) } : value);
181
+ if (!['manual', 'automatic'].includes(job.trigger) || !/^[a-f0-9]{64}$/.test(job.identity))
182
+ sourceError('invalid');
148
183
  if (job.state === 'running' && Date.parse(job.deadline_at) + 2000 < this.now())
149
184
  return { ...job, state: 'failed', reason: 'timeout' };
150
185
  return job;
@@ -164,9 +199,9 @@ export class SourceService {
164
199
  return [];
165
200
  }
166
201
  }
167
- cancelSource(id) {
202
+ cancelSource(id, automaticOnly = false) {
168
203
  for (const job of this.jobs())
169
- if (job.source_id === id && job.state === 'running')
204
+ if (job.source_id === id && job.state === 'running' && (!automaticOnly || job.trigger === 'automatic'))
170
205
  this.write(this.jobPath(job.id), { ...job, state: 'cancelled', reason: 'cancelled' });
171
206
  }
172
207
  cancel(id) {
@@ -183,7 +218,8 @@ export class SourceService {
183
218
  return job;
184
219
  });
185
220
  }
186
- start(id, contextValue, owner) {
221
+ start(id, contextValue, owner, trigger = 'manual') {
222
+ let createdNew = false;
187
223
  const actual = sourceContext(contextValue), ownerId = sourceId(owner);
188
224
  const job = this.configuration.io.lock(this.configuration.context.configDir, () => {
189
225
  const source = this.source(id);
@@ -191,14 +227,32 @@ export class SourceService {
191
227
  sourceError('disabled');
192
228
  if (!matchesScope(source.scope, actual))
193
229
  sourceError('scope');
194
- if (this.jobs().some(job => job.source_id === source.id && job.state === 'running'))
195
- sourceError('busy');
196
- const context = observationContext(source, actual);
197
- const created = { version: 1, id: randomUUID(), source_id: source.id, source_revision: source.revision, owner: ownerId, context,
230
+ const context = observationContext(source, actual), identity = refreshIdentity(source, context);
231
+ const existing = this.jobs().find(job => job.source_id === source.id && job.state === 'running' && (source.kind !== 'github' || job.identity === identity));
232
+ if (existing) {
233
+ if (source.kind !== 'github')
234
+ sourceError('busy');
235
+ if (trigger === 'manual' && existing.trigger === 'automatic') {
236
+ existing.trigger = 'manual';
237
+ existing.owner = ownerId;
238
+ this.write(this.jobPath(existing.id), existing);
239
+ }
240
+ return existing;
241
+ }
242
+ const created = { version: 2, trigger, identity, id: randomUUID(), source_id: source.id, source_revision: source.revision, owner: ownerId, context,
198
243
  started_at: new Date(this.now()).toISOString(), deadline_at: new Date(this.now() + (source.kind === 'github' ? 30000 : source.settings.timeout_ms ?? 5000)).toISOString(), state: 'running', reason: 'running' };
244
+ if (trigger === 'automatic' && !automaticJobActive(this.configuration.context.configDir, created, this.now()))
245
+ sourceError('disabled');
199
246
  this.write(this.jobPath(created.id), created);
247
+ createdNew = true;
200
248
  return created;
201
249
  });
250
+ if (!createdNew)
251
+ return job;
252
+ if (this.launchWorker) {
253
+ this.launchWorker(job);
254
+ return job;
255
+ }
202
256
  const launch = this.configuration.context.launch;
203
257
  const worker = spawn(launch.executable, [...launch.args, 'source', '--config-dir', this.configuration.context.configDir, '_worker', job.id], { detached: true, stdio: 'ignore', windowsHide: true });
204
258
  worker.once('error', () => {
@@ -273,7 +327,15 @@ export class SourceService {
273
327
  const identity = data?.current.identity ?? data?.good?.identity;
274
328
  if (source.kind === 'github' && identity && identity.auth_revision !== authRevision())
275
329
  view = { ...view, state: 'mismatch', reason: 'identity', value: null, fields: undefined };
276
- return { source, view, jobs: this.jobs().filter(job => job.source_id === source.id) };
330
+ const jobs = this.jobs().filter(job => job.source_id === source.id);
331
+ return { source, view, jobs, automatic: automaticStatus(this.configuration.context.configDir, source, context, this.now(), jobs) };
332
+ }
333
+ cancelInactiveAutomatic() {
334
+ this.configuration.io.lock(this.configuration.context.configDir, () => {
335
+ for (const job of this.jobs())
336
+ if (job.trigger === 'automatic' && job.state === 'running' && !automaticJobActive(this.configuration.context.configDir, job, this.now()))
337
+ this.write(this.jobPath(job.id), { ...job, state: 'cancelled', reason: 'lease_expired' });
338
+ });
277
339
  }
278
340
  async work(id) {
279
341
  const job = this.job(id);
@@ -291,8 +353,8 @@ export class SourceService {
291
353
  const abort = new AbortController();
292
354
  const watcher = setInterval(() => {
293
355
  try {
294
- const source = this.source(job.source_id);
295
- if (this.job(id).state !== 'running' || source.revision !== job.source_revision || !source.enabled)
356
+ const source = this.source(job.source_id), current = this.job(id);
357
+ if (current.state !== 'running' || source.revision !== job.source_revision || !source.enabled || !automaticJobActive(this.configuration.context.configDir, current, this.now()))
296
358
  abort.abort();
297
359
  }
298
360
  catch {
@@ -302,19 +364,23 @@ export class SourceService {
302
364
  const deadline = setTimeout(() => abort.abort(), Math.max(1, Date.parse(job.deadline_at) - this.now()));
303
365
  try {
304
366
  const source = this.source(job.source_id);
305
- if (!source.enabled || source.revision !== job.source_revision)
367
+ if (!source.enabled || source.revision !== job.source_revision || !automaticJobActive(this.configuration.context.configDir, this.job(id), this.now()))
306
368
  return;
307
369
  let observation;
308
370
  if (!sameContext(observationContext(source, contextFor(job.context.project, job.context.session, job.context.agent)), job.context))
309
371
  observation = emptyObservation(source, job.context, 'identity');
310
372
  else
311
- observation = source.kind === 'json' ? readLocal(source, job.context) : source.kind === 'command' ? await refreshCommand(source, job.context, abort.signal) : await refreshGithub(source, job.context, abort.signal);
373
+ observation = source.kind === 'json' ? readLocal(source, job.context) : source.kind === 'command' ? await refreshCommand(source, job.context, abort.signal) : await this.githubRefresh(source, job.context, abort.signal);
312
374
  if (observation.reason === 'cancelled' && this.now() >= Date.parse(job.deadline_at))
313
375
  observation = emptyObservation(source, job.context, 'timeout');
314
376
  this.configuration.io.lock(this.configuration.context.configDir, () => {
315
377
  const latest = this.source(job.source_id), state = this.job(id);
316
378
  if (state.state !== 'running' || !latest.enabled || latest.revision !== job.source_revision)
317
379
  return;
380
+ if (!automaticJobActive(this.configuration.context.configDir, state, this.now())) {
381
+ this.write(this.jobPath(id), { ...state, state: 'cancelled', reason: 'lease_expired' });
382
+ return;
383
+ }
318
384
  if (!sameContext(observationContext(latest, contextFor(job.context.project, job.context.session, job.context.agent)), job.context))
319
385
  observation = emptyObservation(source, job.context, 'identity');
320
386
  if (observation.reason !== 'identity' && observation.reason !== 'account')