@todoist/automations-cli 2.2.0 → 2.3.1

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/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  collectSkillStatus,
8
8
  getInstaller,
9
9
  updateAllInstalledSkills
10
- } from "./chunk-4JG637ZB.js";
10
+ } from "./chunk-BAXDCDIS.js";
11
11
 
12
12
  // ../../node_modules/jsonify/lib/parse.js
13
13
  var require_parse = __commonJS({
@@ -8553,7 +8553,7 @@ import { fileURLToPath } from "node:url";
8553
8553
  // package.json
8554
8554
  var package_default = {
8555
8555
  name: "@todoist/automations-cli",
8556
- version: "2.2.0",
8556
+ version: "2.3.1",
8557
8557
  description: "Command-line client for Todoist Automations",
8558
8558
  type: "module",
8559
8559
  bin: {
@@ -8598,7 +8598,7 @@ var package_default = {
8598
8598
  },
8599
8599
  dependencies: {
8600
8600
  "@napi-rs/keyring": "2.1.2",
8601
- "@todoist/cli-core": "2.0.0",
8601
+ "@todoist/cli-core": "2.0.1",
8602
8602
  ai: "7.0.163",
8603
8603
  commander: "15.0.0",
8604
8604
  oauth4webapi: "3.8.8",
@@ -29871,6 +29871,39 @@ var AutomationDraftConnectionsClient = class extends BaseClient {
29871
29871
  }
29872
29872
  };
29873
29873
 
29874
+ // ../../packages/sdk/dist/core/dist/esm/schemas/automation-loop-review.schema.js
29875
+ var automationLoopFindingSchema = external_exports.object({
29876
+ triggerIndex: external_exports.int().nonnegative(),
29877
+ stepIds: external_exports.array(external_exports.string().min(1).max(100)).min(1).max(20),
29878
+ feedbackPath: external_exports.string().min(1).max(1500),
29879
+ evidence: external_exports.string().min(1).max(1500),
29880
+ uncertainty: external_exports.string().max(1e3),
29881
+ suggestedCorrection: external_exports.string().min(1).max(1500)
29882
+ });
29883
+ var automationLoopReviewSchema = external_exports.discriminatedUnion("state", [
29884
+ external_exports.object({
29885
+ state: external_exports.literal("not-applicable"),
29886
+ fingerprint: external_exports.string().min(1)
29887
+ }),
29888
+ external_exports.object({
29889
+ state: external_exports.literal("reviewed"),
29890
+ fingerprint: external_exports.string().min(1),
29891
+ findings: external_exports.array(automationLoopFindingSchema).max(8),
29892
+ limitations: external_exports.array(external_exports.string().min(1).max(1e3)).max(8)
29893
+ }),
29894
+ external_exports.object({
29895
+ state: external_exports.literal("unavailable"),
29896
+ fingerprint: external_exports.string().min(1),
29897
+ reason: external_exports.enum([
29898
+ "incomplete",
29899
+ "input-limit",
29900
+ "definitions",
29901
+ "provider",
29902
+ "revision-changed"
29903
+ ])
29904
+ })
29905
+ ]);
29906
+
29874
29907
  // ../../packages/sdk/dist/core/dist/esm/schemas/shared.schema.js
29875
29908
  var RolloutCompatibleNullableStringSchema = external_exports.string().nullish().transform((value) => value ?? null);
29876
29909
 
@@ -29975,31 +30008,101 @@ var ReadUsageSummaryResponseSchema = external_exports.object({
29975
30008
 
29976
30009
  // ../../packages/sdk/dist/core/dist/esm/types/failure-category.types.js
29977
30010
  var FAILURE_CATEGORY_REGISTRY = {
29978
- ai_quota_exceeded: { reliabilityLabel: "AI usage quota exceeded" },
29979
- mcp_upstream_unavailable: { reliabilityLabel: "Mcp Upstream Unavailable" },
29980
- mcp_client_missing: { reliabilityLabel: "Mcp Client Missing" },
29981
- mcp_tool_missing: { reliabilityLabel: "Mcp Tool Missing" },
29982
- mcp_tool_call_failed: { reliabilityLabel: "Mcp Tool Call Failed" },
29983
- llm_schema_validation: { reliabilityLabel: "Llm Schema Validation" },
29984
- llm_empty_response: { reliabilityLabel: "Llm Empty Response" },
29985
- llm_provider_error: { reliabilityLabel: "Llm Provider Error" },
29986
- prompt_too_large: { reliabilityLabel: "Prompt Too Large" },
29987
- json_parse_error: { reliabilityLabel: "Json Parse Error" },
29988
- code_execution_error: { reliabilityLabel: "Code Execution Error" },
29989
- code_generation_error: { reliabilityLabel: "Code Generation Error" },
29990
- step_execution_error: { reliabilityLabel: "Step Execution Error" },
29991
- step_failure_pattern: { reliabilityLabel: "Step Failure Pattern" },
29992
- schema_validation: { reliabilityLabel: "Schema Validation" },
29993
- template_variable_error: { reliabilityLabel: "Template Variable Error" },
29994
- invalid_configuration: { reliabilityLabel: "Invalid Configuration" },
29995
- invalid_manifest: { reliabilityLabel: "Invalid Manifest" },
29996
- automation_not_found: { reliabilityLabel: "Automation Not Found" },
29997
- timeout: { reliabilityLabel: "Timeout" },
29998
- runtime_error: { reliabilityLabel: "Runtime Error" },
29999
- billing_unavailable: { reliabilityLabel: "Billing Unavailable" },
30000
- unknown: { reliabilityLabel: "Unknown" }
30011
+ ai_quota_exceeded: {
30012
+ reliabilityLabel: "AI usage quota exceeded",
30013
+ countsAgainstReliability: false
30014
+ },
30015
+ mcp_upstream_unavailable: {
30016
+ reliabilityLabel: "Mcp Upstream Unavailable",
30017
+ countsAgainstReliability: true
30018
+ },
30019
+ mcp_client_missing: {
30020
+ reliabilityLabel: "Mcp Client Missing",
30021
+ countsAgainstReliability: true
30022
+ },
30023
+ mcp_tool_missing: {
30024
+ reliabilityLabel: "Mcp Tool Missing",
30025
+ countsAgainstReliability: true
30026
+ },
30027
+ mcp_tool_call_failed: {
30028
+ reliabilityLabel: "Mcp Tool Call Failed",
30029
+ countsAgainstReliability: true
30030
+ },
30031
+ llm_schema_validation: {
30032
+ reliabilityLabel: "Llm Schema Validation",
30033
+ countsAgainstReliability: true
30034
+ },
30035
+ llm_empty_response: {
30036
+ reliabilityLabel: "Llm Empty Response",
30037
+ countsAgainstReliability: true
30038
+ },
30039
+ llm_provider_error: {
30040
+ reliabilityLabel: "Llm Provider Error",
30041
+ countsAgainstReliability: true
30042
+ },
30043
+ prompt_too_large: {
30044
+ reliabilityLabel: "Prompt Too Large",
30045
+ countsAgainstReliability: true
30046
+ },
30047
+ json_parse_error: {
30048
+ reliabilityLabel: "Json Parse Error",
30049
+ countsAgainstReliability: true
30050
+ },
30051
+ code_execution_error: {
30052
+ reliabilityLabel: "Code Execution Error",
30053
+ countsAgainstReliability: true
30054
+ },
30055
+ code_generation_error: {
30056
+ reliabilityLabel: "Code Generation Error",
30057
+ countsAgainstReliability: true
30058
+ },
30059
+ step_execution_error: {
30060
+ reliabilityLabel: "Step Execution Error",
30061
+ countsAgainstReliability: true
30062
+ },
30063
+ step_failure_pattern: {
30064
+ reliabilityLabel: "Step Failure Pattern",
30065
+ countsAgainstReliability: true
30066
+ },
30067
+ schema_validation: {
30068
+ reliabilityLabel: "Schema Validation",
30069
+ countsAgainstReliability: true
30070
+ },
30071
+ template_variable_error: {
30072
+ reliabilityLabel: "Template Variable Error",
30073
+ countsAgainstReliability: true
30074
+ },
30075
+ invalid_configuration: {
30076
+ reliabilityLabel: "Invalid Configuration",
30077
+ countsAgainstReliability: true
30078
+ },
30079
+ invalid_manifest: {
30080
+ reliabilityLabel: "Invalid Manifest",
30081
+ countsAgainstReliability: true
30082
+ },
30083
+ automation_not_found: {
30084
+ reliabilityLabel: "Automation Not Found",
30085
+ countsAgainstReliability: true
30086
+ },
30087
+ timeout: {
30088
+ reliabilityLabel: "Timeout",
30089
+ countsAgainstReliability: true
30090
+ },
30091
+ runtime_error: {
30092
+ reliabilityLabel: "Runtime Error",
30093
+ countsAgainstReliability: true
30094
+ },
30095
+ billing_unavailable: {
30096
+ reliabilityLabel: "Billing Unavailable",
30097
+ countsAgainstReliability: true
30098
+ },
30099
+ unknown: {
30100
+ reliabilityLabel: "Unknown",
30101
+ countsAgainstReliability: true
30102
+ }
30001
30103
  };
30002
30104
  var FAILURE_CATEGORIES = Object.keys(FAILURE_CATEGORY_REGISTRY);
30105
+ Object.freeze(FAILURE_CATEGORIES.filter((category) => !FAILURE_CATEGORY_REGISTRY[category].countsAgainstReliability));
30003
30106
  var SKIP_CATEGORIES = USAGE_BILLING_AUTHORIZATION_DENIAL_REASONS;
30004
30107
 
30005
30108
  // ../../packages/sdk/dist/core/dist/esm/schemas/query-param.schema.js
@@ -30568,7 +30671,8 @@ var automationSchema = external_exports.object({
30568
30671
  workspaceId: external_exports.string().nullable(),
30569
30672
  visibility: external_exports.enum(AUTOMATION_VISIBILITIES),
30570
30673
  isOwner: external_exports.boolean(),
30571
- disabledReason: external_exports.enum(AUTOMATION_DISABLED_REASONS).nullable()
30674
+ disabledReason: external_exports.enum(AUTOMATION_DISABLED_REASONS).nullable(),
30675
+ loopReview: automationLoopReviewSchema.optional()
30572
30676
  });
30573
30677
  var automationListResponseSchema = external_exports.object({
30574
30678
  data: external_exports.array(automationSchema),
@@ -30715,7 +30819,8 @@ var automationDraftSchema = external_exports.object({
30715
30819
  var automationDraftValidationSchema = external_exports.object({
30716
30820
  state: external_exports.enum(["incomplete", "ready"]),
30717
30821
  issues: external_exports.array(external_exports.string()),
30718
- modified: external_exports.boolean()
30822
+ modified: external_exports.boolean(),
30823
+ loopReview: automationLoopReviewSchema.optional()
30719
30824
  });
30720
30825
  var automationDraftWithValidationSchema = automationDraftValidationSchema.extend({ draft: automationDraftSchema });
30721
30826
  var automationDraftListResponseSchema = external_exports.object({
@@ -30724,7 +30829,10 @@ var automationDraftListResponseSchema = external_exports.object({
30724
30829
  });
30725
30830
  var listAutomationDraftsQuerySchema = CursorPaginationSchema.extend({ conversationId: external_exports.string().min(1).optional() });
30726
30831
  external_exports.object({ enabled: external_exports.boolean().optional() }).meta({ id: "FinalizeAutomationDraftRequest" });
30727
- var finalizeAutomationDraftResponseSchema = external_exports.object({ automation: automationSchema });
30832
+ var finalizeAutomationDraftResponseSchema = external_exports.object({
30833
+ automation: automationSchema,
30834
+ loopReview: automationLoopReviewSchema.optional()
30835
+ });
30728
30836
  var draftTestTriggerSelectorSchema = external_exports.union([external_exports.object({ index: external_exports.int().min(0) }), external_exports.object({ event: external_exports.string().min(1) })]);
30729
30837
  var testAutomationDraftRequestSchema = external_exports.object({
30730
30838
  trigger: draftTestTriggerSelectorSchema.optional(),
@@ -32790,6 +32898,7 @@ var UsageBillingClient = class extends BaseClient {
32790
32898
  var WEBHOOK_EVENT_TYPES = [
32791
32899
  "automation:run:started",
32792
32900
  "automation:run:finished",
32901
+ "automation:run:input_required",
32793
32902
  "automation:created",
32794
32903
  "automation:updated",
32795
32904
  "automation:deleted",
@@ -32828,6 +32937,7 @@ var AutomationCreatedEventSchema = external_exports.object({
32828
32937
  // ../../packages/sdk/dist/core/dist/esm/schemas/webhook-events/automation-deleted.event.js
32829
32938
  var AutomationDeletedDataSchema = external_exports.object({
32830
32939
  automationId: external_exports.string(),
32940
+ name: external_exports.string().describe("The automation name at the time it was deleted"),
32831
32941
  deletedAt: external_exports.iso.datetime()
32832
32942
  });
32833
32943
  var AutomationDeletedEventSchema = external_exports.object({
@@ -32839,7 +32949,8 @@ var AutomationDeletedEventSchema = external_exports.object({
32839
32949
  // ../../packages/sdk/dist/core/dist/esm/schemas/webhook-events/automation-disabled.event.js
32840
32950
  var AutomationDisabledDataSchema = external_exports.object({
32841
32951
  automationId: external_exports.string(),
32842
- disabledAt: external_exports.iso.datetime()
32952
+ disabledAt: external_exports.iso.datetime(),
32953
+ disabledReason: external_exports.enum(AUTOMATION_DISABLED_REASONS).nullable().default(null).describe("Why the system stopped the automation. null means a person turned it off and can turn it back on.")
32843
32954
  });
32844
32955
  var AutomationDisabledEventSchema = external_exports.object({
32845
32956
  type: external_exports.literal("automation:disabled"),
@@ -32889,6 +33000,24 @@ var AutomationRunFinishedEventSchema = external_exports.object({
32889
33000
  data: AutomationRunFinishedDataSchema
32890
33001
  });
32891
33002
 
33003
+ // ../../packages/sdk/dist/core/dist/esm/schemas/webhook-events/automation-run-input-required.event.js
33004
+ var AutomationRunInputRequiredDataSchema = external_exports.object({
33005
+ automationRunId: external_exports.string(),
33006
+ automationId: external_exports.string(),
33007
+ stepId: external_exports.string(),
33008
+ notificationId: external_exports.string(),
33009
+ message: external_exports.string(),
33010
+ details: external_exports.string().nullable(),
33011
+ options: external_exports.array(PromptOptionSchema),
33012
+ askedAt: external_exports.iso.datetime(),
33013
+ expiresAt: external_exports.iso.datetime().nullable()
33014
+ });
33015
+ var AutomationRunInputRequiredEventSchema = external_exports.object({
33016
+ type: external_exports.literal("automation:run:input_required"),
33017
+ timestamp: external_exports.iso.datetime(),
33018
+ data: AutomationRunInputRequiredDataSchema
33019
+ });
33020
+
32892
33021
  // ../../packages/sdk/dist/core/dist/esm/schemas/webhook-events/automation-run-started.event.js
32893
33022
  var AutomationRunStartedDataSchema = external_exports.object({
32894
33023
  automationRunId: external_exports.string(),
@@ -32941,6 +33070,7 @@ var WEBHOOK_EVENT_SUBSCRIPTION_DESCRIPTION_MAX_LENGTH = 200;
32941
33070
  external_exports.discriminatedUnion("type", [
32942
33071
  AutomationRunStartedEventSchema,
32943
33072
  AutomationRunFinishedEventSchema,
33073
+ AutomationRunInputRequiredEventSchema,
32944
33074
  AutomationCreatedEventSchema,
32945
33075
  AutomationUpdatedEventSchema,
32946
33076
  AutomationDeletedEventSchema,
@@ -34571,6 +34701,7 @@ async function publishDraft(draftApi, { draftId, confirmed, submittedManifest })
34571
34701
  action: "published",
34572
34702
  summary,
34573
34703
  automation: published.automation,
34704
+ ...published.loopReview ? { loopReview: published.loopReview } : {},
34574
34705
  verification: {
34575
34706
  status: "unavailable",
34576
34707
  reason: getErrorMessage(error62)
@@ -34586,7 +34717,8 @@ async function publishDraft(draftApi, { draftId, confirmed, submittedManifest })
34586
34717
  return {
34587
34718
  action: "published",
34588
34719
  summary,
34589
- automation,
34720
+ automation: published.automation,
34721
+ ...published.loopReview ? { loopReview: published.loopReview } : {},
34590
34722
  verification: isDeepEqual(expected, actual) ? {
34591
34723
  status: "matched",
34592
34724
  against
@@ -34606,6 +34738,7 @@ async function previewPublish(draftApi, draftId, submittedManifest) {
34606
34738
  const diff = published ? diffManifests(normaliseManifest(published.manifest), savedDraft) : null;
34607
34739
  return {
34608
34740
  summary: {
34741
+ ...detail.loopReview ? { loopReview: detail.loopReview } : {},
34609
34742
  draftId,
34610
34743
  name: readManifestName(draft.partialManifest),
34611
34744
  scope: draft.workspaceId === null ? { kind: "personal" } : {
@@ -35571,31 +35704,68 @@ var ReadUsageSummaryResponseSchema2 = external_exports.object({
35571
35704
 
35572
35705
  // ../../packages/core/dist/esm/types/failure-category.types.js
35573
35706
  var FAILURE_CATEGORY_REGISTRY2 = {
35574
- ai_quota_exceeded: { reliabilityLabel: "AI usage quota exceeded" },
35575
- mcp_upstream_unavailable: { reliabilityLabel: "Mcp Upstream Unavailable" },
35576
- mcp_client_missing: { reliabilityLabel: "Mcp Client Missing" },
35577
- mcp_tool_missing: { reliabilityLabel: "Mcp Tool Missing" },
35578
- mcp_tool_call_failed: { reliabilityLabel: "Mcp Tool Call Failed" },
35579
- llm_schema_validation: { reliabilityLabel: "Llm Schema Validation" },
35580
- llm_empty_response: { reliabilityLabel: "Llm Empty Response" },
35581
- llm_provider_error: { reliabilityLabel: "Llm Provider Error" },
35582
- prompt_too_large: { reliabilityLabel: "Prompt Too Large" },
35583
- json_parse_error: { reliabilityLabel: "Json Parse Error" },
35584
- code_execution_error: { reliabilityLabel: "Code Execution Error" },
35585
- code_generation_error: { reliabilityLabel: "Code Generation Error" },
35586
- step_execution_error: { reliabilityLabel: "Step Execution Error" },
35587
- step_failure_pattern: { reliabilityLabel: "Step Failure Pattern" },
35588
- schema_validation: { reliabilityLabel: "Schema Validation" },
35589
- template_variable_error: { reliabilityLabel: "Template Variable Error" },
35590
- invalid_configuration: { reliabilityLabel: "Invalid Configuration" },
35591
- invalid_manifest: { reliabilityLabel: "Invalid Manifest" },
35592
- automation_not_found: { reliabilityLabel: "Automation Not Found" },
35593
- timeout: { reliabilityLabel: "Timeout" },
35594
- runtime_error: { reliabilityLabel: "Runtime Error" },
35595
- billing_unavailable: { reliabilityLabel: "Billing Unavailable" },
35596
- unknown: { reliabilityLabel: "Unknown" }
35707
+ ai_quota_exceeded: {
35708
+ reliabilityLabel: "AI usage quota exceeded",
35709
+ countsAgainstReliability: false
35710
+ },
35711
+ mcp_upstream_unavailable: {
35712
+ reliabilityLabel: "Mcp Upstream Unavailable",
35713
+ countsAgainstReliability: true
35714
+ },
35715
+ mcp_client_missing: { reliabilityLabel: "Mcp Client Missing", countsAgainstReliability: true },
35716
+ mcp_tool_missing: { reliabilityLabel: "Mcp Tool Missing", countsAgainstReliability: true },
35717
+ mcp_tool_call_failed: {
35718
+ reliabilityLabel: "Mcp Tool Call Failed",
35719
+ countsAgainstReliability: true
35720
+ },
35721
+ llm_schema_validation: {
35722
+ reliabilityLabel: "Llm Schema Validation",
35723
+ countsAgainstReliability: true
35724
+ },
35725
+ llm_empty_response: { reliabilityLabel: "Llm Empty Response", countsAgainstReliability: true },
35726
+ llm_provider_error: { reliabilityLabel: "Llm Provider Error", countsAgainstReliability: true },
35727
+ prompt_too_large: { reliabilityLabel: "Prompt Too Large", countsAgainstReliability: true },
35728
+ json_parse_error: { reliabilityLabel: "Json Parse Error", countsAgainstReliability: true },
35729
+ code_execution_error: {
35730
+ reliabilityLabel: "Code Execution Error",
35731
+ countsAgainstReliability: true
35732
+ },
35733
+ code_generation_error: {
35734
+ reliabilityLabel: "Code Generation Error",
35735
+ countsAgainstReliability: true
35736
+ },
35737
+ step_execution_error: {
35738
+ reliabilityLabel: "Step Execution Error",
35739
+ countsAgainstReliability: true
35740
+ },
35741
+ step_failure_pattern: {
35742
+ reliabilityLabel: "Step Failure Pattern",
35743
+ countsAgainstReliability: true
35744
+ },
35745
+ schema_validation: { reliabilityLabel: "Schema Validation", countsAgainstReliability: true },
35746
+ template_variable_error: {
35747
+ reliabilityLabel: "Template Variable Error",
35748
+ countsAgainstReliability: true
35749
+ },
35750
+ invalid_configuration: {
35751
+ reliabilityLabel: "Invalid Configuration",
35752
+ countsAgainstReliability: true
35753
+ },
35754
+ invalid_manifest: { reliabilityLabel: "Invalid Manifest", countsAgainstReliability: true },
35755
+ automation_not_found: {
35756
+ reliabilityLabel: "Automation Not Found",
35757
+ countsAgainstReliability: true
35758
+ },
35759
+ timeout: { reliabilityLabel: "Timeout", countsAgainstReliability: true },
35760
+ runtime_error: { reliabilityLabel: "Runtime Error", countsAgainstReliability: true },
35761
+ billing_unavailable: {
35762
+ reliabilityLabel: "Billing Unavailable",
35763
+ countsAgainstReliability: true
35764
+ },
35765
+ unknown: { reliabilityLabel: "Unknown", countsAgainstReliability: true }
35597
35766
  };
35598
35767
  var FAILURE_CATEGORIES2 = Object.keys(FAILURE_CATEGORY_REGISTRY2);
35768
+ var RELIABILITY_EXCLUDED_FAILURE_CATEGORIES = Object.freeze(FAILURE_CATEGORIES2.filter((category) => !FAILURE_CATEGORY_REGISTRY2[category].countsAgainstReliability));
35599
35769
  var SKIP_CATEGORIES2 = USAGE_BILLING_AUTHORIZATION_DENIAL_REASONS2;
35600
35770
  function isSkipCategory(category) {
35601
35771
  return SKIP_CATEGORIES2.includes(category);
@@ -37109,7 +37279,11 @@ function createAutomationsAuthProvider() {
37109
37279
  throw new Error("createAutomationsAuthProvider: validate() must be overridden");
37110
37280
  }
37111
37281
  }),
37112
- async validateToken({ token, handshake }) {
37282
+ async validateToken({
37283
+ token,
37284
+ handshake,
37285
+ scope
37286
+ }) {
37113
37287
  const environment = getEnvironment();
37114
37288
  const flags = handshake.flags ?? {};
37115
37289
  const readOnly = Boolean(handshake.readOnly);
@@ -37118,7 +37292,9 @@ function createAutomationsAuthProvider() {
37118
37292
  environment: environment.name,
37119
37293
  userId: user.id,
37120
37294
  email: user.email,
37121
- scope: resolveScopes({ readOnly, flags }).join(" ")
37295
+ // Todoist can grant less than was asked for: the user may choose
37296
+ // read-only access on the consent screen.
37297
+ scope: scope ?? resolveScopes({ readOnly, flags }).join(" ")
37122
37298
  });
37123
37299
  }
37124
37300
  };
@@ -38164,6 +38340,7 @@ var PublishDraftOutputSchema = external_exports.union([external_exports.object({
38164
38340
  draftId: external_exports.string().min(1),
38165
38341
  action: CompleteAutomationDraftActionSchema,
38166
38342
  automationId: external_exports.string().min(1),
38343
+ loopReview: automationLoopReviewSchema.optional(),
38167
38344
  previewArtifact: automationPreviewArtifactSchema.optional()
38168
38345
  }), external_exports.object({
38169
38346
  success: external_exports.literal(false),
@@ -38171,6 +38348,7 @@ var PublishDraftOutputSchema = external_exports.union([external_exports.object({
38171
38348
  instructions: external_exports.string().min(1),
38172
38349
  draftId: external_exports.string().min(1),
38173
38350
  action: CompleteAutomationDraftActionSchema.optional(),
38351
+ loopReview: automationLoopReviewSchema.optional(),
38174
38352
  previewArtifact: automationPreviewArtifactSchema.optional()
38175
38353
  })]);
38176
38354
  external_exports.object({
@@ -38589,22 +38767,25 @@ function classifyChatTurnFailure(error62) {
38589
38767
 
38590
38768
  // ../../packages/sdk/dist/chat-turn/transport.js
38591
38769
  import { DefaultChatTransport, readUIMessageStream } from "ai";
38770
+ function getChatTurnUrl(apiRoot, workspaceId) {
38771
+ return workspaceId ? `${apiRoot}/workspaces/${encodeURIComponent(workspaceId)}/chat` : `${apiRoot}/chat`;
38772
+ }
38592
38773
  var ChatTurnTransport = class {
38593
38774
  transport;
38594
38775
  constructor({ token, baseUrl, headers, fetch: fetch2 }) {
38595
38776
  const apiRoot = `${baseUrl.replace(/\/+$/, "")}/v1`;
38596
38777
  this.transport = new DefaultChatTransport({
38597
- api: `${apiRoot}/chat`,
38778
+ api: getChatTurnUrl(apiRoot, null),
38598
38779
  headers: {
38599
38780
  Authorization: `Bearer ${token}`,
38600
38781
  ...headers
38601
38782
  },
38602
38783
  credentials: "include",
38603
38784
  fetch: fetch2,
38604
- prepareSendMessagesRequest({ messages, body, api }) {
38785
+ prepareSendMessagesRequest({ messages, body }) {
38605
38786
  const { workspaceId, ...rest } = body ?? {};
38606
38787
  return {
38607
- api: workspaceId ? `${apiRoot}/workspaces/${encodeURIComponent(workspaceId)}/chat` : api,
38788
+ api: getChatTurnUrl(apiRoot, workspaceId),
38608
38789
  body: {
38609
38790
  ...rest,
38610
38791
  message: messages.at(-1)
@@ -42140,6 +42321,7 @@ function formatDraftPublish(result) {
42140
42321
  return [
42141
42322
  `Published draft ${summary.draftId} as automation ${automation.id} (${how}).`,
42142
42323
  ...describeVerification(verification),
42324
+ ...describeLoopReview(result.loopReview),
42143
42325
  `Open: ${result.url}`,
42144
42326
  ...describeQuestionDelivery(summary.questions)
42145
42327
  ].join("\n");
@@ -42174,6 +42356,7 @@ function summarizeDraftPublish(result) {
42174
42356
  }
42175
42357
  function describePublishSummary(summary) {
42176
42358
  const lines = [
42359
+ ...describeLoopReview(summary.loopReview),
42177
42360
  `Draft: ${summary.name} (${summary.draftId})`,
42178
42361
  summary.scope.kind === "personal" ? "Scope: personal" : `Scope: workspace ${summary.scope.workspaceId} (${describeVisibility2(summary)})`,
42179
42362
  summary.target.kind === "new" ? "Action: create a new automation" : `Action: update automation ${summary.target.automationId}`,
@@ -42193,6 +42376,17 @@ function describePublishSummary(summary) {
42193
42376
  }
42194
42377
  return lines;
42195
42378
  }
42379
+ function describeLoopReview(review) {
42380
+ if (review?.state === "unavailable")
42381
+ return ["Warning: loop review is unavailable; no safety conclusion was reached."];
42382
+ if (review?.state !== "reviewed") return [];
42383
+ return [
42384
+ ...review.findings.map(
42385
+ (finding) => `Loop warning: ${finding.feedbackPath}. ${finding.suggestedCorrection}`
42386
+ ),
42387
+ ...review.limitations.map((limitation) => `Loop review limitation: ${limitation}`)
42388
+ ];
42389
+ }
42196
42390
  function describeVisibility2(summary) {
42197
42391
  if (summary.scope.kind !== "workspace") return "";
42198
42392
  const visibility = summary.scope.visibility === "workspace" ? "visible to the workspace" : "private";