create-scout9 1.0.0-alpha.0.0.13 → 1.0.0-alpha.0.0.14

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.
@@ -1,11 +1,11 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\n/**\n * @param {import('@scout9/app').WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\n/**\n * @param {import('@scout9/app').WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || !!event.context === 'pizza') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
5
5
  },
6
6
  {
7
7
  "name": "src/entities/agents/index.js",
8
- "contents": "/**\n * Required core entity type: Agents represents you and your team\n * @returns {Array<import('@scout9/app').Agent>}\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
8
+ "contents": "/**\n * Required core entity type: Agents represents you and your team\n * @returns {Array<import('@scout9/app').Agent>}\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Patrick',\n lastName: 'Opie',\n forwardPhone: '+15555555555',\n context: 'helps customers with placing their pizza orders',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
20
- "contents": "// import { EntityRootConfiguration } from '../../../platform/src/runtime/client/entity';\n\n// export type DeliveryMethod = {\n// deliveryMethod: 'pickup' | 'delivery';\n// }\n\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n * @returns {IEntityBuildConfig}\n */\nexport default function () {\n return {\n definitions: [\n {\n value: 'delivery',\n text: [\n 'delivery',\n 'deliver',\n 'delivered',\n 'dropped off',\n 'drop off',\n ]\n },\n {\n value: 'pickup',\n text: [\n 'pickup',\n 'pick this one up',\n 'pick up',\n ]\n },\n ],\n training:\n [\n ...[\n 'I\\'ll have my order %delivery_method%',\n 'I\\'ll do a %delivery_method% order',\n '%delivery_method% please',\n ].map((text) => ({text, intent: 'delivery_method'})),\n ],\n tests: [\n {\n text: 'drop off order please',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'delivery'\n }\n },\n },\n {\n text: 'I\\'ll pick this one up',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'pickup'\n }\n },\n }\n ],\n }\n}\n"
20
+ "contents": "\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n * @returns {IEntityBuildConfig}\n */\nexport default async function delivery_methodEntity() {\n return {\n \"definitions\": [\n {\n \"value\": \"delivery\",\n \"text\": [\n \"delivery\",\n \"deliver\",\n \"delivered\",\n \"dropped off\",\n \"drop off\"\n ]\n },\n {\n \"value\": \"pickup\",\n \"text\": [\n \"pickup\",\n \"pick this one up\",\n \"pick up\"\n ]\n }\n ],\n \"training\": [\n {\n \"text\": \"I'll have my order %delivery_method%\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"I'll do a %delivery_method% order\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"%delivery_method% please\",\n \"intent\": \"delivery_method\"\n }\n ],\n \"tests\": [\n {\n \"text\": \"drop off order please\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"delivery\"\n }\n ]\n }\n },\n {\n \"text\": \"I'll pick this one up\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"pickup\"\n }\n ]\n }\n }\n ]\n };\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/entities/pizza/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "name": "src/index.js",
28
- "contents": "/**\n * Configuration for the Scout9 project.\n * @type {import('@scout9/app').Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
28
+ "contents": "/**\n * Configuration for the Scout9 project.\n * @type {import('@scout9/app').Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n organization: {\n name: \"PizzaZoom\",\n description: \"PizzaZoom is a pizza delivery service that uses drones to deliver pizza to your door in 30 minutes or less.\",\n },\n initialContext: [\n \"Get the customers pizza order, be as brief and concise as possible.\",\n \"Customers generally want the pizza ASAP, so assume unless they ask for a specific time, they want it as soon as possible.\",\n ]\n}\n"
29
29
  },
30
30
  {
31
31
  "name": "src/lib/customer-db.js",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  {
39
39
  "name": "src/lib/invoice.js",
40
- "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
40
+ "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
41
41
  },
42
42
  {
43
43
  "name": "src/workflows/pizzaOrder/workflow.js",
44
- "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.js';\nimport { createInvoice, getInvoice } from '../../lib/invoice.js';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n * @param {import('@scout9/app').WorkflowEvent} event - the workflow event that every workflow must have\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - the response that every workflow must return\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.deliveryMethod) {\n return {\n instructions: `Determine if ${customer?.firstName || 'the customer'} is doing a delivery or pickup and determine time of pickup/delivery`\n };\n }\n\n if (!context.invoiceId) {\n const invoice = await createInvoice(context.pizza);\n return {\n instructions: `Send invoice to customer`,\n message: `Order created - $${(invoice.total/100).toFixed(2)} you can pay at ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.deliveryMethod === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.deliveryMethod === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n return {\n forward: true\n }\n}\n"
44
+ "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.mjs';\nimport { createInvoice, getInvoice } from '../../lib/invoice.mjs';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n * @param {import('@scout9/app').WorkflowEvent} event - the workflow event that every workflow must have\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - the response that every workflow must return\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.delivery_method === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.delivery_method === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
@@ -1,11 +1,11 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || !!event.context === 'pizza') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
5
5
  },
6
6
  {
7
7
  "name": "src/entities/agents/index.js",
8
- "contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
8
+ "contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Patrick',\n lastName: 'Opie',\n forwardPhone: '+15555555555',\n context: 'helps customers with placing their pizza orders',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
20
- "contents": "// import { EntityRootConfiguration } from '../../../platform/src/runtime/client/entity';\n\n// export type DeliveryMethod = {\n// deliveryMethod: 'pickup' | 'delivery';\n// }\n\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n */\nexport default function () {\n return {\n definitions: [\n {\n value: 'delivery',\n text: [\n 'delivery',\n 'deliver',\n 'delivered',\n 'dropped off',\n 'drop off',\n ]\n },\n {\n value: 'pickup',\n text: [\n 'pickup',\n 'pick this one up',\n 'pick up',\n ]\n },\n ],\n training:\n [\n ...[\n 'I\\'ll have my order %delivery_method%',\n 'I\\'ll do a %delivery_method% order',\n '%delivery_method% please',\n ].map((text) => ({text, intent: 'delivery_method'})),\n ],\n tests: [\n {\n text: 'drop off order please',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'delivery'\n }\n },\n },\n {\n text: 'I\\'ll pick this one up',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'pickup'\n }\n },\n }\n ],\n }\n}\n"
20
+ "contents": "\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n */\nexport default async function delivery_methodEntity() {\n return {\n \"definitions\": [\n {\n \"value\": \"delivery\",\n \"text\": [\n \"delivery\",\n \"deliver\",\n \"delivered\",\n \"dropped off\",\n \"drop off\"\n ]\n },\n {\n \"value\": \"pickup\",\n \"text\": [\n \"pickup\",\n \"pick this one up\",\n \"pick up\"\n ]\n }\n ],\n \"training\": [\n {\n \"text\": \"I'll have my order %delivery_method%\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"I'll do a %delivery_method% order\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"%delivery_method% please\",\n \"intent\": \"delivery_method\"\n }\n ],\n \"tests\": [\n {\n \"text\": \"drop off order please\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"delivery\"\n }\n ]\n }\n },\n {\n \"text\": \"I'll pick this one up\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"pickup\"\n }\n ]\n }\n }\n ]\n };\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/entities/pizza/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "name": "src/index.js",
28
- "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
28
+ "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n organization: {\n name: \"PizzaZoom\",\n description: \"PizzaZoom is a pizza delivery service that uses drones to deliver pizza to your door in 30 minutes or less.\",\n },\n initialContext: [\n \"Get the customers pizza order, be as brief and concise as possible.\",\n \"Customers generally want the pizza ASAP, so assume unless they ask for a specific time, they want it as soon as possible.\",\n ]\n}\n"
29
29
  },
30
30
  {
31
31
  "name": "src/lib/customer-db.js",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  {
39
39
  "name": "src/lib/invoice.js",
40
- "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
40
+ "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
41
41
  },
42
42
  {
43
43
  "name": "src/workflows/pizzaOrder/workflow.js",
44
- "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.js';\nimport { createInvoice, getInvoice } from '../../lib/invoice.js';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.deliveryMethod) {\n return {\n instructions: `Determine if ${customer?.firstName || 'the customer'} is doing a delivery or pickup and determine time of pickup/delivery`\n };\n }\n\n if (!context.invoiceId) {\n const invoice = await createInvoice(context.pizza);\n return {\n instructions: `Send invoice to customer`,\n message: `Order created - $${(invoice.total/100).toFixed(2)} you can pay at ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.deliveryMethod === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.deliveryMethod === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n return {\n forward: true\n }\n}\n"
44
+ "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.mjs';\nimport { createInvoice, getInvoice } from '../../lib/invoice.mjs';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.delivery_method === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.delivery_method === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
@@ -1,11 +1,11 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || !!event.context === 'pizza') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
5
5
  },
6
6
  {
7
7
  "name": "src/entities/agents/index.js",
8
- "contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
8
+ "contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Patrick',\n lastName: 'Opie',\n forwardPhone: '+15555555555',\n context: 'helps customers with placing their pizza orders',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
20
- "contents": "// import { EntityRootConfiguration } from '../../../platform/src/runtime/client/entity';\n\n// export type DeliveryMethod = {\n// deliveryMethod: 'pickup' | 'delivery';\n// }\n\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n */\nexport default function () {\n return {\n definitions: [\n {\n value: 'delivery',\n text: [\n 'delivery',\n 'deliver',\n 'delivered',\n 'dropped off',\n 'drop off',\n ]\n },\n {\n value: 'pickup',\n text: [\n 'pickup',\n 'pick this one up',\n 'pick up',\n ]\n },\n ],\n training:\n [\n ...[\n 'I\\'ll have my order %delivery_method%',\n 'I\\'ll do a %delivery_method% order',\n '%delivery_method% please',\n ].map((text) => ({text, intent: 'delivery_method'})),\n ],\n tests: [\n {\n text: 'drop off order please',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'delivery'\n }\n },\n },\n {\n text: 'I\\'ll pick this one up',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'pickup'\n }\n },\n }\n ],\n }\n}\n"
20
+ "contents": "\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n */\nexport default async function delivery_methodEntity() {\n return {\n \"definitions\": [\n {\n \"value\": \"delivery\",\n \"text\": [\n \"delivery\",\n \"deliver\",\n \"delivered\",\n \"dropped off\",\n \"drop off\"\n ]\n },\n {\n \"value\": \"pickup\",\n \"text\": [\n \"pickup\",\n \"pick this one up\",\n \"pick up\"\n ]\n }\n ],\n \"training\": [\n {\n \"text\": \"I'll have my order %delivery_method%\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"I'll do a %delivery_method% order\",\n \"intent\": \"delivery_method\"\n },\n {\n \"text\": \"%delivery_method% please\",\n \"intent\": \"delivery_method\"\n }\n ],\n \"tests\": [\n {\n \"text\": \"drop off order please\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"delivery\"\n }\n ]\n }\n },\n {\n \"text\": \"I'll pick this one up\",\n \"expected\": {\n \"intent\": \"delivery_method\",\n \"context\": [\n {\n \"delivery_method\": \"pickup\"\n }\n ]\n }\n }\n ]\n };\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/entities/pizza/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "name": "src/index.js",
28
- "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
28
+ "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n organization: {\n name: \"PizzaZoom\",\n description: \"PizzaZoom is a pizza delivery service that uses drones to deliver pizza to your door in 30 minutes or less.\",\n },\n initialContext: [\n \"Get the customers pizza order, be as brief and concise as possible.\",\n \"Customers generally want the pizza ASAP, so assume unless they ask for a specific time, they want it as soon as possible.\",\n ]\n}\n"
29
29
  },
30
30
  {
31
31
  "name": "src/lib/customer-db.js",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  {
39
39
  "name": "src/lib/invoice.js",
40
- "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
40
+ "contents": "/**\n * An example service of creating and retrieving an invoice\n */\nexport async function createInvoice(pizza) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n\nexport async function getInvoice(id) {\n // @TODO create invoice backend\n return {\n id: 'invoice-123',\n subtotal: 6000,\n tax: 600,\n total: 6600,\n invoiceUrl: 'https://example.com/invoice-123'\n };\n}\n"
41
41
  },
42
42
  {
43
43
  "name": "src/workflows/pizzaOrder/workflow.js",
44
- "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.js';\nimport { createInvoice, getInvoice } from '../../lib/invoice.js';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.deliveryMethod) {\n return {\n instructions: `Determine if ${customer?.firstName || 'the customer'} is doing a delivery or pickup and determine time of pickup/delivery`\n };\n }\n\n if (!context.invoiceId) {\n const invoice = await createInvoice(context.pizza);\n return {\n instructions: `Send invoice to customer`,\n message: `Order created - $${(invoice.total/100).toFixed(2)} you can pay at ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.deliveryMethod === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.deliveryMethod === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n return {\n forward: true\n }\n}\n"
44
+ "contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.mjs';\nimport { createInvoice, getInvoice } from '../../lib/invoice.mjs';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.delivery_method === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.delivery_method === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
- "contents": "/**\n * Configuration for the Scout9 project.\n * @type {import('@scout9/app').Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
20
+ "contents": "/**\n * Configuration for the Scout9 project.\n * @type {import('@scout9/app').Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n initialContext: [\n ]\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/lib/customer-db.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
- "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
20
+ "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n initialContext: [\n ]\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/lib/customer-db.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
- "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
20
+ "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n initialContext: [\n ]\n}\n"
21
21
  },
22
22
  {
23
23
  "name": "src/lib/customer-db.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-scout9",
3
- "version": "1.0.0-alpha.0.0.13",
3
+ "version": "1.0.0-alpha.0.0.14",
4
4
  "bin": "./bin.js",
5
5
  "main": "./index.js",
6
6
  "publishConfig": {