@agent-compose/sdk 0.3.1 → 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.
package/dist/client.d.ts CHANGED
@@ -132,6 +132,27 @@ export interface UpdateFactoryInput {
132
132
  name?: string;
133
133
  description?: string;
134
134
  }
135
+ export interface ScheduleRow {
136
+ id: string;
137
+ name: string;
138
+ workflowName: string;
139
+ cron: string;
140
+ createdAt: string;
141
+ updatedAt: string;
142
+ nextFireAt: string | null;
143
+ lastFireAt: string | null;
144
+ }
145
+ export interface CreateScheduleInput {
146
+ /** Human-friendly schedule name. Unique within the factory. */
147
+ name: string;
148
+ /** The workflow this schedule should fire. Must already be registered
149
+ * in the same factory. */
150
+ workflow: string;
151
+ /** Cron expression (UTC). */
152
+ cron: string;
153
+ /** Factory to attach the schedule to. Defaults to `"default"`. */
154
+ factorySlug?: string;
155
+ }
135
156
  export interface SecretOptions {
136
157
  factorySlug?: string;
137
158
  }
@@ -424,6 +445,21 @@ export declare class AgentComposeClient {
424
445
  /** Delete a factory. Refuses `default` and any factory still
425
446
  * containing workflows. */
426
447
  deleteFactory(slug: string): Promise<void>;
448
+ /** List every schedule in a factory, with the engine-reported next/last
449
+ * fire times merged in. */
450
+ listSchedules(factorySlug?: string): Promise<ScheduleRow[]>;
451
+ /** Create a new schedule. `name` is per-factory unique; the server
452
+ * returns 409 on collision. */
453
+ createSchedule(payload: CreateScheduleInput): Promise<{
454
+ id: string;
455
+ name: string;
456
+ workflow: string;
457
+ cron: string;
458
+ }>;
459
+ /** Delete a schedule by id. Best-effort: a transient engine error is
460
+ * logged server-side but the DB row is removed regardless — the boot
461
+ * reconciler reconverges on next start. */
462
+ deleteSchedule(id: string, factorySlug?: string): Promise<void>;
427
463
  /** Create or update a workflow secret. Value is stored in GCP Secret Manager. */
428
464
  setSecret(workflowName: string, key: string, value: string, opts?: SecretOptions): Promise<SetSecretResult>;
429
465
  /** List secret keys registered for a workflow (metadata only — values are never returned). */
package/dist/index.js CHANGED
@@ -861,6 +861,20 @@ class AgentComposeClient {
861
861
  deleteFactory(slug) {
862
862
  return this.fetch(`/api/v1/factories/${encodeURIComponent(slug)}`, { method: "DELETE" });
863
863
  }
864
+ async listSchedules(factorySlug = "default") {
865
+ const body = await this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`);
866
+ return body.schedules;
867
+ }
868
+ createSchedule(payload) {
869
+ const factorySlug = payload.factorySlug ?? "default";
870
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`, {
871
+ method: "POST",
872
+ body: { name: payload.name, workflow: payload.workflow, cron: payload.cron }
873
+ });
874
+ }
875
+ deleteSchedule(id, factorySlug = "default") {
876
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules/${encodeURIComponent(id)}`, { method: "DELETE" });
877
+ }
864
878
  setSecret(workflowName, key, value, opts) {
865
879
  const factorySlug = opts?.factorySlug ?? DEFAULT_FACTORY;
866
880
  return this.fetch(templatePath(factorySlug, workflowName, "secrets"), {
@@ -861,6 +861,20 @@ class AgentComposeClient {
861
861
  deleteFactory(slug) {
862
862
  return this.fetch(`/api/v1/factories/${encodeURIComponent(slug)}`, { method: "DELETE" });
863
863
  }
864
+ async listSchedules(factorySlug = "default") {
865
+ const body = await this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`);
866
+ return body.schedules;
867
+ }
868
+ createSchedule(payload) {
869
+ const factorySlug = payload.factorySlug ?? "default";
870
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`, {
871
+ method: "POST",
872
+ body: { name: payload.name, workflow: payload.workflow, cron: payload.cron }
873
+ });
874
+ }
875
+ deleteSchedule(id, factorySlug = "default") {
876
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules/${encodeURIComponent(id)}`, { method: "DELETE" });
877
+ }
864
878
  setSecret(workflowName, key, value, opts) {
865
879
  const factorySlug = opts?.factorySlug ?? DEFAULT_FACTORY;
866
880
  return this.fetch(templatePath(factorySlug, workflowName, "secrets"), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-compose/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Client library for agent-compose — define agents, runtimes, and workflows, and invoke them against an agent-compose server.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/client.ts CHANGED
@@ -177,6 +177,29 @@ export interface UpdateFactoryInput {
177
177
  description?: string;
178
178
  }
179
179
 
180
+ export interface ScheduleRow {
181
+ id: string;
182
+ name: string;
183
+ workflowName: string;
184
+ cron: string;
185
+ createdAt: string;
186
+ updatedAt: string;
187
+ nextFireAt: string | null;
188
+ lastFireAt: string | null;
189
+ }
190
+
191
+ export interface CreateScheduleInput {
192
+ /** Human-friendly schedule name. Unique within the factory. */
193
+ name: string;
194
+ /** The workflow this schedule should fire. Must already be registered
195
+ * in the same factory. */
196
+ workflow: string;
197
+ /** Cron expression (UTC). */
198
+ cron: string;
199
+ /** Factory to attach the schedule to. Defaults to `"default"`. */
200
+ factorySlug?: string;
201
+ }
202
+
180
203
  export interface SecretOptions {
181
204
  factorySlug?: string;
182
205
  }
@@ -668,6 +691,40 @@ export class AgentComposeClient {
668
691
  return this.fetch(`/api/v1/factories/${encodeURIComponent(slug)}`, { method: "DELETE" });
669
692
  }
670
693
 
694
+ // ── Schedules ─────────────────────────────────────────────────────────────
695
+ // Cron schedules attached to a registered workflow. One workflow can have
696
+ // N schedules with distinct names + cadences; runs the schedule triggers
697
+ // are tagged with the schedule's id and name in their metadata.
698
+
699
+ /** List every schedule in a factory, with the engine-reported next/last
700
+ * fire times merged in. */
701
+ async listSchedules(factorySlug = "default"): Promise<ScheduleRow[]> {
702
+ const body = await this.fetch<{ schedules: ScheduleRow[] }>(
703
+ `/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`,
704
+ );
705
+ return body.schedules;
706
+ }
707
+
708
+ /** Create a new schedule. `name` is per-factory unique; the server
709
+ * returns 409 on collision. */
710
+ createSchedule(payload: CreateScheduleInput): Promise<{ id: string; name: string; workflow: string; cron: string }> {
711
+ const factorySlug = payload.factorySlug ?? "default";
712
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules`, {
713
+ method: "POST",
714
+ body: { name: payload.name, workflow: payload.workflow, cron: payload.cron },
715
+ });
716
+ }
717
+
718
+ /** Delete a schedule by id. Best-effort: a transient engine error is
719
+ * logged server-side but the DB row is removed regardless — the boot
720
+ * reconciler reconverges on next start. */
721
+ deleteSchedule(id: string, factorySlug = "default"): Promise<void> {
722
+ return this.fetch(
723
+ `/api/v1/factories/${encodeURIComponent(factorySlug)}/schedules/${encodeURIComponent(id)}`,
724
+ { method: "DELETE" },
725
+ );
726
+ }
727
+
671
728
  // ── Secrets ────────────────────────────────────────────────────────────────
672
729
  // Scoped to (factory, workflow, key). Stored in GCP Secret Manager;
673
730
  // `factorySlug` defaults to `"default"`.