@vertesia/workflow 0.79.0 → 0.80.0-dev-20251118

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 (144) hide show
  1. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +3 -4
  2. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -1
  3. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +10 -4
  4. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -1
  5. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +3 -4
  6. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -1
  7. package/lib/cjs/activities/chunkDocument.js +1 -2
  8. package/lib/cjs/activities/chunkDocument.js.map +1 -1
  9. package/lib/cjs/activities/executeInteraction.js +5 -4
  10. package/lib/cjs/activities/executeInteraction.js.map +1 -1
  11. package/lib/cjs/activities/generateDocumentProperties.js +2 -3
  12. package/lib/cjs/activities/generateDocumentProperties.js.map +1 -1
  13. package/lib/cjs/activities/generateOrAssignContentType.js +2 -3
  14. package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -1
  15. package/lib/cjs/activities/index-dsl.js +3 -1
  16. package/lib/cjs/activities/index-dsl.js.map +1 -1
  17. package/lib/cjs/activities/media/prepareVideo.js +429 -0
  18. package/lib/cjs/activities/media/prepareVideo.js.map +1 -0
  19. package/lib/cjs/activities/media/transcribeMediaWithGladia.js +48 -15
  20. package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -1
  21. package/lib/cjs/activities/notifyWebhook.js +2 -1
  22. package/lib/cjs/activities/notifyWebhook.js.map +1 -1
  23. package/lib/cjs/dsl/dsl-workflow.js +6 -1
  24. package/lib/cjs/dsl/dsl-workflow.js.map +1 -1
  25. package/lib/cjs/dsl/setup/ActivityContext.js +7 -4
  26. package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -1
  27. package/lib/cjs/errors.js +14 -1
  28. package/lib/cjs/errors.js.map +1 -1
  29. package/lib/cjs/index.js +1 -0
  30. package/lib/cjs/index.js.map +1 -1
  31. package/lib/cjs/iterative-generation/activities/extractToc.js +2 -2
  32. package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -1
  33. package/lib/cjs/iterative-generation/activities/finalizeOutput.js +7 -4
  34. package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -1
  35. package/lib/cjs/iterative-generation/activities/generatePart.js +18 -14
  36. package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -1
  37. package/lib/cjs/iterative-generation/activities/generateToc.js +46 -56
  38. package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -1
  39. package/lib/cjs/iterative-generation/utils.js.map +1 -1
  40. package/lib/cjs/utils/blobs.js +4 -1
  41. package/lib/cjs/utils/blobs.js.map +1 -1
  42. package/lib/cjs/utils/client.js +3 -1
  43. package/lib/cjs/utils/client.js.map +1 -1
  44. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +3 -4
  45. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -1
  46. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +10 -4
  47. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -1
  48. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +3 -4
  49. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -1
  50. package/lib/esm/activities/chunkDocument.js +1 -2
  51. package/lib/esm/activities/chunkDocument.js.map +1 -1
  52. package/lib/esm/activities/executeInteraction.js +5 -4
  53. package/lib/esm/activities/executeInteraction.js.map +1 -1
  54. package/lib/esm/activities/generateDocumentProperties.js +2 -3
  55. package/lib/esm/activities/generateDocumentProperties.js.map +1 -1
  56. package/lib/esm/activities/generateOrAssignContentType.js +2 -3
  57. package/lib/esm/activities/generateOrAssignContentType.js.map +1 -1
  58. package/lib/esm/activities/index-dsl.js +1 -0
  59. package/lib/esm/activities/index-dsl.js.map +1 -1
  60. package/lib/esm/activities/media/prepareVideo.js +390 -0
  61. package/lib/esm/activities/media/prepareVideo.js.map +1 -0
  62. package/lib/esm/activities/media/transcribeMediaWithGladia.js +50 -17
  63. package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -1
  64. package/lib/esm/activities/notifyWebhook.js +2 -1
  65. package/lib/esm/activities/notifyWebhook.js.map +1 -1
  66. package/lib/esm/dsl/dsl-workflow.js +6 -1
  67. package/lib/esm/dsl/dsl-workflow.js.map +1 -1
  68. package/lib/esm/dsl/setup/ActivityContext.js +10 -7
  69. package/lib/esm/dsl/setup/ActivityContext.js.map +1 -1
  70. package/lib/esm/errors.js +12 -0
  71. package/lib/esm/errors.js.map +1 -1
  72. package/lib/esm/index.js +1 -0
  73. package/lib/esm/index.js.map +1 -1
  74. package/lib/esm/iterative-generation/activities/extractToc.js +3 -3
  75. package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -1
  76. package/lib/esm/iterative-generation/activities/finalizeOutput.js +9 -6
  77. package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -1
  78. package/lib/esm/iterative-generation/activities/generatePart.js +19 -15
  79. package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -1
  80. package/lib/esm/iterative-generation/activities/generateToc.js +46 -56
  81. package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -1
  82. package/lib/esm/iterative-generation/utils.js.map +1 -1
  83. package/lib/esm/utils/blobs.js +4 -1
  84. package/lib/esm/utils/blobs.js.map +1 -1
  85. package/lib/esm/utils/client.js +4 -2
  86. package/lib/esm/utils/client.js.map +1 -1
  87. package/lib/tsconfig.tsbuildinfo +1 -1
  88. package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +1 -1
  89. package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +1 -1
  90. package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +1 -1
  91. package/lib/types/activities/chunkDocument.d.ts.map +1 -1
  92. package/lib/types/activities/executeInteraction.d.ts +1 -1
  93. package/lib/types/activities/executeInteraction.d.ts.map +1 -1
  94. package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -1
  95. package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -1
  96. package/lib/types/activities/index-dsl.d.ts +1 -0
  97. package/lib/types/activities/index-dsl.d.ts.map +1 -1
  98. package/lib/types/activities/media/prepareVideo.d.ts +30 -0
  99. package/lib/types/activities/media/prepareVideo.d.ts.map +1 -0
  100. package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -1
  101. package/lib/types/dsl/dsl-workflow.d.ts.map +1 -1
  102. package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -1
  103. package/lib/types/errors.d.ts +6 -0
  104. package/lib/types/errors.d.ts.map +1 -1
  105. package/lib/types/index.d.ts +1 -0
  106. package/lib/types/index.d.ts.map +1 -1
  107. package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -1
  108. package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -1
  109. package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -1
  110. package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -1
  111. package/lib/types/iterative-generation/utils.d.ts +3 -4
  112. package/lib/types/iterative-generation/utils.d.ts.map +1 -1
  113. package/lib/types/utils/blobs.d.ts.map +1 -1
  114. package/lib/types/utils/client.d.ts +2 -6
  115. package/lib/types/utils/client.d.ts.map +1 -1
  116. package/lib/workflows-bundle.js +9494 -6518
  117. package/package.json +127 -127
  118. package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +4 -6
  119. package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +10 -4
  120. package/src/activities/advanced/updateDocumentFromInteractionRun.ts +3 -5
  121. package/src/activities/chunkDocument.ts +1 -2
  122. package/src/activities/executeInteraction.ts +13 -11
  123. package/src/activities/generateDocumentProperties.ts +2 -3
  124. package/src/activities/generateOrAssignContentType.ts +2 -3
  125. package/src/activities/index-dsl.ts +1 -0
  126. package/src/activities/media/prepareVideo.ts +622 -0
  127. package/src/activities/media/transcribeMediaWithGladia.ts +52 -21
  128. package/src/activities/notifyWebhook.test.ts +1 -1
  129. package/src/activities/notifyWebhook.ts +2 -1
  130. package/src/dsl/dsl-workflow.ts +7 -1
  131. package/src/dsl/setup/ActivityContext.ts +45 -12
  132. package/src/dsl/workflow-exec-child.test.ts +3 -3
  133. package/src/dsl/workflow-fetch.test.ts +1 -1
  134. package/src/dsl/workflow-import.test.ts +1 -1
  135. package/src/dsl/workflow.test.ts +1 -1
  136. package/src/errors.ts +15 -0
  137. package/src/index.ts +1 -0
  138. package/src/iterative-generation/activities/extractToc.ts +26 -12
  139. package/src/iterative-generation/activities/finalizeOutput.ts +52 -29
  140. package/src/iterative-generation/activities/generatePart.ts +65 -25
  141. package/src/iterative-generation/activities/generateToc.ts +79 -67
  142. package/src/iterative-generation/utils.ts +4 -5
  143. package/src/utils/blobs.ts +3 -1
  144. package/src/utils/client.ts +22 -8
@@ -2,30 +2,49 @@ import { ApplicationFailure } from "@temporalio/workflow";
2
2
  import { WorkflowExecutionPayload } from "@vertesia/common";
3
3
  import { MemoryPack } from "@vertesia/memory";
4
4
  import { getVertesiaClient } from "../../utils/client.js";
5
- import { buildAndPublishMemoryPack, loadMemoryPack } from "../../utils/memory.js";
6
- import { IterativeGenerationPayload, OutputMemoryMeta, Section, TocPart, TocSection } from "../types.js";
5
+ import {
6
+ buildAndPublishMemoryPack,
7
+ loadMemoryPack,
8
+ } from "../../utils/memory.js";
9
+ import {
10
+ IterativeGenerationPayload,
11
+ OutputMemoryMeta,
12
+ Section,
13
+ TocPart,
14
+ TocSection,
15
+ } from "../types.js";
7
16
  import { executeWithVars, expectMemoryIsConsistent } from "../utils.js";
8
- import { completionResultToString } from "@llumiverse/common";
9
17
 
10
- export async function it_gen_generatePart(payload: WorkflowExecutionPayload, path: number[]) {
18
+ export async function it_gen_generatePart(
19
+ payload: WorkflowExecutionPayload,
20
+ path: number[],
21
+ ) {
11
22
  const vars = payload.vars as IterativeGenerationPayload;
12
- const client = getVertesiaClient(payload);
23
+ const client = await getVertesiaClient(payload);
13
24
  const memory = vars.memory;
14
25
 
15
26
  const [sectionIndex, partIndex] = path;
16
27
  const outMemory = await loadMemoryPack(client, `${memory}/output`);
17
- const meta = await outMemory.getMetadata() as OutputMemoryMeta;
28
+ const meta = (await outMemory.getMetadata()) as OutputMemoryMeta;
18
29
 
19
30
  // the section we build is the section at the given index
20
31
  const section: TocSection = meta.toc.sections[sectionIndex];
21
32
  if (!section) {
22
- throw ApplicationFailure.nonRetryable('Section not found in the TOC', 'SectionNotFound', { memory, path });
33
+ throw ApplicationFailure.nonRetryable(
34
+ "Section not found in the TOC",
35
+ "SectionNotFound",
36
+ { memory, path },
37
+ );
23
38
  }
24
39
  let part: TocPart | undefined;
25
40
  if (partIndex !== undefined) {
26
41
  part = section.parts?.[partIndex];
27
42
  if (!part) {
28
- throw ApplicationFailure.nonRetryable('Part not found in the TOC section', 'PartNotFound', { memory, path });
43
+ throw ApplicationFailure.nonRetryable(
44
+ "Part not found in the TOC section",
45
+ "PartNotFound",
46
+ { memory, path },
47
+ );
29
48
  }
30
49
  }
31
50
 
@@ -33,17 +52,26 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
33
52
 
34
53
  const content = await loadGeneratedContent(outMemory);
35
54
 
36
- let previously_generated = getPreviouslyGeneratedContent(content, !part, vars.remembrance_strategy);
55
+ let previously_generated = getPreviouslyGeneratedContent(
56
+ content,
57
+ !part,
58
+ vars.remembrance_strategy,
59
+ );
37
60
 
38
- if (!part) { // a new section
61
+ if (!part) {
62
+ // a new section
39
63
  content.push({
40
64
  id: section.id,
41
65
  name: section.name,
42
66
  description: section.description,
43
- content: ''
44
- })
67
+ content: "",
68
+ });
45
69
  } else if (!content.length) {
46
- throw ApplicationFailure.nonRetryable('content.json is empty while generating a part', 'InvalidIterationState', { memory, path });
70
+ throw ApplicationFailure.nonRetryable(
71
+ "content.json is empty while generating a part",
72
+ "InvalidIterationState",
73
+ { memory, path },
74
+ );
47
75
  }
48
76
 
49
77
  const interaction = vars.iterative_interaction || vars.interaction;
@@ -54,30 +82,42 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
54
82
  section: section.name,
55
83
  part: part?.name,
56
84
  path: path,
57
- }
85
+ },
58
86
  });
59
87
 
60
- const result = r.result.map(completionResultToString).join('\n');
88
+ const result = r.result.text();
61
89
  content[content.length - 1].content += result;
62
90
  meta.lastProcessedPart = path;
63
- await buildAndPublishMemoryPack(client, `${memory}/output`, async ({ copyText }) => {
64
- copyText(JSON.stringify(content, null, 2), "content.json");
65
- return meta;
66
- });
91
+ await buildAndPublishMemoryPack(
92
+ client,
93
+ `${memory}/output`,
94
+ async ({ copyText }) => {
95
+ copyText(JSON.stringify(content, null, 2), "content.json");
96
+ return meta;
97
+ },
98
+ );
67
99
  }
68
100
 
69
101
  async function loadGeneratedContent(memory: MemoryPack): Promise<Section[]> {
70
- const content = await memory.getEntryText('content.json');
102
+ const content = await memory.getEntryText("content.json");
71
103
  return content ? JSON.parse(content) : [];
72
104
  }
73
105
 
74
- function getPreviouslyGeneratedContent(sections: Section[], isNewSection: boolean, strategy?: "document" | "section" | "none"): string {
106
+ function getPreviouslyGeneratedContent(
107
+ sections: Section[],
108
+ isNewSection: boolean,
109
+ strategy?: "document" | "section" | "none",
110
+ ): string {
75
111
  switch (strategy) {
76
112
  case "document":
77
- return sections.map((section: Section) => section.content || '').join('\n\n');
113
+ return sections
114
+ .map((section: Section) => section.content || "")
115
+ .join("\n\n");
78
116
  case "none":
79
- return '';
117
+ return "";
80
118
  default:
81
- return isNewSection ? '' : sections[sections.length - 1]?.content || '';
119
+ return isNewSection
120
+ ? ""
121
+ : sections[sections.length - 1]?.content || "";
82
122
  }
83
- }
123
+ }
@@ -1,104 +1,116 @@
1
1
  import { WorkflowExecutionPayload } from "@vertesia/common";
2
2
  import { getVertesiaClient } from "../../utils/client.js";
3
3
  import { buildAndPublishMemoryPack } from "../../utils/memory.js";
4
- import { IterativeGenerationPayload, OutputMemoryMeta, Toc, TocIndex } from "../types.js";
4
+ import {
5
+ IterativeGenerationPayload,
6
+ OutputMemoryMeta,
7
+ Toc,
8
+ TocIndex,
9
+ } from "../types.js";
5
10
  import { executeWithVars, tocIndex } from "../utils.js";
6
- import { parseCompletionResultsToJson } from "@llumiverse/common";
7
11
 
8
12
  const defaultTocSchema = {
9
- "type": "object",
10
- "properties": {
11
- "sections": {
12
- "type": "array",
13
- "items": {
14
- "type": "object",
15
- "properties": {
16
- "id": {
17
- "type": "string",
18
- "description": "the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model."
13
+ type: "object",
14
+ properties: {
15
+ sections: {
16
+ type: "array",
17
+ items: {
18
+ type: "object",
19
+ properties: {
20
+ id: {
21
+ type: "string",
22
+ description:
23
+ "the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
19
24
  },
20
- "operation": {
21
- "type": "string",
22
- "enum": ["create", "update", "delete"],
23
- "description": "The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform."
25
+ operation: {
26
+ type: "string",
27
+ enum: ["create", "update", "delete"],
28
+ description:
29
+ "The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform.",
24
30
  },
25
- "name": {
26
- "type": "string",
27
- "description": "The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part."
31
+ name: {
32
+ type: "string",
33
+ description:
34
+ "The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part.",
28
35
  },
29
- "description": {
30
- "type": "string"
36
+ description: {
37
+ type: "string",
31
38
  },
32
- "instructions": {
33
- "type": "string"
39
+ instructions: {
40
+ type: "string",
34
41
  },
35
- "parts":
36
- {
37
- "type": "array",
38
- "description": "when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
39
- "items": {
40
- "type": "object",
41
- "properties": {
42
- "id": {
43
- "type": "string",
44
- "description": "the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model."
42
+ parts: {
43
+ type: "array",
44
+ description:
45
+ "when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
46
+ items: {
47
+ type: "object",
48
+ properties: {
49
+ id: {
50
+ type: "string",
51
+ description:
52
+ "the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
45
53
  },
46
- "name": {
47
- "type": "string",
48
- "description": "The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part."
54
+ name: {
55
+ type: "string",
56
+ description:
57
+ "The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part.",
49
58
  },
50
59
  /*
51
60
  "description": {
52
61
  "type": "string"
53
62
  },
54
63
  */
55
- "instructions": {
56
- "type": "string"
57
- }
64
+ instructions: {
65
+ type: "string",
66
+ },
58
67
  },
59
- "required": [
60
- "id",
61
- "name",
62
- ]
63
- }
64
- }
68
+ required: ["id", "name"],
69
+ },
70
+ },
65
71
  },
66
- "required": [
67
- "id",
68
- "name",
69
- "operation"
70
- ]
71
- }
72
- }
72
+ required: ["id", "name", "operation"],
73
+ },
74
+ },
73
75
  },
74
- "required": [
75
- "sections"
76
- ]
77
- }
76
+ required: ["sections"],
77
+ };
78
78
 
79
- export async function it_gen_generateToc(payload: WorkflowExecutionPayload): Promise<TocIndex> {
79
+ export async function it_gen_generateToc(
80
+ payload: WorkflowExecutionPayload,
81
+ ): Promise<TocIndex> {
80
82
  const vars = payload.vars as IterativeGenerationPayload;
81
83
 
82
84
  const schema = vars.toc_schema || defaultTocSchema;
83
85
 
84
- const client = getVertesiaClient(payload);
86
+ const client = await getVertesiaClient(payload);
85
87
 
86
- const run = await executeWithVars(client, vars.interaction, vars, undefined, schema);
88
+ const run = await executeWithVars(
89
+ client,
90
+ vars.interaction,
91
+ vars,
92
+ undefined,
93
+ schema,
94
+ );
87
95
 
88
96
  //Parse the CompletionResult[] to get a Toc object
89
- const jsonResults = parseCompletionResultsToJson(run.result);
97
+ const jsonResults = run.result.object();
90
98
 
91
99
  const toc: Toc = {
92
100
  sections: jsonResults.sections
93
101
  };
94
102
 
95
- await buildAndPublishMemoryPack(client, `${vars.memory}/output`, async () => {
96
- return {
97
- toc,
98
- lastProcessedPart: undefined, // the part index (a number array)
99
- previouslyGenerated: ""
100
- } satisfies OutputMemoryMeta
101
- });
103
+ await buildAndPublishMemoryPack(
104
+ client,
105
+ `${vars.memory}/output`,
106
+ async () => {
107
+ return {
108
+ toc,
109
+ lastProcessedPart: undefined, // the part index (a number array)
110
+ previouslyGenerated: "",
111
+ } satisfies OutputMemoryMeta;
112
+ },
113
+ );
102
114
 
103
115
  return tocIndex(toc);
104
116
  }
@@ -1,8 +1,7 @@
1
- import { VertesiaClient } from "@vertesia/client";
2
- import { ExecutionRun } from "@vertesia/common";
1
+ import { ModelOptions, TextFallbackOptions } from "@llumiverse/common";
3
2
  import { ApplicationFailure } from "@temporalio/workflow";
3
+ import { VertesiaClient } from "@vertesia/client";
4
4
  import { OutputMemoryMeta, PartIndex, Toc, TocIndex, TocSection } from "./types.js";
5
- import { ModelOptions, TextFallbackOptions } from "@llumiverse/common";
6
5
 
7
6
  //TODO: For whole file, support for options beyond max_tokens and temperature and multiple modalities.
8
7
  export interface ExecuteOptions {
@@ -15,7 +14,7 @@ export interface ExecuteOptions {
15
14
  result_schema?: Record<string, any>;
16
15
  }
17
16
 
18
- export async function execute(client: VertesiaClient, options: ExecuteOptions): Promise<ExecutionRun> {
17
+ export async function execute(client: VertesiaClient, options: ExecuteOptions) {
19
18
  return client.interactions.executeByName(options.interaction, {
20
19
  data: {
21
20
  ...options.memory_mapping,
@@ -30,7 +29,7 @@ export async function execute(client: VertesiaClient, options: ExecuteOptions):
30
29
  });
31
30
  }
32
31
 
33
- export function executeWithVars(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun> {
32
+ export function executeWithVars(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>) {
34
33
  if (mapping) {
35
34
  mapping = { ...vars.input_mapping, ...mapping };
36
35
  } else {
@@ -14,7 +14,9 @@ export async function fetchBlobAsStream(client: VertesiaClient, blobUri: string)
14
14
  } catch (err: any) {
15
15
  if (err.message.includes("not found")) {
16
16
  //TODO improve error handling with a fetch fail error class in the client
17
- throw new DocumentNotFoundError(`Failed to download blob ${blobUri}: ${err.message}`, []);
17
+ throw new DocumentNotFoundError(`Not found at ${blobUri}: ${err.message}`, []);
18
+ } else if (err.message.includes("forbidden")) {
19
+ throw new DocumentNotFoundError(`Forbidden at ${blobUri}: ${err.message}`);
18
20
  } else {
19
21
  throw new Error(`Failed to download blob ${blobUri}: ${err.message}`);
20
22
  }
@@ -2,31 +2,45 @@
2
2
  * get a zeno client for a given token
3
3
  */
4
4
 
5
- import { VertesiaClient } from "@vertesia/client";
5
+ import {
6
+ decodeJWT,
7
+ VertesiaClient,
8
+ VertesiaClientProps,
9
+ } from "@vertesia/client";
6
10
  import { WorkflowExecutionBaseParams } from "@vertesia/common";
7
11
  import { WorkflowParamNotFoundError } from "../errors.js";
8
12
 
9
-
10
13
  export function getVertesiaClient(payload: WorkflowExecutionBaseParams) {
11
14
  return new VertesiaClient(getVertesiaClientOptions(payload));
12
15
  }
13
16
 
14
- export function getVertesiaClientOptions(payload: WorkflowExecutionBaseParams) {
17
+ export function getVertesiaClientOptions(
18
+ payload: WorkflowExecutionBaseParams,
19
+ ): VertesiaClientProps {
15
20
  if (!payload.auth_token) {
16
- throw new WorkflowParamNotFoundError("Authentication Token is missing from WorkflowExecutionPayload.authToken");
21
+ throw new WorkflowParamNotFoundError(
22
+ "Authentication Token is missing from WorkflowExecutionPayload.authToken",
23
+ );
17
24
  }
18
25
 
19
26
  if (!payload.config?.studio_url) {
20
- throw new WorkflowParamNotFoundError("Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl");
27
+ throw new WorkflowParamNotFoundError(
28
+ "Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
29
+ );
21
30
  }
22
31
 
23
32
  if (!payload.config?.store_url) {
24
- throw new WorkflowParamNotFoundError("Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl");
33
+ throw new WorkflowParamNotFoundError(
34
+ "Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl",
35
+ );
25
36
  }
26
37
 
38
+ const token = decodeJWT(payload.auth_token);
39
+
27
40
  return {
28
41
  serverUrl: payload.config.studio_url,
29
42
  storeUrl: payload.config.store_url,
30
- apikey: payload.auth_token
43
+ tokenServerUrl: token.iss,
44
+ apikey: payload.auth_token,
31
45
  };
32
- }
46
+ }