@faces-sh/cli 1.0.2 → 1.0.3

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.
@@ -19,9 +19,18 @@ export default class ConversationItems extends BaseCommand {
19
19
  async run() {
20
20
  const { args, flags } = await this.parse(ConversationItems);
21
21
  const client = this.makeClient(flags);
22
- let data;
22
+ const all = [];
23
+ let premises;
23
24
  try {
24
- data = (await client.get(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}/items`));
25
+ let after = '';
26
+ for (;;) {
27
+ const page = (await client.get(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}/items?order=asc&limit=100${after ? `&after=${encodeURIComponent(after)}` : ''}`));
28
+ all.push(...(page.data ?? []));
29
+ premises = page.premises ?? premises;
30
+ if (!page.has_more || !page.last_id)
31
+ break;
32
+ after = page.last_id;
33
+ }
25
34
  }
26
35
  catch (err) {
27
36
  if (err instanceof FacesAPIError) {
@@ -30,8 +39,10 @@ export default class ConversationItems extends BaseCommand {
30
39
  }
31
40
  throw err;
32
41
  }
42
+ const data = { object: 'list', data: all, first_id: all[0]?.id ?? null, last_id: all.at(-1)?.id ?? null,
43
+ has_more: false, premises };
33
44
  if (!this.jsonEnabled()) {
34
- const items = data.data ?? [];
45
+ const items = data.data;
35
46
  if (items.length === 0)
36
47
  this.log('No items yet.');
37
48
  for (const line of itemLines(items))
@@ -157,7 +157,7 @@ function parsed(raw) {
157
157
  }
158
158
  }
159
159
  function questionText(q) {
160
- return String(q.instructions ?? q.question ?? q.id ?? '?');
160
+ return String(q.instructions ?? q.question ?? q.name ?? q.id ?? '?');
161
161
  }
162
162
  function choiceOf(out) {
163
163
  if (out.choice !== undefined && out.choice !== null)
@@ -182,6 +182,15 @@ export function itemLines(items) {
182
182
  calls.set(String(it.call_id ?? ''), it);
183
183
  continue;
184
184
  }
185
+ if (it.type === 'decision') {
186
+ const answer = (it.answer && typeof it.answer === 'object' ? it.answer : {});
187
+ const question = (it.question && typeof it.question === 'object' ? it.question : {});
188
+ const result = answer.result === undefined || answer.result === null ? '-' : String(answer.result);
189
+ lines.push(`${head}${String(it.face ?? 'face')}${it.model ? ` (${it.model})` : ''} decided: ${questionText(question)} -> ${result}`);
190
+ if (typeof it.cause === 'string' && it.cause)
191
+ lines.push(`${pad}cause: ${it.cause}`);
192
+ continue;
193
+ }
185
194
  if (it.type === 'function_call_output') {
186
195
  const call = calls.get(String(it.call_id ?? ''));
187
196
  const out = parsed(it.output);