@nettee/beacon 0.3.5 → 0.4.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 (119) hide show
  1. package/README.md +25 -8
  2. package/deploy/io.nettee.beacon.plist.example +0 -2
  3. package/dist/cli-app.d.ts +31 -0
  4. package/dist/cli-app.js +6 -13
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +11 -8
  7. package/dist/daemon/config/channels.d.ts +11 -0
  8. package/dist/daemon/config/event-credentials.d.ts +6 -0
  9. package/dist/daemon/config/global.d.ts +40 -0
  10. package/dist/daemon/config/profile.d.ts +38 -0
  11. package/dist/daemon/config/registry.d.ts +3 -0
  12. package/dist/daemon/config/runtime-environment.d.ts +2 -0
  13. package/dist/daemon/config/secrets.d.ts +5 -0
  14. package/dist/daemon/config/yaml.d.ts +1 -0
  15. package/dist/daemon/dashboard/export.d.ts +11 -0
  16. package/dist/daemon/dashboard/profiles.d.ts +5 -0
  17. package/dist/daemon/dashboard/records.d.ts +25 -0
  18. package/dist/daemon/dashboard/server.d.ts +15 -0
  19. package/dist/daemon/dashboard/session-prompt.d.ts +4 -0
  20. package/dist/daemon/dashboard/static.d.ts +2 -0
  21. package/dist/daemon/doctor.d.ts +1 -0
  22. package/dist/daemon/domain/types.d.ts +137 -0
  23. package/dist/daemon/events/cloudevent.d.ts +25 -0
  24. package/dist/daemon/events/pipeline.d.ts +35 -0
  25. package/dist/daemon/events/server.d.ts +15 -0
  26. package/dist/daemon/events/store.d.ts +58 -0
  27. package/dist/daemon/feishu/doctor.d.ts +2 -0
  28. package/dist/daemon/feishu/final-outcome-card.d.ts +20 -0
  29. package/dist/daemon/feishu/gateway.d.ts +46 -0
  30. package/dist/daemon/feishu/intake.d.ts +37 -0
  31. package/dist/daemon/feishu/mentions.d.ts +37 -0
  32. package/dist/daemon/feishu/message-gateway.d.ts +4 -0
  33. package/dist/daemon/feishu/message-pipeline.d.ts +13 -0
  34. package/dist/daemon/feishu/reply-experiment.d.ts +3 -0
  35. package/dist/daemon/feishu/trigger-input.d.ts +36 -0
  36. package/dist/daemon/index.d.ts +6 -0
  37. package/dist/daemon/index.js +5 -0
  38. package/dist/daemon/manual-trigger.d.ts +2 -0
  39. package/dist/{manual-trigger.js → daemon/manual-trigger.js} +2 -1
  40. package/dist/daemon/message/gateway.d.ts +9 -0
  41. package/dist/daemon/outcome/content.d.ts +68 -0
  42. package/dist/daemon/outcome/doctor.d.ts +2 -0
  43. package/dist/{outcome → daemon/outcome}/doctor.js +2 -3
  44. package/dist/daemon/outcome/instructions.d.ts +3 -0
  45. package/dist/daemon/outcome/server.d.ts +20 -0
  46. package/dist/daemon/outcome/submit.d.ts +5 -0
  47. package/dist/daemon/run/create-pi-orchestrator.d.ts +17 -0
  48. package/dist/{run → daemon/run}/create-pi-orchestrator.js +1 -2
  49. package/dist/daemon/run/orchestrator.d.ts +61 -0
  50. package/dist/daemon/run/profile-runner.d.ts +9 -0
  51. package/dist/daemon/run/queue.d.ts +20 -0
  52. package/dist/daemon/runtime/pi-doctor.d.ts +1 -0
  53. package/dist/daemon/runtime/pi-outcome-extension.d.ts +43 -0
  54. package/dist/daemon/runtime/pi-rpc.d.ts +42 -0
  55. package/dist/{runtime → daemon/runtime}/pi-rpc.js +3 -1
  56. package/dist/daemon/runtime/system-prompt.d.ts +10 -0
  57. package/dist/daemon/runtime-options.d.ts +4 -0
  58. package/dist/daemon/runtime-options.js +1 -0
  59. package/dist/daemon/schedule/cron.d.ts +2 -0
  60. package/dist/daemon/schedule/cursor-store.d.ts +18 -0
  61. package/dist/daemon/schedule/loop.d.ts +17 -0
  62. package/dist/daemon/schedule/reconciler.d.ts +16 -0
  63. package/dist/daemon/schedule-trigger.d.ts +18 -0
  64. package/dist/{schedule-trigger.js → daemon/schedule-trigger.js} +2 -1
  65. package/dist/daemon/service.d.ts +4 -0
  66. package/dist/{service.js → daemon/service.js} +3 -1
  67. package/dist/daemon/state/trigger-store.d.ts +30 -0
  68. package/dist/version.d.ts +1 -0
  69. package/dist/web/assets/index-BP5xd2Iv.js +9 -0
  70. package/dist/web/assets/index-D3C6sw_J.css +2 -0
  71. package/dist/{dashboard/ui → web}/index.html +2 -2
  72. package/package.json +13 -25
  73. package/dist/dashboard/ui/assets/index-BNrf6SEW.css +0 -2
  74. package/dist/dashboard/ui/assets/index-DNeyL6DY.js +0 -9
  75. /package/dist/{config → daemon/config}/channels.js +0 -0
  76. /package/dist/{config → daemon/config}/event-credentials.js +0 -0
  77. /package/dist/{config → daemon/config}/global.js +0 -0
  78. /package/dist/{config → daemon/config}/profile.js +0 -0
  79. /package/dist/{config → daemon/config}/registry.js +0 -0
  80. /package/dist/{config → daemon/config}/runtime-environment.js +0 -0
  81. /package/dist/{config → daemon/config}/secrets.js +0 -0
  82. /package/dist/{config → daemon/config}/yaml.js +0 -0
  83. /package/dist/{dashboard → daemon/dashboard}/export.js +0 -0
  84. /package/dist/{dashboard → daemon/dashboard}/profiles.js +0 -0
  85. /package/dist/{dashboard → daemon/dashboard}/records.js +0 -0
  86. /package/dist/{dashboard → daemon/dashboard}/server.js +0 -0
  87. /package/dist/{dashboard → daemon/dashboard}/session-prompt.js +0 -0
  88. /package/dist/{dashboard → daemon/dashboard}/static.js +0 -0
  89. /package/dist/{doctor.js → daemon/doctor.js} +0 -0
  90. /package/dist/{domain → daemon/domain}/types.js +0 -0
  91. /package/dist/{events → daemon/events}/cloudevent.js +0 -0
  92. /package/dist/{events → daemon/events}/pipeline.js +0 -0
  93. /package/dist/{events → daemon/events}/server.js +0 -0
  94. /package/dist/{events → daemon/events}/store.js +0 -0
  95. /package/dist/{feishu → daemon/feishu}/doctor.js +0 -0
  96. /package/dist/{feishu → daemon/feishu}/final-outcome-card.js +0 -0
  97. /package/dist/{feishu → daemon/feishu}/gateway.js +0 -0
  98. /package/dist/{feishu → daemon/feishu}/intake.js +0 -0
  99. /package/dist/{feishu → daemon/feishu}/mentions.js +0 -0
  100. /package/dist/{feishu → daemon/feishu}/message-gateway.js +0 -0
  101. /package/dist/{feishu → daemon/feishu}/message-pipeline.js +0 -0
  102. /package/dist/{feishu → daemon/feishu}/reply-experiment.js +0 -0
  103. /package/dist/{feishu → daemon/feishu}/trigger-input.js +0 -0
  104. /package/dist/{message → daemon/message}/gateway.js +0 -0
  105. /package/dist/{outcome → daemon/outcome}/content.js +0 -0
  106. /package/dist/{outcome → daemon/outcome}/instructions.js +0 -0
  107. /package/dist/{outcome → daemon/outcome}/server.js +0 -0
  108. /package/dist/{outcome → daemon/outcome}/submit.js +0 -0
  109. /package/dist/{run → daemon/run}/orchestrator.js +0 -0
  110. /package/dist/{run → daemon/run}/profile-runner.js +0 -0
  111. /package/dist/{run → daemon/run}/queue.js +0 -0
  112. /package/dist/{runtime → daemon/runtime}/pi-doctor.js +0 -0
  113. /package/dist/{runtime → daemon/runtime}/pi-outcome-extension.js +0 -0
  114. /package/dist/{runtime → daemon/runtime}/system-prompt.js +0 -0
  115. /package/dist/{schedule → daemon/schedule}/cron.js +0 -0
  116. /package/dist/{schedule → daemon/schedule}/cursor-store.js +0 -0
  117. /package/dist/{schedule → daemon/schedule}/loop.js +0 -0
  118. /package/dist/{schedule → daemon/schedule}/reconciler.js +0 -0
  119. /package/dist/{state → daemon/state}/trigger-store.js +0 -0
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ declare const cursorSchema: z.ZodObject<{
3
+ version: z.ZodLiteral<1>;
4
+ scheduleId: z.ZodString;
5
+ through: z.ZodString;
6
+ }, z.core.$strict>;
7
+ export type ScheduleCursor = z.infer<typeof cursorSchema>;
8
+ export declare class ScheduleCursorStore {
9
+ private readonly root;
10
+ constructor(profileDirectory: string);
11
+ private path;
12
+ private prepare;
13
+ read(scheduleId: string): Promise<ScheduleCursor | undefined>;
14
+ private write;
15
+ initialize(scheduleId: string, through: Date): Promise<ScheduleCursor>;
16
+ advance(scheduleId: string, through: Date): Promise<ScheduleCursor>;
17
+ }
18
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { Profile } from "../config/profile.js";
2
+ type Reconciler = {
3
+ reconcile(now: Date): Promise<void>;
4
+ };
5
+ export declare class ScheduleLoop {
6
+ private readonly profile;
7
+ private readonly reconciler;
8
+ private readonly onFatal;
9
+ private timer;
10
+ private stopped;
11
+ private active;
12
+ constructor(profile: Profile, reconciler: Reconciler, onFatal: (error: Error) => void);
13
+ start(after?: Date): void;
14
+ stop(): void;
15
+ drain(): Promise<void>;
16
+ }
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type Profile } from "../config/profile.js";
2
+ import type { TriggerInput } from "../domain/types.js";
3
+ import type { TriggerStore } from "../state/trigger-store.js";
4
+ import type { ScheduleCursorStore } from "./cursor-store.js";
5
+ export type ScheduleReconcilerOptions = {
6
+ profile: Profile;
7
+ triggers: TriggerStore;
8
+ cursors: ScheduleCursorStore;
9
+ maxOccurrences: number;
10
+ process(triggerKey: string, normalize: () => Promise<TriggerInput>): Promise<void>;
11
+ };
12
+ export declare class ScheduleReconciler {
13
+ private readonly options;
14
+ constructor(options: ScheduleReconcilerOptions);
15
+ reconcile(now: Date): Promise<void>;
16
+ }
@@ -0,0 +1,18 @@
1
+ import { type Profile } from "./config/profile.js";
2
+ import type { TriggerRecord } from "./domain/types.js";
3
+ import type { RuntimeOptions } from "./runtime-options.js";
4
+ import { TriggerStore } from "./state/trigger-store.js";
5
+ export declare function triggerScheduleOnce(options: {
6
+ profile: Profile;
7
+ scheduleId: string;
8
+ store: TriggerStore;
9
+ process(triggerKey: string, normalize: () => Promise<{
10
+ kind: "schedule";
11
+ scheduleId: string;
12
+ scheduledFor: string;
13
+ text: string;
14
+ }>): Promise<void>;
15
+ now?: (() => Date) | undefined;
16
+ id?: (() => string) | undefined;
17
+ }): Promise<TriggerRecord>;
18
+ export declare function runScheduleTrigger(configPath: string, profileId: string, scheduleId: string, options: RuntimeOptions): Promise<void>;
@@ -55,7 +55,7 @@ export async function triggerScheduleOnce(options) {
55
55
  }
56
56
  return record;
57
57
  }
58
- export async function runScheduleTrigger(configPath, profileId, scheduleId) {
58
+ export async function runScheduleTrigger(configPath, profileId, scheduleId, options) {
59
59
  const global = await loadGlobalConfig(configPath);
60
60
  const runtimeEnvironment = await loadRuntimeEnvironment(global.runtimeEnvironmentPath);
61
61
  const channels = await loadChannelRegistry(global.channelsPath);
@@ -69,6 +69,7 @@ export async function runScheduleTrigger(configPath, profileId, scheduleId) {
69
69
  try {
70
70
  const store = new TriggerStore(profile.directory, profile.id);
71
71
  const orchestrator = createPiRunOrchestrator({
72
+ beaconCliPath: options.beaconCliPath,
72
73
  config: global,
73
74
  runtimeEnvironment,
74
75
  profile,
@@ -0,0 +1,4 @@
1
+ import type { RuntimeOptions } from "./runtime-options.js";
2
+ export declare function runBeacon(configPath: string, options: RuntimeOptions & {
3
+ uiDirectory?: string | undefined;
4
+ }): Promise<void>;
@@ -35,7 +35,7 @@ function shutdownController() {
35
35
  },
36
36
  };
37
37
  }
38
- export async function runBeacon(configPath) {
38
+ export async function runBeacon(configPath, options) {
39
39
  const global = await loadGlobalConfig(configPath);
40
40
  const runtimeEnvironment = await loadRuntimeEnvironment(global.runtimeEnvironmentPath);
41
41
  const channels = await loadChannelRegistry(global.channelsPath);
@@ -50,6 +50,7 @@ export async function runBeacon(configPath) {
50
50
  try {
51
51
  if (global.dashboard.enabled) {
52
52
  dashboard = await startDashboard({
53
+ uiDirectory: options.uiDirectory,
53
54
  listen: global.dashboard.listen,
54
55
  port: global.dashboard.port,
55
56
  profilesDirectory: global.profilesDirectory,
@@ -81,6 +82,7 @@ export async function runBeacon(configPath) {
81
82
  const gateway = createFeishuGateway(profileCredentials);
82
83
  const store = new TriggerStore(profile.directory, profile.id);
83
84
  const orchestrator = createPiRunOrchestrator({
85
+ beaconCliPath: options.beaconCliPath,
84
86
  config: global,
85
87
  runtimeEnvironment,
86
88
  profile,
@@ -0,0 +1,30 @@
1
+ import { type DeliveryTarget, type TriggerInput, type TriggerRecord } from "../domain/types.js";
2
+ export type TriggerClaim = {
3
+ input?: TriggerInput | undefined;
4
+ sourceKey: string[];
5
+ target: DeliveryTarget;
6
+ notifyTarget?: DeliveryTarget | undefined;
7
+ ingress?: Record<string, unknown> | undefined;
8
+ acceptedAt?: Date | undefined;
9
+ };
10
+ export declare class TriggerStore {
11
+ private readonly profileId;
12
+ readonly root: string;
13
+ constructor(profileDirectory: string, profileId: string);
14
+ recordPath(triggerKey: string): string;
15
+ private prepare;
16
+ private read;
17
+ private syncDirectory;
18
+ private write;
19
+ claim(request: TriggerClaim): Promise<{
20
+ created: boolean;
21
+ record: TriggerRecord;
22
+ }>;
23
+ update(triggerKey: string, transform: (record: TriggerRecord) => TriggerRecord): Promise<TriggerRecord>;
24
+ list(): Promise<TriggerRecord[]>;
25
+ /**
26
+ * Locate the Trigger whose reply or notify Delivery produced this Feishu
27
+ * outbound `message_id`. Newest accepted Trigger wins on collision.
28
+ */
29
+ findByDeliveredMessageId(messageId: string): Promise<TriggerRecord | undefined>;
30
+ }
@@ -0,0 +1 @@
1
+ export declare const packageVersion: string;