@n1k1t/pipelain 0.4.13 → 0.4.15

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 (79) hide show
  1. package/README.md +34 -2
  2. package/assets/report/index.hbs +123 -55
  3. package/assets/report/main.css +13 -0
  4. package/cli/index.ts +77 -0
  5. package/lib/src/models/content/factory.d.ts +7 -1
  6. package/lib/src/models/content/factory.d.ts.map +1 -1
  7. package/lib/src/models/content/factory.js +15 -0
  8. package/lib/src/models/content/factory.js.map +1 -1
  9. package/lib/src/models/content/kinds/article.d.ts +3 -1
  10. package/lib/src/models/content/kinds/article.d.ts.map +1 -1
  11. package/lib/src/models/content/kinds/article.js +7 -0
  12. package/lib/src/models/content/kinds/article.js.map +1 -1
  13. package/lib/src/models/content/kinds/attachment.d.ts +3 -1
  14. package/lib/src/models/content/kinds/attachment.d.ts.map +1 -1
  15. package/lib/src/models/content/kinds/attachment.js +7 -0
  16. package/lib/src/models/content/kinds/attachment.js.map +1 -1
  17. package/lib/src/models/content/kinds/group.d.ts +3 -1
  18. package/lib/src/models/content/kinds/group.d.ts.map +1 -1
  19. package/lib/src/models/content/kinds/group.js +7 -0
  20. package/lib/src/models/content/kinds/group.js.map +1 -1
  21. package/lib/src/models/content/kinds/model.d.ts +5 -0
  22. package/lib/src/models/content/kinds/model.d.ts.map +1 -1
  23. package/lib/src/models/content/kinds/model.js +6 -0
  24. package/lib/src/models/content/kinds/model.js.map +1 -1
  25. package/lib/src/models/content/kinds/plain.d.ts +3 -1
  26. package/lib/src/models/content/kinds/plain.d.ts.map +1 -1
  27. package/lib/src/models/content/kinds/plain.js +7 -0
  28. package/lib/src/models/content/kinds/plain.js.map +1 -1
  29. package/lib/src/models/content/kinds/rules.d.ts +3 -1
  30. package/lib/src/models/content/kinds/rules.d.ts.map +1 -1
  31. package/lib/src/models/content/kinds/rules.js +7 -0
  32. package/lib/src/models/content/kinds/rules.js.map +1 -1
  33. package/lib/src/models/content/kinds/sources.d.ts +3 -1
  34. package/lib/src/models/content/kinds/sources.d.ts.map +1 -1
  35. package/lib/src/models/content/kinds/sources.js +7 -0
  36. package/lib/src/models/content/kinds/sources.js.map +1 -1
  37. package/lib/src/models/content/kinds/tasks.d.ts +3 -1
  38. package/lib/src/models/content/kinds/tasks.d.ts.map +1 -1
  39. package/lib/src/models/content/kinds/tasks.js +7 -0
  40. package/lib/src/models/content/kinds/tasks.js.map +1 -1
  41. package/lib/src/models/llm/providers/google.d.ts.map +1 -1
  42. package/lib/src/models/llm/providers/google.js +8 -1
  43. package/lib/src/models/llm/providers/google.js.map +1 -1
  44. package/lib/src/models/llm/providers/model.d.ts +4 -1
  45. package/lib/src/models/llm/providers/model.d.ts.map +1 -1
  46. package/lib/src/models/llm/providers/model.js +4 -0
  47. package/lib/src/models/llm/providers/model.js.map +1 -1
  48. package/lib/src/models/pipeline/report/types.d.ts +3 -3
  49. package/lib/src/models/pipeline/report/types.d.ts.map +1 -1
  50. package/lib/src/models/pipeline/session.d.ts +4 -13
  51. package/lib/src/models/pipeline/session.d.ts.map +1 -1
  52. package/lib/src/models/pipeline/session.js.map +1 -1
  53. package/lib/src/models/pipeline/steps/ai/actions/fallback.d.ts +30 -0
  54. package/lib/src/models/pipeline/steps/ai/actions/fallback.d.ts.map +1 -0
  55. package/lib/src/models/pipeline/steps/ai/actions/fallback.js +48 -0
  56. package/lib/src/models/pipeline/steps/ai/actions/fallback.js.map +1 -0
  57. package/lib/src/models/pipeline/steps/ai/actions/index.d.ts +1 -0
  58. package/lib/src/models/pipeline/steps/ai/actions/index.d.ts.map +1 -1
  59. package/lib/src/models/pipeline/steps/ai/actions/index.js +1 -0
  60. package/lib/src/models/pipeline/steps/ai/actions/index.js.map +1 -1
  61. package/lib/src/models/pipeline/steps/ai/actions/model.d.ts +1 -3
  62. package/lib/src/models/pipeline/steps/ai/actions/model.d.ts.map +1 -1
  63. package/lib/src/models/pipeline/steps/ai/actions/model.js +1 -2
  64. package/lib/src/models/pipeline/steps/ai/actions/model.js.map +1 -1
  65. package/lib/src/models/pipeline/steps/ai/actions/reasoning.js +1 -1
  66. package/lib/src/models/pipeline/steps/ai/actions/reasoning.js.map +1 -1
  67. package/lib/src/models/pipeline/steps/ai/actions/tool.js +1 -1
  68. package/lib/src/models/pipeline/steps/ai/actions/tool.js.map +1 -1
  69. package/lib/src/models/pipeline/steps/ai/index.d.ts +2 -1
  70. package/lib/src/models/pipeline/steps/ai/index.d.ts.map +1 -1
  71. package/lib/src/models/pipeline/steps/ai/index.js +104 -89
  72. package/lib/src/models/pipeline/steps/ai/index.js.map +1 -1
  73. package/lib/src/models/pipeline/steps/ai/types.d.ts +3 -0
  74. package/lib/src/models/pipeline/steps/ai/types.d.ts.map +1 -1
  75. package/lib/src/models/pipeline/steps/swarm.d.ts +13 -6
  76. package/lib/src/models/pipeline/steps/swarm.d.ts.map +1 -1
  77. package/lib/src/models/pipeline/steps/swarm.js +39 -18
  78. package/lib/src/models/pipeline/steps/swarm.js.map +1 -1
  79. package/package.json +13 -12
package/README.md CHANGED
@@ -158,6 +158,10 @@ Used to create structured prompt content. These methods are available via `utils
158
158
  | `file(title, path)` | Reads a local file and attaches it as context. | `await utils.content.file('Config', 'package.json')` |
159
159
  | `glob(title, pattern)` | Reads multiple files by pattern and attaches them. | `await utils.content.glob('Source', 'src/**/*.ts')` |
160
160
  | `plain(text)` | Adds raw markdown text. | `utils.content.plain('### Subtitle\nText')` |
161
+ | `user(content)` | Forces content to be placed into the `user` message. | `utils.content.user('Say hi')` |
162
+ | `system(content)` | Forces content to be placed into the `system` message. | `utils.content.system('You are a helpful assistant')` |
163
+
164
+ Each content kind has a default location it is rendered into (`tasks` and plain strings default to `user`, everything else defaults to `system`). Wrap any content in `utils.content.user()` / `utils.content.system()` to override that placement explicitly.
161
165
 
162
166
  ### `factory.tools` (LlmToolsFactory)
163
167
  Used to provide tools to the AI. These methods are available via `factory.tools` in pipeline steps.
@@ -389,12 +393,14 @@ const pipeline = PipelineCompiler
389
393
 
390
394
  ### Parallel Execution with `swarm`
391
395
 
392
- Use `swarm` to execute multiple AI tasks in parallel. You can define subtasks using the `subtasks` method:
396
+ Use `swarm` to execute multiple AI tasks in parallel. You can define subtasks as a `list` (array) or as a `map` (keyed object), optionally limiting how many run concurrently with `.limit()`.
397
+
398
+ #### `list`
393
399
 
394
400
  ```ts
395
401
  .step('analysis', ({ factory }) => factory
396
402
  .swarm('Parallel Analysis')
397
- .subtasks([
403
+ .list([
398
404
  factory
399
405
  .ai('Sentiment Analysis')
400
406
  .schema(z.object({ score: z.number() }))
@@ -410,6 +416,32 @@ Use `swarm` to execute multiple AI tasks in parallel. You can define subtasks us
410
416
  // Results will be available in context.state.analysis as an array of PromiseSettledResult
411
417
  ```
412
418
 
419
+ > `subtasks(...)` is a deprecated alias of `list(...)` kept for backward compatibility — prefer `list`.
420
+
421
+ #### `map`
422
+
423
+ Use `map` when you need to address each subtask result by name instead of by array index:
424
+
425
+ ```ts
426
+ .step('analysis', ({ factory }) => factory
427
+ .swarm('Parallel Analysis')
428
+ .map({
429
+ sentiment: factory
430
+ .ai('Sentiment Analysis')
431
+ .schema(z.object({ score: z.number() }))
432
+ .prompt(({ context }) => [`Analyze sentiment of: ${context.input}`]),
433
+
434
+ keywords: factory
435
+ .ai('Keyword Extraction')
436
+ .schema(z.object({ tags: z.array(z.string()) }))
437
+ .prompt(({ context }) => [`Extract keywords from: ${context.input}`]),
438
+ })
439
+ .limit(2) // Optional: limit parallel executions
440
+ )
441
+ // context.state.analysis.sentiment -> PromiseSettledResult<{ score: number }>
442
+ // context.state.analysis.keywords -> PromiseSettledResult<{ tags: string[] }>
443
+ ```
444
+
413
445
  ### Iterative Execution with `loop`
414
446
 
415
447
  Use `loop` for tasks that require multiple iterations or validation, such as self-correction:
@@ -167,85 +167,153 @@
167
167
  {{#if (eq type "ai:tool")}}
168
168
  <span class="action-type-badge badge-tool">TOOL</span>
169
169
  <span class="action-name text-mono">{{name}}</span>
170
+ {{else if (eq type "ai:fallback")}}
171
+ <span class="action-type-badge badge-fallback">FALLBACK</span>
172
+ <span class="action-name text-mono">{{llm.old.model}}</span>
170
173
  {{else}}
171
174
  <span class="action-type-badge badge-reasoning">REASONING</span>
172
175
  {{/if}}
173
176
  </div>
174
177
  <div class="summary-right">
175
- <span class="llm-tag text-muted">{{llm.name}}/{{llm.model}}</span>
176
- <span class="badge badge-{{meta.state}}">{{meta.state}}</span>
177
- <span class="time-tag">{{formatDuration meta.spent}}</span>
178
+ {{#if (eq type "ai:fallback")}}
179
+ <span class="badge badge-error">{{error.type}}</span>
180
+ {{else}}
181
+ <span class="llm-tag text-muted">{{llm.name}}/{{llm.model}}</span>
182
+ <span class="badge badge-{{meta.state}}">{{meta.state}}</span>
183
+ <span class="time-tag">{{formatDuration meta.spent}}</span>
184
+ {{/if}}
178
185
  </div>
179
186
  </summary>
180
187
 
181
188
  <div class="action-content">
182
- <!-- Action LLM & Details -->
183
- <div class="io-title">Info</div>
184
- <div class="action-meta-grid">
185
- <div class="meta-row">
186
- <span class="meta-label">Model:</span>
187
- <span class="meta-value text-mono">{{llm.name}}/{{llm.model}}</span>
188
- </div>
189
- {{#if id}}
189
+ {{#if (eq type "ai:fallback")}}
190
+ <!-- Fallback LLM Info -->
191
+ <div class="io-title">Transition</div>
192
+ <div class="action-meta-grid">
190
193
  <div class="meta-row">
191
- <span class="meta-label">Action ID:</span>
192
- <span class="meta-value text-mono">{{id}}</span>
194
+ <span class="meta-label">From:</span>
195
+ <span class="meta-value text-mono">{{llm.old.name}}/{{llm.old.model}}</span>
193
196
  </div>
194
- {{/if}}
195
- </div>
197
+ <div class="meta-row">
198
+ <span class="meta-label">To:</span>
199
+ <span class="meta-value text-mono">{{llm.new.name}}/{{llm.new.model}}</span>
200
+ </div>
201
+ </div>
196
202
 
197
- <!-- Tool Input/Output -->
198
- {{#if (eq type "ai:tool")}}
199
- <div class="action-io">
200
- <div class="io-block">
201
- <div class="io-title">Input ({{input.type}})</div>
202
- <pre><code class="{{#if (eq input.type "json")}}language-json{{/if}}">{{#if (eq input.type "json")}}{{json input.value}}{{else}}{{input.value}}{{/if}}</code></pre>
203
+ <!-- Fallback Reason -->
204
+ <div class="io-title">Reason</div>
205
+ <div class="error-box error-box-fallback">
206
+ <div class="error-header">
207
+ <svg class="error-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
208
+ <circle cx="12" cy="12" r="10" />
209
+ <line x1="12" y1="8" x2="12" y2="12" />
210
+ <line x1="12" y1="16" x2="12.01" y2="16" />
211
+ </svg>
212
+ <span class="error-type">{{error.type}}</span>
203
213
  </div>
214
+ <div class="error-message">{{error.reason}}</div>
215
+ </div>
216
+
217
+ <div class="io-title">Previous Provider</div>
218
+ <div class="action-meta-grid">
219
+ {{#if llm.old.parameters}}
220
+ <div class="span-all">
221
+ <span class="meta-label">Parameters:</span>
222
+ <pre><code class="language-json">{{json llm.old.parameters}}</code></pre>
223
+ </div>
224
+ {{/if}}
225
+ {{#if llm.old.options}}
226
+ <div class="span-all">
227
+ <span class="meta-label">Options:</span>
228
+ <pre><code class="language-json">{{json llm.old.options}}</code></pre>
229
+ </div>
230
+ {{/if}}
231
+ </div>
204
232
 
205
- {{#if output}}
206
- <div class="io-block {{#if (eq output.type "error")}}io-error{{/if}}">
207
- <div class="io-title">Output ({{output.type}})</div>
208
- {{#if (eq output.type "error")}}
209
- <div class="error-output">
210
- <pre><code>{{#if (eq output.value.type "json")}}{{json output.value.payload}}{{else}}{{output.value.payload}}{{/if}}</code></pre>
211
- </div>
212
- {{else}}
213
- <pre><code class="{{#if (eq output.type "json")}}language-json{{/if}}">{{#if (eq output.type "json")}}{{json output.value}}{{else}}{{output.value}}{{/if}}</code></pre>
214
- {{/if}}
233
+ <div class="io-title">fallback Provider</div>
234
+ <div class="action-meta-grid">
235
+ {{#if llm.new.parameters}}
236
+ <div class="span-all">
237
+ <span class="meta-label">Parameters:</span>
238
+ <pre><code class="language-json">{{json llm.new.parameters}}</code></pre>
239
+ </div>
240
+ {{/if}}
241
+ {{#if llm.new.options}}
242
+ <div class="span-all">
243
+ <span class="meta-label">Options:</span>
244
+ <pre><code class="language-json">{{json llm.new.options}}</code></pre>
215
245
  </div>
216
246
  {{/if}}
217
247
  </div>
218
248
  {{else}}
219
- <!-- Reasoning Output -->
220
- <div class="action-io">
221
- <div class="io-block">
222
- <div class="io-title">Reasoning Output</div>
223
- <pre class="reasoning-output"><code>{{output}}</code></pre>
249
+ <!-- Action LLM & Details -->
250
+ <div class="io-title">Info</div>
251
+ <div class="action-meta-grid">
252
+ <div class="meta-row">
253
+ <span class="meta-label">Model:</span>
254
+ <span class="meta-value text-mono">{{llm.name}}/{{llm.model}}</span>
224
255
  </div>
256
+ {{#if id}}
257
+ <div class="meta-row">
258
+ <span class="meta-label">Action ID:</span>
259
+ <span class="meta-value text-mono">{{id}}</span>
260
+ </div>
261
+ {{/if}}
225
262
  </div>
226
- {{/if}}
227
263
 
228
- <div class="io-title">Provider</div>
229
- <div class="action-meta-grid">
230
- {{#if llm.parameters}}
231
- <div class="span-all">
232
- <span class="meta-label">Parameters:</span>
233
- <pre><code class="language-json">{{json llm.parameters}}</code></pre>
234
- </div>
235
- {{/if}}
236
- {{#if llm.options}}
237
- <div class="span-all">
238
- <span class="meta-label">Options:</span>
239
- <pre><code class="language-json">{{json llm.options}}</code></pre>
264
+ <!-- Tool Input/Output -->
265
+ {{#if (eq type "ai:tool")}}
266
+ <div class="action-io">
267
+ <div class="io-block">
268
+ <div class="io-title">Input ({{input.type}})</div>
269
+ <pre><code class="{{#if (eq input.type "json")}}language-json{{/if}}">{{#if (eq input.type "json")}}{{json input.value}}{{else}}{{input.value}}{{/if}}</code></pre>
270
+ </div>
271
+
272
+ {{#if output}}
273
+ <div class="io-block {{#if (eq output.type "error")}}io-error{{/if}}">
274
+ <div class="io-title">Output ({{output.type}})</div>
275
+ {{#if (eq output.type "error")}}
276
+ <div class="error-output">
277
+ <pre><code>{{#if (eq output.value.type "json")}}{{json output.value.payload}}{{else}}{{output.value.payload}}{{/if}}</code></pre>
278
+ </div>
279
+ {{else}}
280
+ <pre><code class="{{#if (eq output.type "json")}}language-json{{/if}}">{{#if (eq output.type "json")}}{{json output.value}}{{else}}{{output.value}}{{/if}}</code></pre>
281
+ {{/if}}
282
+ </div>
283
+ {{/if}}
240
284
  </div>
241
- {{/if}}
242
- {{#if trace}}
243
- <div class="span-all">
244
- <span class="meta-label">Trace Metadata:</span>
245
- <pre><code class="language-json">{{json trace}}</code></pre>
285
+ {{else}}
286
+ <!-- Reasoning Output -->
287
+ <div class="action-io">
288
+ <div class="io-block">
289
+ <div class="io-title">Reasoning Output</div>
290
+ <pre class="reasoning-output"><code>{{output}}</code></pre>
291
+ </div>
246
292
  </div>
247
293
  {{/if}}
248
- </div>
294
+
295
+ <div class="io-title">Provider</div>
296
+ <div class="action-meta-grid">
297
+ {{#if llm.parameters}}
298
+ <div class="span-all">
299
+ <span class="meta-label">Parameters:</span>
300
+ <pre><code class="language-json">{{json llm.parameters}}</code></pre>
301
+ </div>
302
+ {{/if}}
303
+ {{#if llm.options}}
304
+ <div class="span-all">
305
+ <span class="meta-label">Options:</span>
306
+ <pre><code class="language-json">{{json llm.options}}</code></pre>
307
+ </div>
308
+ {{/if}}
309
+ {{#if trace}}
310
+ <div class="span-all">
311
+ <span class="meta-label">Trace Metadata:</span>
312
+ <pre><code class="language-json">{{json trace}}</code></pre>
313
+ </div>
314
+ {{/if}}
315
+ </div>
316
+ {{/if}}
249
317
  </div>
250
318
  </details>
251
319
  {{/each}}
@@ -274,6 +274,11 @@ details[open] > summary .expand-arrow {
274
274
  color: var(--color-reasoning);
275
275
  }
276
276
 
277
+ .badge-fallback {
278
+ background: var(--color-warning-bg);
279
+ color: var(--color-warning);
280
+ }
281
+
277
282
  /* Tags */
278
283
  .llm-tag, .usage-tag, .time-tag, .duration-tag {
279
284
  font-size: 12px;
@@ -350,6 +355,10 @@ details[open] > summary .expand-arrow {
350
355
  border-left: 3px solid var(--color-reasoning);
351
356
  }
352
357
 
358
+ .action-card.action-type-ai\:fallback {
359
+ border-left: 3px solid var(--color-warning);
360
+ }
361
+
353
362
  .action-summary {
354
363
  padding: 10px 20px;
355
364
  font-size: 14px;
@@ -470,6 +479,10 @@ code {
470
479
  gap: 10px;
471
480
  }
472
481
 
482
+ .error-box-fallback {
483
+ margin-bottom: 20px;
484
+ }
485
+
473
486
  .error-header {
474
487
  display: flex;
475
488
  align-items: center;
package/cli/index.ts ADDED
@@ -0,0 +1,77 @@
1
+ import { Command, program } from 'commander';
2
+ import fs from 'fs/promises';
3
+
4
+ import { PipelineCompiler, Project, stdout, TLlmProviderReasoning } from '../src';
5
+ import { cast } from '../src/utils';
6
+
7
+ program
8
+ .description('PipelAIn')
9
+ .addCommand(
10
+ new Command()
11
+ .command('exec')
12
+ .description('Executes prompt/pipeline by provided params')
13
+ .option('-p --prompt <text>', 'User prompt text')
14
+ .option('-s --silent [boolean]', 'Hides logs of pipeline execution', false)
15
+ .option('-o --output [path]', 'Output file path')
16
+ .option('-l --limit [number]', 'Tool calls limit')
17
+ .option('-r --reasoning [level]', 'Reasoning level', cast<TLlmProviderReasoning>('provider-default'))
18
+ .option('--system [text]', 'System prompt text')
19
+ .option('--cwd [path]', 'Working directory', process.cwd())
20
+ .action(async (options: {
21
+ reasoning: TLlmProviderReasoning;
22
+ silent: boolean;
23
+ prompt: string;
24
+ cwd: string;
25
+
26
+ system?: string;
27
+ output?: string;
28
+ limit?: string;
29
+ }) => {
30
+ const pipeline = PipelineCompiler
31
+ .build('Executor')
32
+ .step('output', ({ factory }) => factory
33
+ .ai('Execution')
34
+ .llm(({ context }) =>
35
+ context.llm.assign({
36
+ reasoning: options.reasoning,
37
+ tools: factory.tools.all().provide(),
38
+
39
+ ...(options.limit && { limit: Number(options.limit) }),
40
+ })
41
+ )
42
+ .prompt(({ utils }) => [
43
+ utils.content.system(options.system ?? ''),
44
+ utils.content.user(options.prompt),
45
+ ])
46
+ );
47
+
48
+ const project = await Project.build({ cwd: options.cwd });
49
+ const compiled = await pipeline.compile({
50
+ project,
51
+ stdout: options.silent ? undefined : stdout.console,
52
+ });
53
+
54
+ const result = await compiled.run();
55
+
56
+ if (options.output) {
57
+ await fs.writeFile(options.output, result.output, 'utf8');
58
+ }
59
+ if (!options.silent) {
60
+ console.log('\n');
61
+ }
62
+
63
+ process.stdout.write(result.output);
64
+ process.exit(0);
65
+ })
66
+ )
67
+ .addCommand(
68
+ new Command()
69
+ .command('serve')
70
+ .description('Starts server')
71
+ .option('-h --host [host]', 'Host address', 'localhost')
72
+ .option('-p --port [port]', 'Port', '8080')
73
+ .action(async (input, command) => {
74
+
75
+ })
76
+ )
77
+ .parse();
@@ -1,4 +1,4 @@
1
- import { TContentType } from './kinds/model';
1
+ import { Content, TContentType } from './kinds/model';
2
2
  import { SetPartialKeys } from '../../../types';
3
3
  import { IJsonContent } from './types';
4
4
  import { Project } from '../project';
@@ -25,7 +25,13 @@ export declare class ContentFactory {
25
25
  sources(list: kinds.SourcesContent['TSchema']): kinds.SourcesContent;
26
26
  /** Creates plain markdown */
27
27
  plain(payload: string): kinds.PlainContent;
28
+ /** Creates attachment that will be placed into virtual file system */
28
29
  attachment(title: string, payload: Omit<SetPartialKeys<kinds.AttachmentContent['TSchema'], 'extension' | 'key'>, 'title'>): kinds.AttachmentContent;
30
+ /** Creates content that will be placed into `user` messages */
31
+ user(predicate: string | Content | (string | Content)[]): kinds.GroupContent;
32
+ /** Creates content that will be placed into `system` messages */
33
+ system(predicate: string | Content | (string | Content)[]): kinds.GroupContent;
34
+ /** Reads file and puts it as attachemnt into virtual file system */
29
35
  file(title: string, location: string | string[]): Promise<kinds.AttachmentContent>;
30
36
  /** Reads files by pattern and creates attachments for each file */
31
37
  glob(title: string, pattern: string): Promise<kinds.GroupContent>;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/models/content/factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,YAAY,EAAE,MAAM,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AAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAW/F,mEAAmE;IACtD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC;IAyB9E,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc;IAI/C,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC;CAGzF"}
@@ -40,6 +40,7 @@ exports.ContentFactory = void 0;
40
40
  const path_1 = __importDefault(require("path"));
41
41
  const promises_1 = __importDefault(require("fs/promises"));
42
42
  const fast_glob_1 = __importDefault(require("fast-glob"));
43
+ const lodash_1 = __importDefault(require("lodash"));
43
44
  const model_1 = require("./kinds/model");
44
45
  const file_1 = require("../file");
45
46
  const kinds = __importStar(require("./kinds"));
@@ -69,9 +70,23 @@ class ContentFactory {
69
70
  plain(payload) {
70
71
  return kinds.PlainContent.build(payload);
71
72
  }
73
+ /** Creates attachment that will be placed into virtual file system */
72
74
  attachment(title, payload) {
73
75
  return kinds.AttachmentContent.build({ title, ...payload });
74
76
  }
77
+ /** Creates content that will be placed into `user` messages */
78
+ user(predicate) {
79
+ return kinds.GroupContent.build(lodash_1.default.flatMap([predicate]).map((segment) => segment instanceof model_1.Content
80
+ ? segment.relocate('user')
81
+ : kinds.PlainContent.build(segment).relocate('user')));
82
+ }
83
+ /** Creates content that will be placed into `system` messages */
84
+ system(predicate) {
85
+ return kinds.GroupContent.build(lodash_1.default.flatMap([predicate]).map((segment) => segment instanceof model_1.Content
86
+ ? segment.relocate('system')
87
+ : kinds.PlainContent.build(segment).relocate('system')));
88
+ }
89
+ /** Reads file and puts it as attachemnt into virtual file system */
75
90
  async file(title, location) {
76
91
  const file = await file_1.File.build(location, { cwd: this.project?.cwd });
77
92
  return kinds.AttachmentContent.build({
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/models/content/factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2DAA6B;AAC7B,0DAA2B;AAE3B,yCAAsD;AAItD,kCAA+B;AAE/B,+CAAiC;AAYjC,MAAa,cAAc;IACzB,YAAsB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAK3C,+CAA+C;IACxC,OAAO,CACZ,iBAA2D,EAC3D,OAAwB;QAExB,OAAO,OAAO,iBAAiB,KAAK,QAAQ;YAC1C,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YAClF,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED,yBAAyB;IAClB,KAAK,CAAC,IAAc;QACzB,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,yBAAyB;IAClB,KAAK,CAAC,IAAc;QACzB,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,iCAAiC;IAC1B,OAAO,CAAC,IAAqC;QAClD,OAAO,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,6BAA6B;IACtB,KAAK,CAAC,OAAe;QAC1B,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAEM,UAAU,CACf,KAAa,EACb,OAA+F;QAE/F,OAAO,KAAK,CAAC,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,CAAC,KAAK,CAAC;YACnC,KAAK;YAEL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,mEAAmE;IAC5D,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,OAAe;QAC9C,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAE,EAAC,OAAO,CAAC,CAAC;QAEhC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC7B,SAAS,EAAE,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YACjC,IAAI,EAAE,QAAQ;YAEd,OAAO,EAAE,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC7C,CAAC,CAAC,CACJ,CAAC;QAEF,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACjB,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAC5B,KAAK;YAEL,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CACH,CACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAiB;QAC5B,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,EAAE,CAAyB,IAAO,EAAE,OAAgB;QACzD,OAAO,OAAO,YAAY,eAAO,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7D,CAAC;CACF;AA/GD,wCA+GC"}
@@ -1,12 +1,14 @@
1
+ import { Content, TContentLocation } from './model';
1
2
  import { IJsonContent } from '../types';
2
- import { Content } from './model';
3
3
  export declare class ArticleContent extends Content<'article', {
4
4
  title: string;
5
5
  content: IJsonContent[];
6
6
  /** Markdown tag for the title */
7
7
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'b';
8
8
  }> {
9
+ location: TContentLocation;
9
10
  render(): string;
11
+ clone(): ArticleContent;
10
12
  static build(payload: ArticleContent['TSchema']): ArticleContent;
11
13
  }
12
14
  //# sourceMappingURL=article.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/article.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,qBAAa,cAAe,SAAQ,OAAO,CAAC,SAAS,EAAE;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB,iCAAiC;IACjC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC;CAC9C,CAAC;IACO,MAAM,IAAI,MAAM;IAQvB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,cAAc;CAGjE"}
1
+ {"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/article.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,cAAe,SAAQ,OAAO,CAAC,SAAS,EAAE;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB,iCAAiC;IACjC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC;CAC9C,CAAC;IACO,QAAQ,EAAE,gBAAgB,CAAY;IAEtC,MAAM,IAAI,MAAM;IAQhB,KAAK,IAAI,cAAc;IAI9B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,cAAc;CAGjE"}
@@ -8,10 +8,17 @@ const json2md_1 = __importDefault(require("json2md"));
8
8
  const model_1 = require("./model");
9
9
  const utils_1 = require("../../../utils");
10
10
  class ArticleContent extends model_1.Content {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.location = 'system';
14
+ }
11
15
  render() {
12
16
  const tag = this.payload.tag ?? 'h3';
13
17
  return (0, json2md_1.default)((0, utils_1.cast)([{ [tag]: this.payload.title }, ...this.payload.content])).trim();
14
18
  }
19
+ clone() {
20
+ return ArticleContent.build(this.payload);
21
+ }
15
22
  static build(payload) {
16
23
  return new ArticleContent('article', payload);
17
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"article.js","sourceRoot":"","sources":["../../../../../src/models/content/kinds/article.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAG9B,mCAAkC;AAClC,0CAAsC;AAEtC,MAAa,cAAe,SAAQ,eAMlC;IACO,MAAM;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;QAErC,OAAO,IAAA,iBAAO,EACZ,IAAA,YAAI,EAAiB,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAC/E,CAAC,IAAI,EAAE,CAAC;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAkC;QAC7C,OAAO,IAAI,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AAlBD,wCAkBC"}
1
+ {"version":3,"file":"article.js","sourceRoot":"","sources":["../../../../../src/models/content/kinds/article.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAE9B,mCAAoD;AAEpD,0CAAsC;AAEtC,MAAa,cAAe,SAAQ,eAMlC;IANF;;QAOS,aAAQ,GAAqB,QAAQ,CAAC;IAiB/C,CAAC;IAfQ,MAAM;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;QAErC,OAAO,IAAA,iBAAO,EACZ,IAAA,YAAI,EAAiB,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAC/E,CAAC,IAAI,EAAE,CAAC;IACX,CAAC;IAEM,KAAK;QACV,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAkC;QAC7C,OAAO,IAAI,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AAxBD,wCAwBC"}
@@ -1,5 +1,5 @@
1
+ import { Content, TContentLocation } from './model';
1
2
  import { SetPartialKeys } from '../../../../types';
2
- import { Content } from './model';
3
3
  export declare class AttachmentContent extends Content<'attachment', {
4
4
  content: unknown;
5
5
  title: string;
@@ -7,7 +7,9 @@ export declare class AttachmentContent extends Content<'attachment', {
7
7
  /** File extension with dot (`.json`, `.md` and etc) */
8
8
  extension?: string;
9
9
  }> {
10
+ location: TContentLocation;
10
11
  render(): string;
12
+ clone(): AttachmentContent;
11
13
  static build(payload: SetPartialKeys<AttachmentContent['TSchema'], 'key'>): AttachmentContent;
12
14
  }
13
15
  //# sourceMappingURL=attachment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/attachment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,YAAY,EAAE;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IAEZ,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;IACO,MAAM,IAAI,MAAM;IAMvB,MAAM,CAAC,KAAK,CACV,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,GAC3D,iBAAiB;CAWrB"}
1
+ {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/attachment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,YAAY,EAAE;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IAEZ,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;IACO,QAAQ,EAAE,gBAAgB,CAAY;IAEtC,MAAM,IAAI,MAAM;IAMhB,KAAK,IAAI,iBAAiB;IAIjC,MAAM,CAAC,KAAK,CACV,OAAO,EAAE,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,GAC3D,iBAAiB;CAWrB"}
@@ -7,11 +7,18 @@ exports.AttachmentContent = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const model_1 = require("./model");
9
9
  class AttachmentContent extends model_1.Content {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.location = 'system';
13
+ }
10
14
  render() {
11
15
  return lodash_1.default.isObject(this.payload.content)
12
16
  ? JSON.stringify(this.payload.content, null, 2)
13
17
  : String(this.payload.content);
14
18
  }
19
+ clone() {
20
+ return AttachmentContent.build(this.payload);
21
+ }
15
22
  static build(payload) {
16
23
  const extension = payload.extension ?? (lodash_1.default.isObject(payload.content) ? '.json' : undefined);
17
24
  return new AttachmentContent('attachment', {
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../../../src/models/content/kinds/attachment.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,mCAAkC;AAElC,MAAa,iBAAkB,SAAQ,eAOrC;IACO,MAAM;QACX,OAAO,gBAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/C,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,KAAK,CACV,OAA4D;QAE5D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE3F,OAAO,IAAI,iBAAiB,CAAC,YAAY,EAAE;YACzC,SAAS;YAET,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,IAAI,EAAE,EAAE;SACpF,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,8CA2BC"}
1
+ {"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../../../src/models/content/kinds/attachment.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,mCAAoD;AAGpD,MAAa,iBAAkB,SAAQ,eAOrC;IAPF;;QAQS,aAAQ,GAAqB,QAAQ,CAAC;IAyB/C,CAAC;IAvBQ,MAAM;QACX,OAAO,gBAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/C,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,KAAK;QACV,OAAO,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CACV,OAA4D;QAE5D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE3F,OAAO,IAAI,iBAAiB,CAAC,YAAY,EAAE;YACzC,SAAS;YAET,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,IAAI,EAAE,EAAE;SACpF,CAAC,CAAC;IACL,CAAC;CACF;AAjCD,8CAiCC"}
@@ -1,7 +1,9 @@
1
- import { Content } from './model';
1
+ import { Content, TContentLocation } from './model';
2
2
  export declare class GroupContent extends Content<'group', Content[]> {
3
3
  render(): string;
4
4
  flat(): Content[];
5
+ relocate(location: TContentLocation): this;
6
+ clone(): GroupContent;
5
7
  static build(payload: GroupContent['TSchema']): GroupContent;
6
8
  }
7
9
  //# sourceMappingURL=group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,qBAAa,YAAa,SAAQ,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;IACpD,MAAM,IAAI,MAAM;IAIhB,IAAI,IAAI,OAAO,EAAE;IAWxB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY;CAG7D"}
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../../src/models/content/kinds/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEpD,qBAAa,YAAa,SAAQ,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;IACpD,MAAM,IAAI,MAAM;IAIhB,IAAI,IAAI,OAAO,EAAE;IAWjB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAK1C,KAAK,IAAI,YAAY;IAI5B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY;CAG7D"}
@@ -15,6 +15,13 @@ class GroupContent extends model_1.Content {
15
15
  return acc;
16
16
  }, []);
17
17
  }
18
+ relocate(location) {
19
+ this.payload.forEach((content) => content.relocate(location));
20
+ return this;
21
+ }
22
+ clone() {
23
+ return GroupContent.build(this.payload);
24
+ }
18
25
  static build(payload) {
19
26
  return new GroupContent('group', payload);
20
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"group.js","sourceRoot":"","sources":["../../../../../src/models/content/kinds/group.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAElC,MAAa,YAAa,SAAQ,eAA2B;IACpD,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAA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AC,QAA0B;QACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK;QACV,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAgC;QAC3C,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF;AA5BD,oCA4BC"}
@@ -1,10 +1,15 @@
1
1
  export type TContentType = 'attachment' | 'article' | 'tasks' | 'rules' | 'sources' | 'group' | 'plain';
2
+ export type TContentLocation = 'system' | 'user';
2
3
  export declare abstract class Content<K extends TContentType = TContentType, TSchema = unknown> {
3
4
  type: K;
4
5
  payload: TSchema;
5
6
  TSchema: TSchema;
7
+ location?: TContentLocation;
6
8
  constructor(type: K, payload: TSchema);
7
9
  /** Renders content to string */
8
10
  abstract render(): string;
11
+ abstract clone(): Content<K, TSchema>;
12
+ /** Creates clone and redefines prompt content location */
13
+ relocate(location: TContentLocation): this;
9
14
  }
10
15
  //# sourceMappingURL=model.d.ts.map