@stigmer/react 3.5.2 → 3.6.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 (193) hide show
  1. package/agent/AgentPicker.d.ts +10 -1
  2. package/agent/AgentPicker.d.ts.map +1 -1
  3. package/agent/AgentPicker.js +2 -2
  4. package/agent/AgentPicker.js.map +1 -1
  5. package/channel/AgentChannelsPanel.d.ts.map +1 -1
  6. package/channel/AgentChannelsPanel.js +22 -5
  7. package/channel/AgentChannelsPanel.js.map +1 -1
  8. package/channel/ChannelTemplatesDialog.d.ts +53 -0
  9. package/channel/ChannelTemplatesDialog.d.ts.map +1 -0
  10. package/channel/ChannelTemplatesDialog.js +150 -0
  11. package/channel/ChannelTemplatesDialog.js.map +1 -0
  12. package/channel/index.d.ts +8 -0
  13. package/channel/index.d.ts.map +1 -1
  14. package/channel/index.js +4 -0
  15. package/channel/index.js.map +1 -1
  16. package/channel/providers.d.ts +12 -0
  17. package/channel/providers.d.ts.map +1 -1
  18. package/channel/providers.js +14 -2
  19. package/channel/providers.js.map +1 -1
  20. package/channel/templatePresentation.d.ts +37 -0
  21. package/channel/templatePresentation.d.ts.map +1 -0
  22. package/channel/templatePresentation.js +69 -0
  23. package/channel/templatePresentation.js.map +1 -0
  24. package/channel/useChannelTemplateList.d.ts +64 -0
  25. package/channel/useChannelTemplateList.d.ts.map +1 -0
  26. package/channel/useChannelTemplateList.js +69 -0
  27. package/channel/useChannelTemplateList.js.map +1 -0
  28. package/channel/useChannelTemplateReadiness.d.ts +53 -0
  29. package/channel/useChannelTemplateReadiness.d.ts.map +1 -0
  30. package/channel/useChannelTemplateReadiness.js +42 -0
  31. package/channel/useChannelTemplateReadiness.js.map +1 -0
  32. package/dashboard/useDashboardFailedRuns.d.ts.map +1 -1
  33. package/dashboard/useDashboardFailedRuns.js +2 -0
  34. package/dashboard/useDashboardFailedRuns.js.map +1 -1
  35. package/index.d.ts +4 -2
  36. package/index.d.ts.map +1 -1
  37. package/index.js +9 -1
  38. package/index.js.map +1 -1
  39. package/library/useExportResource.d.ts +4 -3
  40. package/library/useExportResource.d.ts.map +1 -1
  41. package/library/useExportResource.js +1 -1
  42. package/library/useExportResource.js.map +1 -1
  43. package/organization/OrgProvider.d.ts +11 -4
  44. package/organization/OrgProvider.d.ts.map +1 -1
  45. package/organization/OrgProvider.js +28 -4
  46. package/organization/OrgProvider.js.map +1 -1
  47. package/package.json +4 -4
  48. package/resource-detail/useDeleteResource.d.ts +1 -1
  49. package/resource-detail/useDeleteResource.d.ts.map +1 -1
  50. package/resource-detail/useDeleteResource.js +5 -0
  51. package/resource-detail/useDeleteResource.js.map +1 -1
  52. package/resource-workbench/components/ResourceWorkbench.d.ts +10 -1
  53. package/resource-workbench/components/ResourceWorkbench.d.ts.map +1 -1
  54. package/resource-workbench/components/ResourceWorkbench.js +6 -2
  55. package/resource-workbench/components/ResourceWorkbench.js.map +1 -1
  56. package/resource-workbench/hooks/useResourceCollection.d.ts +8 -0
  57. package/resource-workbench/hooks/useResourceCollection.d.ts.map +1 -1
  58. package/resource-workbench/hooks/useResourceCollection.js +2 -2
  59. package/resource-workbench/hooks/useResourceCollection.js.map +1 -1
  60. package/schedule/CadenceField.d.ts +31 -0
  61. package/schedule/CadenceField.d.ts.map +1 -0
  62. package/schedule/CadenceField.js +116 -0
  63. package/schedule/CadenceField.js.map +1 -0
  64. package/schedule/ScheduleDetailView.d.ts +58 -0
  65. package/schedule/ScheduleDetailView.d.ts.map +1 -0
  66. package/schedule/ScheduleDetailView.js +236 -0
  67. package/schedule/ScheduleDetailView.js.map +1 -0
  68. package/schedule/ScheduleForm.d.ts +43 -0
  69. package/schedule/ScheduleForm.d.ts.map +1 -0
  70. package/schedule/ScheduleForm.js +129 -0
  71. package/schedule/ScheduleForm.js.map +1 -0
  72. package/schedule/ScheduleRowActions.d.ts +20 -0
  73. package/schedule/ScheduleRowActions.d.ts.map +1 -0
  74. package/schedule/ScheduleRowActions.js +54 -0
  75. package/schedule/ScheduleRowActions.js.map +1 -0
  76. package/schedule/TimeZoneField.d.ts +32 -0
  77. package/schedule/TimeZoneField.d.ts.map +1 -0
  78. package/schedule/TimeZoneField.js +104 -0
  79. package/schedule/TimeZoneField.js.map +1 -0
  80. package/schedule/cadence.d.ts +95 -0
  81. package/schedule/cadence.d.ts.map +1 -0
  82. package/schedule/cadence.js +242 -0
  83. package/schedule/cadence.js.map +1 -0
  84. package/schedule/index.d.ts +31 -0
  85. package/schedule/index.d.ts.map +1 -0
  86. package/schedule/index.js +16 -0
  87. package/schedule/index.js.map +1 -0
  88. package/schedule/scheduleColumns.d.ts +26 -0
  89. package/schedule/scheduleColumns.d.ts.map +1 -0
  90. package/schedule/scheduleColumns.js +77 -0
  91. package/schedule/scheduleColumns.js.map +1 -0
  92. package/schedule/scheduleListFn.d.ts +50 -0
  93. package/schedule/scheduleListFn.d.ts.map +1 -0
  94. package/schedule/scheduleListFn.js +65 -0
  95. package/schedule/scheduleListFn.js.map +1 -0
  96. package/schedule/scheduleState.d.ts +43 -0
  97. package/schedule/scheduleState.d.ts.map +1 -0
  98. package/schedule/scheduleState.js +67 -0
  99. package/schedule/scheduleState.js.map +1 -0
  100. package/schedule/useCreateSchedule.d.ts +57 -0
  101. package/schedule/useCreateSchedule.d.ts.map +1 -0
  102. package/schedule/useCreateSchedule.js +61 -0
  103. package/schedule/useCreateSchedule.js.map +1 -0
  104. package/schedule/useResumeSchedule.d.ts +30 -0
  105. package/schedule/useResumeSchedule.d.ts.map +1 -0
  106. package/schedule/useResumeSchedule.js +45 -0
  107. package/schedule/useResumeSchedule.js.map +1 -0
  108. package/schedule/useSchedule.d.ts +39 -0
  109. package/schedule/useSchedule.d.ts.map +1 -0
  110. package/schedule/useSchedule.js +44 -0
  111. package/schedule/useSchedule.js.map +1 -0
  112. package/schedule/useScheduleCount.d.ts +38 -0
  113. package/schedule/useScheduleCount.d.ts.map +1 -0
  114. package/schedule/useScheduleCount.js +30 -0
  115. package/schedule/useScheduleCount.js.map +1 -0
  116. package/schedule/useScheduleList.d.ts +48 -0
  117. package/schedule/useScheduleList.d.ts.map +1 -0
  118. package/schedule/useScheduleList.js +43 -0
  119. package/schedule/useScheduleList.js.map +1 -0
  120. package/schedule/useSetScheduleEnabled.d.ts +31 -0
  121. package/schedule/useSetScheduleEnabled.d.ts.map +1 -0
  122. package/schedule/useSetScheduleEnabled.js +53 -0
  123. package/schedule/useSetScheduleEnabled.js.map +1 -0
  124. package/schedule/useTriggerSchedule.d.ts +28 -0
  125. package/schedule/useTriggerSchedule.d.ts.map +1 -0
  126. package/schedule/useTriggerSchedule.js +43 -0
  127. package/schedule/useTriggerSchedule.js.map +1 -0
  128. package/search/useResourceCount.d.ts +2 -1
  129. package/search/useResourceCount.d.ts.map +1 -1
  130. package/search/useResourceCount.js +6 -1
  131. package/search/useResourceCount.js.map +1 -1
  132. package/src/agent/AgentPicker.tsx +13 -1
  133. package/src/channel/AgentChannelsPanel.tsx +43 -1
  134. package/src/channel/ChannelTemplatesDialog.tsx +433 -0
  135. package/src/channel/__tests__/AgentChannelsPanel.test.tsx +73 -0
  136. package/src/channel/__tests__/ChannelTemplatesDialog.test.tsx +292 -0
  137. package/src/channel/__tests__/providers.test.ts +9 -0
  138. package/src/channel/__tests__/templatePresentation.test.ts +96 -0
  139. package/src/channel/__tests__/useChannelTemplateList.test.tsx +216 -0
  140. package/src/channel/__tests__/useChannelTemplateReadiness.test.tsx +124 -0
  141. package/src/channel/index.ts +15 -0
  142. package/src/channel/providers.ts +26 -2
  143. package/src/channel/templatePresentation.ts +82 -0
  144. package/src/channel/useChannelTemplateList.ts +123 -0
  145. package/src/channel/useChannelTemplateReadiness.ts +69 -0
  146. package/src/dashboard/__tests__/useDashboardFailedRuns.test.tsx +106 -0
  147. package/src/dashboard/useDashboardFailedRuns.ts +2 -0
  148. package/src/execution/__tests__/PlanArtifactCard.test.tsx +23 -2
  149. package/src/index.ts +65 -0
  150. package/src/library/useExportResource.ts +4 -3
  151. package/src/organization/OrgProvider.tsx +29 -4
  152. package/src/organization/__tests__/OrgProvider.orgSwitch.test.tsx +89 -0
  153. package/src/resource-detail/useDeleteResource.ts +11 -1
  154. package/src/resource-workbench/__tests__/ResourceWorkbench.test.tsx +112 -0
  155. package/src/resource-workbench/components/ResourceWorkbench.tsx +32 -15
  156. package/src/resource-workbench/hooks/useResourceCollection.ts +11 -1
  157. package/src/schedule/CadenceField.tsx +365 -0
  158. package/src/schedule/ScheduleDetailView.tsx +583 -0
  159. package/src/schedule/ScheduleForm.tsx +405 -0
  160. package/src/schedule/ScheduleRowActions.tsx +124 -0
  161. package/src/schedule/TimeZoneField.tsx +199 -0
  162. package/src/schedule/__tests__/ScheduleDetailView.test.tsx +260 -0
  163. package/src/schedule/__tests__/cadence.test.ts +278 -0
  164. package/src/schedule/__tests__/scheduleColumnsRowActions.test.tsx +176 -0
  165. package/src/schedule/__tests__/scheduleCreation.test.tsx +340 -0
  166. package/src/schedule/__tests__/scheduleHooks.test.tsx +312 -0
  167. package/src/schedule/__tests__/scheduleListFn.test.ts +128 -0
  168. package/src/schedule/__tests__/scheduleState.test.ts +133 -0
  169. package/src/schedule/cadence.ts +298 -0
  170. package/src/schedule/index.ts +57 -0
  171. package/src/schedule/scheduleColumns.tsx +118 -0
  172. package/src/schedule/scheduleListFn.ts +108 -0
  173. package/src/schedule/scheduleState.ts +96 -0
  174. package/src/schedule/useCreateSchedule.ts +88 -0
  175. package/src/schedule/useResumeSchedule.ts +67 -0
  176. package/src/schedule/useSchedule.ts +67 -0
  177. package/src/schedule/useScheduleCount.ts +57 -0
  178. package/src/schedule/useScheduleList.ts +83 -0
  179. package/src/schedule/useSetScheduleEnabled.ts +84 -0
  180. package/src/schedule/useTriggerSchedule.ts +65 -0
  181. package/src/search/__tests__/useResourceCount.test.tsx +89 -0
  182. package/src/search/useResourceCount.ts +8 -2
  183. package/src/workflow/WorkflowDashboard.tsx +1 -0
  184. package/src/workflow/useWorkflowExecutionList.ts +13 -2
  185. package/styles.css +1 -1
  186. package/workflow/CanvasTransitionEdge.d.ts +1 -1
  187. package/workflow/WorkflowDashboard.d.ts.map +1 -1
  188. package/workflow/WorkflowDashboard.js +1 -0
  189. package/workflow/WorkflowDashboard.js.map +1 -1
  190. package/workflow/useWorkflowExecutionList.d.ts +10 -0
  191. package/workflow/useWorkflowExecutionList.d.ts.map +1 -1
  192. package/workflow/useWorkflowExecutionList.js +3 -2
  193. package/workflow/useWorkflowExecutionList.js.map +1 -1
@@ -0,0 +1,67 @@
1
+ // Pure schedule-state derivation — the disabled-vs-paused vocabulary,
2
+ // computed on read.
3
+ //
4
+ // A schedule that is not firing is stopped by one of two levers with two
5
+ // different writers and two different remedies (the backend pins this
6
+ // vocabulary in its controller docs):
7
+ //
8
+ // - "disabled" — the OWNER's switch (`spec.enabled = false`), cleared
9
+ // by re-applying the manifest or the console's Enable action.
10
+ // - "paused" — the PLATFORM's failure-streak latch
11
+ // (`status.paused_reason` non-empty), cleared only by Resume.
12
+ //
13
+ // The console must never collapse these into one badge (stigmer/stigmer#352):
14
+ // each state names its own remedy. When both levers are set, "disabled"
15
+ // wins for display — the owner's intent dominates — but callers should
16
+ // keep the paused reason visible alongside (the banner does).
17
+ /**
18
+ * Derive a schedule's display state from its spec and status.
19
+ *
20
+ * A missing spec derives as "disabled" — the same fail-closed reading the
21
+ * server applies to a manifest that omits `enabled`.
22
+ */
23
+ export function deriveScheduleState(spec, status) {
24
+ const isPaused = (status?.pausedReason ?? "") !== "";
25
+ if (!spec?.enabled) {
26
+ return { state: "disabled", phase: "disabled", label: "Disabled", isPaused };
27
+ }
28
+ if (isPaused) {
29
+ return { state: "paused", phase: "degraded", label: "Paused", isPaused };
30
+ }
31
+ return { state: "active", phase: "ready", label: "Active", isPaused };
32
+ }
33
+ /**
34
+ * Compact future-instant formatter for a schedule's next fire time:
35
+ * `now`, `in 5m`, `in 3h`, `in 6d`, then a short date once "days from
36
+ * now" stops being how people think about it.
37
+ *
38
+ * The schedule-local sibling of the activity module's past-only
39
+ * `formatRelativeTime` (same compact units, same date tail) — kept
40
+ * separate because that util's contract is deliberately past-only.
41
+ * A fire time slightly in the past (a tick mid-flight, clock skew)
42
+ * renders as `now` rather than a nonsense negative countdown.
43
+ *
44
+ * `now` is injected, never read from the live clock — required for
45
+ * deterministic tests and Scenar fixtures.
46
+ */
47
+ export function formatNextFire(date, now) {
48
+ const deltaMs = date.getTime() - now.getTime();
49
+ if (deltaMs < 60_000)
50
+ return "now";
51
+ const minutes = Math.floor(deltaMs / 60_000);
52
+ if (minutes < 60)
53
+ return `in ${minutes}m`;
54
+ const hours = Math.floor(minutes / 60);
55
+ if (hours < 24)
56
+ return `in ${hours}h`;
57
+ const days = Math.floor(hours / 24);
58
+ if (days < 7)
59
+ return `in ${days}d`;
60
+ const sameYear = date.getFullYear() === now.getFullYear();
61
+ return date.toLocaleDateString(undefined, {
62
+ month: "short",
63
+ day: "numeric",
64
+ ...(sameYear ? {} : { year: "numeric" }),
65
+ });
66
+ }
67
+ //# sourceMappingURL=scheduleState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleState.js","sourceRoot":"","sources":["../../src/schedule/scheduleState.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,oBAAoB;AACpB,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,sCAAsC;AACtC,EAAE;AACF,wEAAwE;AACxE,kEAAkE;AAClE,qDAAqD;AACrD,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,uEAAuE;AACvE,8DAA8D;AAyB9D;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA8B,EAC9B,MAAkC;IAElC,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IAErD,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;IAC/E,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC3E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,IAAU,EAAE,GAAS;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAE/C,IAAI,OAAO,GAAG,MAAM;QAAE,OAAO,KAAK,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IAC7C,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,MAAM,OAAO,GAAG,CAAC;IAE1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,MAAM,KAAK,GAAG,CAAC;IAEtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACpC,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,MAAM,IAAI,GAAG,CAAC;IAEnC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE;QACxC,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACzC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,57 @@
1
+ import type { ScheduleInput } from "@stigmer/sdk";
2
+ import type { Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
3
+ /** Return value of {@link useCreateSchedule}. */
4
+ export interface UseCreateScheduleReturn {
5
+ /**
6
+ * Submit a {@link ScheduleInput} to create (or upsert) a schedule.
7
+ *
8
+ * Uses `stigmer.schedule.apply()` — the idempotent upsert operation.
9
+ * Resolves with the server-created `Schedule` proto including
10
+ * populated metadata (id, slug, audit timestamps) and the
11
+ * platform-computed `status.next_fire_at`.
12
+ */
13
+ readonly create: (input: ScheduleInput) => Promise<Schedule>;
14
+ /** `true` while the apply request is in flight. */
15
+ readonly isCreating: boolean;
16
+ /** Error from the last failed create, or `null` when healthy. */
17
+ readonly error: Error | null;
18
+ /** Reset `error` to `null`. */
19
+ readonly clearError: () => void;
20
+ }
21
+ /**
22
+ * Behavior hook that wraps `schedule.apply()` with loading and error
23
+ * state.
24
+ *
25
+ * Creates a schedule from a {@link ScheduleInput}. Uses `apply()`
26
+ * (upsert) rather than `create()` so re-submissions are idempotent —
27
+ * matching the CLI's `stigmer apply` semantics and the established SDK
28
+ * mutation hook pattern (`isCreating` flag, `error` state, `clearError`
29
+ * reset, result returned from the promise, not stored in hook state).
30
+ *
31
+ * NOTE: this hook is for CREATION. Editing an existing schedule must
32
+ * NOT go through `ScheduleInput` — the input type cannot express every
33
+ * metadata field (tags, description), and the server replaces spec and
34
+ * mutable metadata wholesale on update, so a down-converting edit would
35
+ * silently wipe them. Edit flows use the full-proto path instead (see
36
+ * `useSetScheduleEnabled` for the pattern).
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * const { create, isCreating, error, clearError } = useCreateSchedule();
41
+ *
42
+ * const schedule = await create({
43
+ * name: "daily-fee-reminders",
44
+ * org: "acme",
45
+ * cron: "0 9 * * *",
46
+ * timeZone: "Asia/Kolkata",
47
+ * enabled: false,
48
+ * agent: {
49
+ * agentRef: { org: "acme", slug: "billing-assistant" },
50
+ * message: "Send today's fee reminders.",
51
+ * },
52
+ * });
53
+ * // schedule.metadata?.slug → "daily-fee-reminders"
54
+ * ```
55
+ */
56
+ export declare function useCreateSchedule(): UseCreateScheduleReturn;
57
+ //# sourceMappingURL=useCreateSchedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCreateSchedule.d.ts","sourceRoot":"","sources":["../../src/schedule/useCreateSchedule.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAItF,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CAyB3D"}
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { useCallback, useState } from "react";
3
+ import { useStigmer } from "../hooks.js";
4
+ import { toError } from "../internal/toError.js";
5
+ /**
6
+ * Behavior hook that wraps `schedule.apply()` with loading and error
7
+ * state.
8
+ *
9
+ * Creates a schedule from a {@link ScheduleInput}. Uses `apply()`
10
+ * (upsert) rather than `create()` so re-submissions are idempotent —
11
+ * matching the CLI's `stigmer apply` semantics and the established SDK
12
+ * mutation hook pattern (`isCreating` flag, `error` state, `clearError`
13
+ * reset, result returned from the promise, not stored in hook state).
14
+ *
15
+ * NOTE: this hook is for CREATION. Editing an existing schedule must
16
+ * NOT go through `ScheduleInput` — the input type cannot express every
17
+ * metadata field (tags, description), and the server replaces spec and
18
+ * mutable metadata wholesale on update, so a down-converting edit would
19
+ * silently wipe them. Edit flows use the full-proto path instead (see
20
+ * `useSetScheduleEnabled` for the pattern).
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * const { create, isCreating, error, clearError } = useCreateSchedule();
25
+ *
26
+ * const schedule = await create({
27
+ * name: "daily-fee-reminders",
28
+ * org: "acme",
29
+ * cron: "0 9 * * *",
30
+ * timeZone: "Asia/Kolkata",
31
+ * enabled: false,
32
+ * agent: {
33
+ * agentRef: { org: "acme", slug: "billing-assistant" },
34
+ * message: "Send today's fee reminders.",
35
+ * },
36
+ * });
37
+ * // schedule.metadata?.slug → "daily-fee-reminders"
38
+ * ```
39
+ */
40
+ export function useCreateSchedule() {
41
+ const stigmer = useStigmer();
42
+ const [isCreating, setIsCreating] = useState(false);
43
+ const [error, setError] = useState(null);
44
+ const clearError = useCallback(() => setError(null), []);
45
+ const create = useCallback(async (input) => {
46
+ setIsCreating(true);
47
+ setError(null);
48
+ try {
49
+ return await stigmer.schedule.apply(input);
50
+ }
51
+ catch (err) {
52
+ setError(toError(err));
53
+ throw err;
54
+ }
55
+ finally {
56
+ setIsCreating(false);
57
+ }
58
+ }, [stigmer]);
59
+ return { create, isCreating, error, clearError };
60
+ }
61
+ //# sourceMappingURL=useCreateSchedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCreateSchedule.js","sourceRoot":"","sources":["../../src/schedule/useCreateSchedule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAqBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,WAAW,CACxB,KAAK,EAAE,KAAoB,EAAqB,EAAE;QAChD,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEf,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EACD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
2
+ /** Return value of {@link useResumeSchedule}. */
3
+ export interface UseResumeScheduleReturn {
4
+ /**
5
+ * Clear the platform's failure-streak pause and let the schedule fire
6
+ * again. Resolves with the post-resume schedule; the caller refetches
7
+ * or replaces its local copy from it.
8
+ */
9
+ readonly resumeSchedule: (scheduleId: string) => Promise<Schedule>;
10
+ /** `true` while the resume request is in flight. */
11
+ readonly isResuming: boolean;
12
+ /** Error from the last failed resume, or `null` when healthy. */
13
+ readonly error: Error | null;
14
+ }
15
+ /**
16
+ * Behavior hook that resumes a platform-paused schedule.
17
+ *
18
+ * Resume is the ONE path that clears `status.paused_reason` (and the
19
+ * failure streak with it) — re-applying the manifest deliberately does
20
+ * not, so a routine GitOps apply can never silently un-pause a failing
21
+ * schedule. Resuming a schedule that is not paused is a server-side
22
+ * no-op; resuming a disabled schedule clears the pause but the schedule
23
+ * stays disabled (the owner's lever is separate — see
24
+ * {@link useSetScheduleEnabled}).
25
+ *
26
+ * Error toasts relay the server's message verbatim: the copy is
27
+ * identical across editions and states the remedy.
28
+ */
29
+ export declare function useResumeSchedule(): UseResumeScheduleReturn;
30
+ //# sourceMappingURL=useResumeSchedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResumeSchedule.d.ts","sourceRoot":"","sources":["../../src/schedule/useResumeSchedule.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAMtF,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnE,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CA6B3D"}
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { useCallback, useMemo, useState } from "react";
3
+ import { getUserMessage } from "@stigmer/sdk";
4
+ import { useStigmer } from "../hooks.js";
5
+ import { toast } from "../feedback/toast.js";
6
+ import { toError } from "../internal/toError.js";
7
+ /**
8
+ * Behavior hook that resumes a platform-paused schedule.
9
+ *
10
+ * Resume is the ONE path that clears `status.paused_reason` (and the
11
+ * failure streak with it) — re-applying the manifest deliberately does
12
+ * not, so a routine GitOps apply can never silently un-pause a failing
13
+ * schedule. Resuming a schedule that is not paused is a server-side
14
+ * no-op; resuming a disabled schedule clears the pause but the schedule
15
+ * stays disabled (the owner's lever is separate — see
16
+ * {@link useSetScheduleEnabled}).
17
+ *
18
+ * Error toasts relay the server's message verbatim: the copy is
19
+ * identical across editions and states the remedy.
20
+ */
21
+ export function useResumeSchedule() {
22
+ const stigmer = useStigmer();
23
+ const [isResuming, setIsResuming] = useState(false);
24
+ const [error, setError] = useState(null);
25
+ const resumeSchedule = useCallback(async (scheduleId) => {
26
+ setIsResuming(true);
27
+ setError(null);
28
+ try {
29
+ const resumed = await stigmer.schedule.resume(scheduleId);
30
+ toast.success("Schedule resumed");
31
+ return resumed;
32
+ }
33
+ catch (err) {
34
+ const wrapped = toError(err);
35
+ setError(wrapped);
36
+ toast.error(getUserMessage(err));
37
+ throw wrapped;
38
+ }
39
+ finally {
40
+ setIsResuming(false);
41
+ }
42
+ }, [stigmer]);
43
+ return useMemo(() => ({ resumeSchedule, isResuming, error }), [resumeSchedule, isResuming, error]);
44
+ }
45
+ //# sourceMappingURL=useResumeSchedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResumeSchedule.js","sourceRoot":"","sources":["../../src/schedule/useResumeSchedule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAgBjD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,MAAM,cAAc,GAAG,WAAW,CAChC,KAAK,EAAE,UAAkB,EAAqB,EAAE;QAC9C,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC1D,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;YAClC,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC;YAClB,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,MAAM,OAAO,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EACD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAC7C,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,CAAC,CACpC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
2
+ /** Return value of {@link useSchedule}. */
3
+ export interface UseScheduleReturn {
4
+ /** The resolved schedule, or `null` while loading, on error, or when not found. */
5
+ readonly schedule: Schedule | null;
6
+ /** `true` while the initial fetch is in flight. */
7
+ readonly isLoading: boolean;
8
+ /** `true` while a background refetch is in flight. */
9
+ readonly isRefetching: boolean;
10
+ /** Error from the last failed request, or `null` when healthy. */
11
+ readonly error: Error | null;
12
+ /** Discard cached data and re-fetch the schedule from the server. */
13
+ readonly refetch: () => void;
14
+ }
15
+ /**
16
+ * Data hook that fetches a single Schedule by organization and slug.
17
+ *
18
+ * Wraps `stigmer.schedule.getByReference()` with loading, error, and
19
+ * not-found state management. The loaded resource carries the spec
20
+ * (cron, time zone, enabled, target) and the platform-written status
21
+ * (`next_fire_at`, `last_fire_at`, `last_execution_id`,
22
+ * `consecutive_failures`, `paused_reason`) — everything the detail view
23
+ * renders, including the disabled-vs-paused distinction (see
24
+ * {@link deriveScheduleState}).
25
+ *
26
+ * Pass `null` for either `org` or `slug` to skip fetching (stable
27
+ * no-op).
28
+ *
29
+ * **Not-found handling:** a NOT_FOUND response sets `schedule` to
30
+ * `null` without raising an error; `schedule === null && !isLoading
31
+ * && !error` means the resource does not exist.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * const { schedule, isLoading, error, refetch } = useSchedule("isc", "daily-fee-reminders");
36
+ * ```
37
+ */
38
+ export declare function useSchedule(org: string | null, slug: string | null): UseScheduleReturn;
39
+ //# sourceMappingURL=useSchedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchedule.d.ts","sourceRoot":"","sources":["../../src/schedule/useSchedule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAKtF,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,IAAI,EAAE,MAAM,GAAG,IAAI,GAClB,iBAAiB,CAmBnB"}
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { isNotFound } from "@stigmer/sdk";
3
+ import { useStigmer } from "../hooks.js";
4
+ import { useFetch } from "../internal/useFetch.js";
5
+ /**
6
+ * Data hook that fetches a single Schedule by organization and slug.
7
+ *
8
+ * Wraps `stigmer.schedule.getByReference()` with loading, error, and
9
+ * not-found state management. The loaded resource carries the spec
10
+ * (cron, time zone, enabled, target) and the platform-written status
11
+ * (`next_fire_at`, `last_fire_at`, `last_execution_id`,
12
+ * `consecutive_failures`, `paused_reason`) — everything the detail view
13
+ * renders, including the disabled-vs-paused distinction (see
14
+ * {@link deriveScheduleState}).
15
+ *
16
+ * Pass `null` for either `org` or `slug` to skip fetching (stable
17
+ * no-op).
18
+ *
19
+ * **Not-found handling:** a NOT_FOUND response sets `schedule` to
20
+ * `null` without raising an error; `schedule === null && !isLoading
21
+ * && !error` means the resource does not exist.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * const { schedule, isLoading, error, refetch } = useSchedule("isc", "daily-fee-reminders");
26
+ * ```
27
+ */
28
+ export function useSchedule(org, slug) {
29
+ const stigmer = useStigmer();
30
+ const { data: schedule, isLoading, isRefetching, error, refetch } = useFetch(org && slug
31
+ ? async () => {
32
+ try {
33
+ return await stigmer.schedule.getByReference({ org, slug });
34
+ }
35
+ catch (err) {
36
+ if (isNotFound(err))
37
+ return null;
38
+ throw err;
39
+ }
40
+ }
41
+ : null, [org, slug, stigmer], null);
42
+ return { schedule, isLoading, isRefetching, error, refetch };
43
+ }
44
+ //# sourceMappingURL=useSchedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchedule.js","sourceRoot":"","sources":["../../src/schedule/useSchedule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAgBnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,WAAW,CACzB,GAAkB,EAClB,IAAmB;IAEnB,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,QAAQ,CAC1E,GAAG,IAAI,IAAI;QACT,CAAC,CAAC,KAAK,IAAI,EAAE;YACT,IAAI,CAAC;gBACH,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,UAAU,CAAC,GAAG,CAAC;oBAAE,OAAO,IAAI,CAAC;gBACjC,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QACH,CAAC,CAAC,IAAI,EACR,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EACpB,IAAI,CACL,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** Options for {@link useScheduleCount}. */
2
+ export interface UseScheduleCountOptions {
3
+ /** Opaque token that forces a recount when its value changes. */
4
+ readonly refetchToken?: unknown;
5
+ }
6
+ /** Return value of {@link useScheduleCount}. */
7
+ export interface UseScheduleCountReturn {
8
+ /**
9
+ * Total number of schedules in the organization. `undefined` until
10
+ * the first successful fetch completes.
11
+ */
12
+ readonly count: number | undefined;
13
+ /** `true` while the count fetch is in flight. */
14
+ readonly isLoading: boolean;
15
+ /** Error from the last failed request, or `null` when healthy. */
16
+ readonly error: Error | null;
17
+ /** Discard cached data and re-fetch the count from the server. */
18
+ readonly refetch: () => void;
19
+ }
20
+ /**
21
+ * Data hook that fetches the total count of an organization's schedules.
22
+ *
23
+ * Issues a minimal direct `listSchedules` call to retrieve only the
24
+ * total count. Useful for the Library landing card and dashboard
25
+ * widgets. There is no scope option: schedules are org-only.
26
+ *
27
+ * For the full paginated schedule list, use {@link useScheduleList}
28
+ * instead.
29
+ *
30
+ * Pass `null` as `org` to skip fetching (stable no-op).
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * const { count, isLoading } = useScheduleCount("isc");
35
+ * ```
36
+ */
37
+ export declare function useScheduleCount(org: string | null, options?: UseScheduleCountOptions): UseScheduleCountReturn;
38
+ //# sourceMappingURL=useScheduleCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScheduleCount.d.ts","sourceRoot":"","sources":["../../src/schedule/useScheduleCount.ts"],"names":[],"mappings":"AAOA,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,gDAAgD;AAChD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE,uBAAuB,GAChC,sBAAsB,CAQxB"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { useMemo } from "react";
3
+ import { useStigmer } from "../hooks.js";
4
+ import { useResourceCount } from "../search/index.js";
5
+ import { createScheduleListFn } from "./scheduleListFn.js";
6
+ /**
7
+ * Data hook that fetches the total count of an organization's schedules.
8
+ *
9
+ * Issues a minimal direct `listSchedules` call to retrieve only the
10
+ * total count. Useful for the Library landing card and dashboard
11
+ * widgets. There is no scope option: schedules are org-only.
12
+ *
13
+ * For the full paginated schedule list, use {@link useScheduleList}
14
+ * instead.
15
+ *
16
+ * Pass `null` as `org` to skip fetching (stable no-op).
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const { count, isLoading } = useScheduleCount("isc");
21
+ * ```
22
+ */
23
+ export function useScheduleCount(org, options) {
24
+ const stigmer = useStigmer();
25
+ const listFn = useMemo(() => createScheduleListFn(stigmer), [stigmer]);
26
+ return useResourceCount(listFn, org, {
27
+ refetchToken: options?.refetchToken,
28
+ });
29
+ }
30
+ //# sourceMappingURL=useScheduleCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScheduleCount.js","sourceRoot":"","sources":["../../src/schedule/useScheduleCount.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAuB3D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAkB,EAClB,OAAiC;IAEjC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvE,OAAO,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;QACnC,YAAY,EAAE,OAAO,EAAE,YAAY;KACpC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
2
+ /** Options for {@link useScheduleList}. */
3
+ export interface UseScheduleListOptions {
4
+ /** Maximum schedules per page. @default 20 */
5
+ readonly pageSize?: number;
6
+ /** Page number (1-indexed). @default 1 */
7
+ readonly page?: number;
8
+ }
9
+ /** Return value of {@link useScheduleList}. */
10
+ export interface UseScheduleListReturn {
11
+ /** Full `Schedule` protos (spec + status) for the current page. */
12
+ readonly schedules: readonly Schedule[];
13
+ /** Total number of schedules in the organization. */
14
+ readonly totalCount: number;
15
+ /** Total pages available at the current page size. */
16
+ readonly totalPages: number;
17
+ /** The current page number (mirrors the `page` option). */
18
+ readonly currentPage: number;
19
+ /** `true` while the initial fetch is in flight. */
20
+ readonly isLoading: boolean;
21
+ /** `true` while a background refetch is in flight. */
22
+ readonly isRefetching: boolean;
23
+ /** Error from the last failed request, or `null` when healthy. */
24
+ readonly error: Error | null;
25
+ /** Discard cached data and re-fetch the current page from the server. */
26
+ readonly refetch: () => void;
27
+ }
28
+ /**
29
+ * Data hook that fetches a paginated list of an organization's schedules.
30
+ *
31
+ * Backed by the direct `listSchedules` query — not the search service —
32
+ * so each entry is a full `Schedule` proto with the operational status
33
+ * fields a schedule list exists to show (`next_fire_at`, enabled/paused
34
+ * state, `last_fire_at`). There is no text query or visibility scope:
35
+ * schedules are org-only and have no server-side search.
36
+ *
37
+ * Pass `null` as `org` to skip fetching (stable no-op).
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * const { schedules, totalCount, isLoading } = useScheduleList("isc", {
42
+ * page: 1,
43
+ * pageSize: 20,
44
+ * });
45
+ * ```
46
+ */
47
+ export declare function useScheduleList(org: string | null, options?: UseScheduleListOptions): UseScheduleListReturn;
48
+ //# sourceMappingURL=useScheduleList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScheduleList.d.ts","sourceRoot":"","sources":["../../src/schedule/useScheduleList.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAKtF,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IACxC,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAuBvB"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { useStigmer } from "../hooks.js";
3
+ import { useFetch } from "../internal/useFetch.js";
4
+ import { listSchedulesPage } from "./scheduleListFn.js";
5
+ const INITIAL_PAGE = { items: [], totalCount: 0, totalPages: 0 };
6
+ /**
7
+ * Data hook that fetches a paginated list of an organization's schedules.
8
+ *
9
+ * Backed by the direct `listSchedules` query — not the search service —
10
+ * so each entry is a full `Schedule` proto with the operational status
11
+ * fields a schedule list exists to show (`next_fire_at`, enabled/paused
12
+ * state, `last_fire_at`). There is no text query or visibility scope:
13
+ * schedules are org-only and have no server-side search.
14
+ *
15
+ * Pass `null` as `org` to skip fetching (stable no-op).
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const { schedules, totalCount, isLoading } = useScheduleList("isc", {
20
+ * page: 1,
21
+ * pageSize: 20,
22
+ * });
23
+ * ```
24
+ */
25
+ export function useScheduleList(org, options) {
26
+ const stigmer = useStigmer();
27
+ const pageSize = options?.pageSize;
28
+ const page = options?.page ?? 1;
29
+ const { data, isLoading, isRefetching, error, refetch } = useFetch(org
30
+ ? () => listSchedulesPage(stigmer, org, { num: page, size: pageSize })
31
+ : null, [stigmer, org, page, pageSize], INITIAL_PAGE);
32
+ return {
33
+ schedules: data.items,
34
+ totalCount: data.totalCount,
35
+ totalPages: data.totalPages,
36
+ currentPage: page,
37
+ isLoading,
38
+ isRefetching,
39
+ error,
40
+ refetch,
41
+ };
42
+ }
43
+ //# sourceMappingURL=useScheduleList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScheduleList.js","sourceRoot":"","sources":["../../src/schedule/useScheduleList.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AA8B3E,MAAM,YAAY,GAAiB,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAE/E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAkB,EAClB,OAAgC;IAEhC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC;IAEhC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,QAAQ,CAChE,GAAG;QACD,CAAC,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACtE,CAAC,CAAC,IAAI,EACR,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAC9B,YAAY,CACb,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,KAAK;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI;QACjB,SAAS;QACT,YAAY;QACZ,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
2
+ /** Return value of {@link useSetScheduleEnabled}. */
3
+ export interface UseSetScheduleEnabledReturn {
4
+ /**
5
+ * Flip the owner's `spec.enabled` switch. Takes the full fetched
6
+ * schedule (not just an id) because the write re-applies the whole
7
+ * resource. Resolves with the post-apply schedule; the caller
8
+ * refetches or replaces its local copy from it.
9
+ */
10
+ readonly setEnabled: (schedule: Schedule, enabled: boolean) => Promise<Schedule>;
11
+ /** `true` while the apply is in flight. */
12
+ readonly isPending: boolean;
13
+ /** Error from the last failed apply, or `null` when healthy. */
14
+ readonly error: Error | null;
15
+ }
16
+ /**
17
+ * Behavior hook that flips a schedule's owner-controlled `enabled` flag.
18
+ *
19
+ * The write path is deliberate: clone the fetched proto, flip one
20
+ * field, and re-apply the WHOLE resource through the manifest engine
21
+ * (`stigmer.manifest.apply`) — never down-convert to the curated
22
+ * `ScheduleInput` shape. The server replaces spec and mutable metadata
23
+ * wholesale on update, and `ScheduleInput` cannot express every
24
+ * metadata field (tags, description), so the input route would silently
25
+ * wipe them. The full-proto route is lossless by construction; the
26
+ * server ignores client-provided status, and re-applying never clears a
27
+ * platform pause (Resume is the one clearing path — see
28
+ * {@link useResumeSchedule}).
29
+ */
30
+ export declare function useSetScheduleEnabled(): UseSetScheduleEnabledReturn;
31
+ //# sourceMappingURL=useSetScheduleEnabled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSetScheduleEnabled.d.ts","sourceRoot":"","sources":["../../src/schedule/useSetScheduleEnabled.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,uDAAuD,CAAC;AAM/D,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjF,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,IAAI,2BAA2B,CAyCnE"}
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import { useCallback, useMemo, useState } from "react";
3
+ import { clone } from "@bufbuild/protobuf";
4
+ import { ScheduleSchema, } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
5
+ import { getUserMessage, manifestDocumentForResource } from "@stigmer/sdk";
6
+ import { useStigmer } from "../hooks.js";
7
+ import { toast } from "../feedback/toast.js";
8
+ import { toError } from "../internal/toError.js";
9
+ /**
10
+ * Behavior hook that flips a schedule's owner-controlled `enabled` flag.
11
+ *
12
+ * The write path is deliberate: clone the fetched proto, flip one
13
+ * field, and re-apply the WHOLE resource through the manifest engine
14
+ * (`stigmer.manifest.apply`) — never down-convert to the curated
15
+ * `ScheduleInput` shape. The server replaces spec and mutable metadata
16
+ * wholesale on update, and `ScheduleInput` cannot express every
17
+ * metadata field (tags, description), so the input route would silently
18
+ * wipe them. The full-proto route is lossless by construction; the
19
+ * server ignores client-provided status, and re-applying never clears a
20
+ * platform pause (Resume is the one clearing path — see
21
+ * {@link useResumeSchedule}).
22
+ */
23
+ export function useSetScheduleEnabled() {
24
+ const stigmer = useStigmer();
25
+ const [isPending, setIsPending] = useState(false);
26
+ const [error, setError] = useState(null);
27
+ const setEnabled = useCallback(async (schedule, enabled) => {
28
+ if (!schedule.spec) {
29
+ throw new Error("Cannot toggle this schedule: it has no spec. Pass a schedule " +
30
+ "as returned by the server (get/getByReference).");
31
+ }
32
+ setIsPending(true);
33
+ setError(null);
34
+ try {
35
+ const updated = clone(ScheduleSchema, schedule);
36
+ updated.spec.enabled = enabled;
37
+ const applied = await stigmer.manifest.apply(manifestDocumentForResource(updated));
38
+ toast.success(enabled ? "Schedule enabled" : "Schedule disabled");
39
+ return applied.message;
40
+ }
41
+ catch (err) {
42
+ const wrapped = toError(err);
43
+ setError(wrapped);
44
+ toast.error(getUserMessage(err));
45
+ throw wrapped;
46
+ }
47
+ finally {
48
+ setIsPending(false);
49
+ }
50
+ }, [stigmer]);
51
+ return useMemo(() => ({ setEnabled, isPending, error }), [setEnabled, isPending, error]);
52
+ }
53
+ //# sourceMappingURL=useSetScheduleEnabled.js.map