agentlang 0.0.40 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/language/generated/ast.d.ts +57 -21
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +80 -26
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.d.ts.map +1 -1
- package/out/language/generated/grammar.js +337 -115
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +398 -135
- package/out/language/main.cjs.map +2 -2
- package/out/runtime/agents/common.d.ts +2 -1
- package/out/runtime/agents/common.d.ts.map +1 -1
- package/out/runtime/agents/common.js +49 -1
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/agents/registry.js +3 -1
- package/out/runtime/agents/registry.js.map +1 -1
- package/out/runtime/auth/cognito.js +1 -1
- package/out/runtime/defs.d.ts +1 -0
- package/out/runtime/defs.d.ts.map +1 -1
- package/out/runtime/defs.js +1 -0
- package/out/runtime/defs.js.map +1 -1
- package/out/runtime/interpreter.d.ts +5 -0
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +77 -8
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +89 -37
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +1 -1
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +10 -3
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts +13 -0
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +80 -9
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/runtime/modules/core.d.ts +1 -0
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +15 -5
- package/out/runtime/modules/core.js.map +1 -1
- package/out/syntaxes/agentlang.monarch.js +3 -3
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/package.json +1 -1
- package/src/language/agentlang.langium +12 -4
- package/src/language/generated/ast.ts +144 -49
- package/src/language/generated/grammar.ts +337 -115
- package/src/runtime/agents/common.ts +50 -1
- package/src/runtime/agents/registry.ts +3 -3
- package/src/runtime/auth/cognito.ts +3 -3
- package/src/runtime/defs.ts +1 -0
- package/src/runtime/interpreter.ts +122 -8
- package/src/runtime/loader.ts +98 -37
- package/src/runtime/module.ts +13 -3
- package/src/runtime/modules/ai.ts +102 -11
- package/src/runtime/modules/auth.ts +6 -1
- package/src/runtime/modules/core.ts +16 -4
- package/src/syntaxes/agentlang.monarch.ts +3 -3
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const PlannerInstructions = "Agentlang is a very-high-level declarative language that makes it easy to define business applications as 'models'.\nThe model of a business application consists of entity definitions and workflows defined in \"modules\". \nA module is be encoded in a syntax inspired by JavaScript and JSON. Example of a simple module follows:\n\nmodule Erp\n\nentity Employee {\n employeeId UUID @id @default(uuid()),\n firstName String,\n lastName String,\n salary Number,\n email Email @indexed\n}\n\nThe Empoyee entity is part of the \"Erp\" module and it has four attributes: 'employeeId', 'firstName', 'lastName', 'salary' and 'email'. \nThe 'employeeId' attribute uniquely identifies an instance of the Employee entity and it's automatically filled-in by the system by calling the \"uuid()\" function. \nIn the place of the keyword 'entity', the keyword 'record' may also be used. The difference between an entity and a record is that, \ninstances of an entity is persisted to the database, instances of records are not.\n\nThis is an example of a record:\n\nrecord EmailMessage {\n to Email,\n from Email,\n subject String,\n body String\n}\n\nAnother major construct in Agentlang is the 'workflow'. Workflows contains JSON \"patterns\" that perform CRUD operations on entities. \nFor example, here's is a workflow that creates a new instance of the Employee entity:\n\nworkflow CreateEmployee {\n {Erp/Employee {firstName CreateEmployee.firstName,\n lastName CreateEmployee.lastName,\n salary CreateEmployee.salary,\n email CreateEmployee.email}}\n}\n\nThe attribute-values of the new Employee are derived from the \"event\" that triggers the workflow. In this example the event is called \"CreateEmployee\".\nAn event need not have an explicit schema, because its attributes can always be inferred from the workflow definition. But a model may also contain\nexplicit definitions of events, as follows,\n\nevent CreateEmployee {\n firstName String,\n lastName String,\n salary Number,\n email Email\n}\n\nA workflow attached to an event is invoked by creating an instance of the event, e.g:\n\n{Erp/CreateEmployee {firstName \"Sam\", lastName \"K\", salary 1400, email \"samk@acme.com\"}}\n\nThis means a workflow can be invoked from another workflow, simply by having the event-creation pattern.\n\nOther than the create-pattern for entities and events, some of the most useful patterns (related to entities) that can appear in a workflow are:\n1. Query - e.g: '{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"}}'. The attributes by which the query happens must end with a '?' character.\n To lookup all instances of an entity, use the syntax: '{EntityName?: {}}'.\n2. Update - e.g: '{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\", firstName \"Joe\"}}'. This pattern updates the firstName of the employee\n with the given employeeId.\n3. Upsert - e.g: '{Erp/Employee {employeeId \"56392e13-0d9a-42f7-b556-0d7cd9468a24\", firstName \"Joe\"}, @upsert}'. The 'upsert' pattern will create a new\n instance, if the instance does not already exist.\n4. Delete - e.g: 'delete {Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"}}'\n\nThe default query operator is '=' (equals). So an expression like 'employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"' means,\n'where employeeId equals \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"'. Other comparison operators has to be specified explicitly, as in\n'{age?< 50}' - which means 'where age less-than 50'. The comparison operators supported by a query pattern are:\n\n= - equals\n!= - not-equals\n< - less-than\n<= - less-than or equals\n> - greater-than\n>= - greater-than or equals\nin - membership check (argument must be an array)\nlike - string-ends-with?\nbetween - between given values (argument must be an array)\n\nTwo comparison expressions can be combined together by the logical operators 'or' and 'and'. The comparison and logical expressions produce a boolean\nresult, represented by 'true' or 'false'. A boolean value can be inversed by using the 'not' expression, e.g: 'not(some-value)'\n\nIn addition to the basic CRUD patterns, you can execute conditional-logic with the help of the 'if' pattern. An example follows,\n\nworkflow IncrementSalary {\n if (IncrementSalary.percentage > 10) {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + salary * IncrementSalary.percentage}}\n } else {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + 1500}}\n }\n}\n\nNote the value passed to the 'salary' attribute - it's an arithmetic expression. All normal arithmetic expressions are supported by workflow patterns.\n\nAnother example of the 'if' pattern:\n\nworkflow validateLicense {\n {checkLicenseNumber {number validateLicense.number}} @as response;\n if (response = \"ok\") {\n {license {number? validateLicense.number, status \"active\"}}\n } else {\n {license {number? validateLicense.number, status \"canceled\"}}\n }\n}\n\nAlso note the use of the '@as' keyword - this binds the result of a pattern to an 'alias'.\n\nA successful query pattern will return an array of instances. The 'for' pattern can be used to iterate over an array. An example follows:\n\nworkflow NotifyEmployees {\n {Erp/Employee {salary?> 1000}} @as employees;\n for emp in employees {\n {Erp/SendMail {email emp.email, body \"You are selected for an increment!\"}}\n }\n}\n\nHere the result of the query is bound to the alias named 'employees'. Any pattern can have an alias, including 'if' and 'for'. An alias can be used to refer to the attributes of the instance, \nvia the dot(.) notation. Aliases can also be used to destructure a query result - here's an example:\n\nworkflow FindFirstTwoEmployees {\n {Erp/Employee {salary?> 1000}} @as [emp1, emp2];\n [emp1, emp2]\n}\n\nThis alias will bind the first two instances to 'a' and 'b' and the rest of the instances to an array named 'xs':\n\n{SomeEntity {id?> 1}} @as [a, b, _, xs]\n\nExamples of binding aliases to 'if' and 'for':\n\nif (IncrementSalary.percentage > 10) {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + salary * IncrementSalary.percentage}}\n} else {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + 1500}}\n} @as emp\n\nfor emp in employees {\n {Erp/SendMail {email emp.email, body \"You are selected for an increment!\"}}\n} @as emails\n\nMake sure all references based on a preceding pattern is based either on an actual alias or the name of the workflow. For example, the following sequence of patterns\nare invalid, because the alias 'employee' is not defined:\n\n{Employee {id? 101}};\n{SendEmail {to employee.email, body \"hello\"}}\n\nA fix for the reference-error is shown below:\n\n{Employee {id? 101}} @as [employee];\n{SendEmail {to employee.email, body \"hello\"}}\n\nNote that the alias for the query is '[employee]' so that the resultset is destructured to select exactly one instance of Employee \nselected into the reference. You must follow this pattern if your goal is to select exactly a single instance.\n\nKeep in mind that the only valid syntax for the 'if' condition is:\n\nif (<expr>) {\n <patterns>\n} else if (<expr>) {\n <patterns>\n} else {\n <patterns>\n}\n\nThe following usage is NOT valid:\n\n<pattern> if (<expr>)\n\nA pattern may execute asynchronously and its eventual result can be handled by patterns provided in the '@then' clause. An example is shown below:\n\n{sendChatMessage {to \"amy\", \"text\" \"hello\"}} @as response @then {\n {saveResponse {from \"amy\", \"text\" response}}\n}\n\nIf you are instructed that a particular event will be called asynchronously, always provide the patterns that follows in its '@then' clause. You must add the \n'@then' clause only if an event's documentation or instruction explicitly requires to do so.\n\nEntities in a module can be connected together in relationships. There are two types of relationships - 'contains' and 'between'.\n'Contains' relationship is for hierarchical data, as in a Library entity containing Books. 'Between' relationship is for graph-like data,\nlike two Profiles in a social media app is connected as friends. A 'between' relationship can be one of the following three types - 'one_one' (one-to-one),\n'one_many' (one-to-many) and 'many_many' (many-to-many), which is the default.\n\nThe following example shows how additional profile data for an employee could be defined as a new entity and attached to the Employee entity as a between-relationship:\n\nentity Profile {\n id UUID @id @default(uuid()),\n address String @optional,\n photo URL @optional,\n dateOfBirth DateTime @optional\n}\n\nrelationship EmployeeProfile between (Erp/Employee, Erp/Profile) @one_one\n\nThe '@one_one' annotation means exactly one Employee and Profile can be related to each other via 'EmployeeProfile'.\n\nHere's the 'CreateEmployee' workflow updated to create the Employee with the his/her Profile attached:\n\nworkflow CreateEmployee {\n {Erp/Employee {firstName CreateEmployee.firstName,\n lastName CreateEmployee.lastName,\n salary CreateEmployee.salary,\n email CreateEmployee.email},\n Erp/EmployeeProfile {Erp/Profile {address CreateEmployee.address,\n photo CreateEmployee.photo,\n dateOfBirth CreateEmployee.dateOfBirth}}}\n}\n\nThe following pattern can be user to query an Employee along with his Profile:\n\n{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"},\n Erp/EmployeeProfile {Erp/Profile? {}}}\n\nAs an example of 'contains' relaionships, consider modelling task-assignments for an Employee as folllows:\n\nentity TaskAssignment {\n id UUID @id @default(uuid()),\n description String,\n assignmentDate DateTime @default(now())\n}\n\nrelationship EmployeeTaskAssignment contains (Erp/Employee, Erp/TaskAssignment)\n\nThe following workflow shows how to assign a new task to an Employee:\n\nworkflow AssignNewTask {\n {Erp/Employee {employeeId? AssignNewTask.employeeId},\n Erp/EmployeeTaskAssignment {Erp/TaskAssignment {description AssignNewTask.description}}}\n}\n\nThe following workflow queries an Employee along with all his tasks:\n\nworkflow GetEmployeeTaskAssignments {\n {Erp/Employee {employeeId? GetEmployeeTaskAssignments.employeeId},\n Erp/EmployeeTaskAssignment {Erp/TaskAssignment? {}}}\n}\n\nA general rule regarding generating workflows - as much as possible, do not include references to the workflow event in the patterns. Try to\nfill-in values from the available context. For example, if your instruction is \"create a workflow to send an email to employee 101 with this message - \n'please call me as soon as possible'\", the best workflow to return is:\n\nworkflow sendEmail {\n {employee {id? 101}} @as emp;\n {email {to emp.email body \"please call me as soon as possible\"}}\n}\n\nbecause all the information needed is available in the context. If the instruction is \"create a workflow to send an email by employee-id with this message - \n'please call me as soon as possible'\", then you can return:\n\nworkflow sendEmail {\n {employee {id? sendEmail.employeeId}} @as emp;\n {email {to emp.email body \"please call me as soon as possible\"}}\n}\n\nThe point is use the immediate context to fill-in values in generated patterns, as much as possible.\n\nAlso generate a workflow only if required explicitly by the user or the contextual information is incomplete. Otherwise, just return an array of patterns.\nAs an example, if the user request is \"send an email to employee 101 with this message - 'please call me as soon as possible'\", you must return:\n\n[{employee {id? 101}} @as emp;\n {email {to emp.email, body \"please call me as soon as possible\"}}]\n\nYou MUST separate each pattern in the array with a semi-colon (;) and never use a comma (,) for this purpose.\n\nNow consider the following module definition and generate appropriate patterns in response to the user instructions. You must return only valid patterns or workflows,\nno other descriptive text or comments are needed.\n";
|
|
1
|
+
export declare const PlannerInstructions = "Agentlang is a very-high-level declarative language that makes it easy to define business applications as 'models'.\nThe model of a business application consists of entity definitions and workflows defined in \"modules\". \nA module is be encoded in a syntax inspired by JavaScript and JSON. Example of a simple module follows:\n\nmodule Erp\n\nentity Employee {\n employeeId UUID @id @default(uuid()),\n firstName String,\n lastName String,\n salary Number,\n email Email @indexed\n}\n\nThe Empoyee entity is part of the \"Erp\" module and it has four attributes: 'employeeId', 'firstName', 'lastName', 'salary' and 'email'. \nThe 'employeeId' attribute uniquely identifies an instance of the Employee entity and it's automatically filled-in by the system by calling the \"uuid()\" function. \nIn the place of the keyword 'entity', the keyword 'record' may also be used. The difference between an entity and a record is that, \ninstances of an entity is persisted to the database, instances of records are not.\n\nThis is an example of a record:\n\nrecord EmailMessage {\n to Email,\n from Email,\n subject String,\n body String\n}\n\nAnother major construct in Agentlang is the 'workflow'. Workflows contains JSON \"patterns\" that perform CRUD operations on entities. \nFor example, here's is a workflow that creates a new instance of the Employee entity:\n\nworkflow CreateEmployee {\n {Erp/Employee {firstName CreateEmployee.firstName,\n lastName CreateEmployee.lastName,\n salary CreateEmployee.salary,\n email CreateEmployee.email}}\n}\n\nThe attribute-values of the new Employee are derived from the \"event\" that triggers the workflow. In this example the event is called \"CreateEmployee\".\nAn event need not have an explicit schema, because its attributes can always be inferred from the workflow definition. But a model may also contain\nexplicit definitions of events, as follows,\n\nevent CreateEmployee {\n firstName String,\n lastName String,\n salary Number,\n email Email\n}\n\nA workflow attached to an event is invoked by creating an instance of the event, e.g:\n\n{Erp/CreateEmployee {firstName \"Sam\", lastName \"K\", salary 1400, email \"samk@acme.com\"}}\n\nThis means a workflow can be invoked from another workflow, simply by having the event-creation pattern.\n\nOther than the create-pattern for entities and events, some of the most useful patterns (related to entities) that can appear in a workflow are:\n1. Query - e.g: '{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"}}'. The attributes by which the query happens must end with a '?' character.\n To lookup all instances of an entity, use the syntax: '{EntityName?: {}}'.\n2. Update - e.g: '{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\", firstName \"Joe\"}}'. This pattern updates the firstName of the employee\n with the given employeeId.\n3. Upsert - e.g: '{Erp/Employee {employeeId \"56392e13-0d9a-42f7-b556-0d7cd9468a24\", firstName \"Joe\"}, @upsert}'. The 'upsert' pattern will create a new\n instance, if the instance does not already exist.\n4. Delete - e.g: 'delete {Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"}}'\n\nThe default query operator is '=' (equals). So an expression like 'employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"' means,\n'where employeeId equals \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"'. Other comparison operators has to be specified explicitly, as in\n'{age?< 50}' - which means 'where age less-than 50'. The comparison operators supported by a query pattern are:\n\n= - equals\n!= - not-equals\n< - less-than\n<= - less-than or equals\n> - greater-than\n>= - greater-than or equals\nin - membership check (argument must be an array)\nlike - string-ends-with?\nbetween - between given values (argument must be an array)\n\nTwo comparison expressions can be combined together by the logical operators 'or' and 'and'. The comparison and logical expressions produce a boolean\nresult, represented by 'true' or 'false'. A boolean value can be inversed by using the 'not' expression, e.g: 'not(some-value)'\n\nIn addition to the basic CRUD patterns, you can execute conditional-logic with the help of the 'if' pattern. An example follows,\n\nworkflow IncrementSalary {\n if (IncrementSalary.percentage > 10) {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + salary * IncrementSalary.percentage}}\n } else {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + 1500}}\n }\n}\n\nNote the value passed to the 'salary' attribute - it's an arithmetic expression. All normal arithmetic expressions are supported by workflow patterns.\n\nAnother example of the 'if' pattern:\n\nworkflow validateLicense {\n {checkLicenseNumber {number validateLicense.number}} @as response;\n if (response = \"ok\") {\n {license {number? validateLicense.number, status \"active\"}}\n } else {\n {license {number? validateLicense.number, status \"canceled\"}}\n }\n}\n\nAlso note the use of the '@as' keyword - this binds the result of a pattern to an 'alias'.\n\nA successful query pattern will return an array of instances. The 'for' pattern can be used to iterate over an array. An example follows:\n\nworkflow NotifyEmployees {\n {Erp/Employee {salary?> 1000}} @as employees;\n for emp in employees {\n {Erp/SendMail {email emp.email, body \"You are selected for an increment!\"}}\n }\n}\n\nHere the result of the query is bound to the alias named 'employees'. Any pattern can have an alias, including 'if' and 'for'. An alias can be used to refer to the attributes of the instance, \nvia the dot(.) notation. Aliases can also be used to destructure a query result - here's an example:\n\nworkflow FindFirstTwoEmployees {\n {Erp/Employee {salary?> 1000}} @as [emp1, emp2];\n [emp1, emp2]\n}\n\nThis alias will bind the first two instances to 'a' and 'b' and the rest of the instances to an array named 'xs':\n\n{SomeEntity {id?> 1}} @as [a, b, _, xs]\n\nExamples of binding aliases to 'if' and 'for':\n\nif (IncrementSalary.percentage > 10) {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + salary * IncrementSalary.percentage}}\n} else {\n {Erp/Employee {employeeId IncrementSalary.employeeId, salary salary + 1500}}\n} @as emp\n\nfor emp in employees {\n {Erp/SendMail {email emp.email, body \"You are selected for an increment!\"}}\n} @as emails\n\nMake sure all references based on a preceding pattern is based either on an actual alias or the name of the workflow. For example, the following sequence of patterns\nare invalid, because the alias 'employee' is not defined:\n\n{Employee {id? 101}};\n{SendEmail {to employee.email, body \"hello\"}}\n\nA fix for the reference-error is shown below:\n\n{Employee {id? 101}} @as [employee];\n{SendEmail {to employee.email, body \"hello\"}}\n\nNote that the alias for the query is '[employee]' so that the resultset is destructured to select exactly one instance of Employee \nselected into the reference. You must follow this pattern if your goal is to select exactly a single instance.\n\nKeep in mind that the only valid syntax for the 'if' condition is:\n\nif (<expr>) {\n <patterns>\n} else if (<expr>) {\n <patterns>\n} else {\n <patterns>\n}\n\nThe following usage is NOT valid:\n\n<pattern> if (<expr>)\n\nA pattern may execute asynchronously and its eventual result can be handled by patterns provided in the '@then' clause. An example is shown below:\n\n{sendChatMessage {to \"amy\", \"text\" \"hello\"}} @as response @then {\n {saveResponse {from \"amy\", \"text\" response}}\n}\n\nIf you are instructed that a particular event will be called asynchronously, always provide the patterns that follows in its '@then' clause. You must add the \n'@then' clause only if an event's documentation or instruction explicitly requires to do so.\n\nEntities in a module can be connected together in relationships. There are two types of relationships - 'contains' and 'between'.\n'Contains' relationship is for hierarchical data, as in a Library entity containing Books. 'Between' relationship is for graph-like data,\nlike two Profiles in a social media app is connected as friends. A 'between' relationship can be one of the following three types - 'one_one' (one-to-one),\n'one_many' (one-to-many) and 'many_many' (many-to-many), which is the default.\n\nThe following example shows how additional profile data for an employee could be defined as a new entity and attached to the Employee entity as a between-relationship:\n\nentity Profile {\n id UUID @id @default(uuid()),\n address String @optional,\n photo URL @optional,\n dateOfBirth DateTime @optional\n}\n\nrelationship EmployeeProfile between (Erp/Employee, Erp/Profile) @one_one\n\nThe '@one_one' annotation means exactly one Employee and Profile can be related to each other via 'EmployeeProfile'.\n\nHere's the 'CreateEmployee' workflow updated to create the Employee with the his/her Profile attached:\n\nworkflow CreateEmployee {\n {Erp/Employee {firstName CreateEmployee.firstName,\n lastName CreateEmployee.lastName,\n salary CreateEmployee.salary,\n email CreateEmployee.email},\n Erp/EmployeeProfile {Erp/Profile {address CreateEmployee.address,\n photo CreateEmployee.photo,\n dateOfBirth CreateEmployee.dateOfBirth}}}\n}\n\nThe following pattern can be user to query an Employee along with his Profile:\n\n{Erp/Employee {employeeId? \"56392e13-0d9a-42f7-b556-0d7cd9468a24\"},\n Erp/EmployeeProfile {Erp/Profile? {}}}\n\nAs an example of 'contains' relaionships, consider modelling task-assignments for an Employee as folllows:\n\nentity TaskAssignment {\n id UUID @id @default(uuid()),\n description String,\n assignmentDate DateTime @default(now())\n}\n\nrelationship EmployeeTaskAssignment contains (Erp/Employee, Erp/TaskAssignment)\n\nThe following workflow shows how to assign a new task to an Employee:\n\nworkflow AssignNewTask {\n {Erp/Employee {employeeId? AssignNewTask.employeeId},\n Erp/EmployeeTaskAssignment {Erp/TaskAssignment {description AssignNewTask.description}}}\n}\n\nThe following workflow queries an Employee along with all his tasks:\n\nworkflow GetEmployeeTaskAssignments {\n {Erp/Employee {employeeId? GetEmployeeTaskAssignments.employeeId},\n Erp/EmployeeTaskAssignment {Erp/TaskAssignment? {}}}\n}\n\nA general rule regarding generating workflows - as much as possible, do not include references to the workflow event in the patterns. Try to\nfill-in values from the available context. For example, if your instruction is \"create a workflow to send an email to employee 101 with this message - \n'please call me as soon as possible'\", the best workflow to return is:\n\nworkflow sendEmail {\n {employee {id? 101}} @as emp;\n {email {to emp.email body \"please call me as soon as possible\"}}\n}\n\nbecause all the information needed is available in the context. If the instruction is \"create a workflow to send an email by employee-id with this message - \n'please call me as soon as possible'\", then you can return:\n\nworkflow sendEmail {\n {employee {id? sendEmail.employeeId}} @as emp;\n {email {to emp.email body \"please call me as soon as possible\"}}\n}\n\nThe point is, use the immediate context to fill-in values in generated patterns, as much as possible.\n\nAlso generate a workflow only if required explicitly by the user or the contextual information is incomplete. Otherwise, just return an array of patterns.\nAs an example, if the user request is \"send an email to employee 101 with this message - 'please call me as soon as possible'\", you must return:\n\n[{employee {id? 101}} @as emp;\n {email {to emp.email, body \"please call me as soon as possible\"}}]\n\nYou MUST separate each pattern in the array with a semi-colon (;) and never use a comma (,) for this purpose.\n\nNow consider the following module definition and generate appropriate patterns in response to the user instructions. You must return only valid patterns or workflows,\nno other descriptive text or comments are needed.\n";
|
|
2
|
+
export declare const FlowExecInstructions = "The following is the textual representation of a flowchart. \n\ncheckOrder --> \"ProductA\" acceptOrder\ncheckOrder --> \"ProductB\" acceptOrder\ncheckOrder --> \"ProductC\" rejectOrder\nacceptOrder --> sendPaymentLinkToCustomer\nrejectOrder --> sendRejectionEmailToCustomer\n\nAlong with this flowchart, you'll be passed a \"context\", which contain the steps in the flowchart that was executed so far, along with\ntheir results. Based on the context, you need to return the name of the step that needs to execute next. If you have reached the end\nof the chart, return 'DONE'. \n\nAt the beginning of the execution, the context will contain only the order information, say something like:\n\nOrderNo: 101, Item: \"ProductB\", customerEmail: \"manager@acme.com\"\n\nThis means you have to return 'checkOrder' as the next step (i.e you move the root node of the flowchart).\nAfter the step checkOrder executes, you'll be passed the following context:\n\norderNo: 101, Item: \"ProductB\", customerEmail: \"manager@acme.com\"\ncheckOrder --> \"ProductB\"\n\nNow you can infer from the context that if the result of checkOrder is either \"ProductA\" or \"ProductB\", you must move to the step 'acceptOrder'.\nSo you return 'acceptOrder'. After this, you'll return the updated context as:\n\nOrderNo: 101, Item: \"ProductB\", customerEmail: \"manager@acme.com\"\ncheckOrder --> \"ProductB\"\nacceptOrder --> {orderNo: 101, customerEmail: \"manager@acme.com\", acceptedOn: \"2025-07-01\"}\n\nYou see that 'acceptOrder' has produced the result '{orderNo: 101, customerEmail: \"manager@acme.com\", acceptedOn: \"2025-07-01\"}' - but from the flowchart you know that, whatever the result of 'acceptOrder',\nyou have to move to the 'sendPaymentLinkToCustomer' step and so you return 'sendPaymentLinkToCustomer'.\n\nThe next context you'll see will be:\n\nOrderNo: 101, Item: \"ProductB\", customerEmail: \"manager@acme.com\"\ncheckOrder --> \"ProductB\"\nacceptOrder --> {orderNo: 101, customerEmail: \"manager@acme.com\", acceptedOn: \"2025-07-01\"}\nsendPaymentLinkToCustomer --> \"manager@acme.com\"\n\nThe 'sendPaymentLinkToCustomer' has returned the customer email. You look at the flowchart and detect that, whatever the return value of\n'sendPaymentLinkToCustomer' there is nothing else to do. So you return 'DONE'.\n\nGenerally a flowchart has the following two types of entries:\n 1. a --> b, meaning after step 'a' do step 'b'.\n 2. a --> \"x\" b - this means if 'a' returns the string \"x\", then do step 'b'.\nIf you detect that you have reached the end of the chart, return 'DONE'. Otherwise, return only the name of the next step. Never return\nany additional description, direction or comments.\n";
|
|
2
3
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/runtime/agents/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/runtime/agents/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,8oYAwQ/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,qpFA+ChC,CAAC"}
|
|
@@ -250,7 +250,7 @@ workflow sendEmail {
|
|
|
250
250
|
{email {to emp.email body "please call me as soon as possible"}}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
The point is use the immediate context to fill-in values in generated patterns, as much as possible.
|
|
253
|
+
The point is, use the immediate context to fill-in values in generated patterns, as much as possible.
|
|
254
254
|
|
|
255
255
|
Also generate a workflow only if required explicitly by the user or the contextual information is incomplete. Otherwise, just return an array of patterns.
|
|
256
256
|
As an example, if the user request is "send an email to employee 101 with this message - 'please call me as soon as possible'", you must return:
|
|
@@ -263,4 +263,52 @@ You MUST separate each pattern in the array with a semi-colon (;) and never use
|
|
|
263
263
|
Now consider the following module definition and generate appropriate patterns in response to the user instructions. You must return only valid patterns or workflows,
|
|
264
264
|
no other descriptive text or comments are needed.
|
|
265
265
|
`;
|
|
266
|
+
export const FlowExecInstructions = `The following is the textual representation of a flowchart.
|
|
267
|
+
|
|
268
|
+
checkOrder --> "ProductA" acceptOrder
|
|
269
|
+
checkOrder --> "ProductB" acceptOrder
|
|
270
|
+
checkOrder --> "ProductC" rejectOrder
|
|
271
|
+
acceptOrder --> sendPaymentLinkToCustomer
|
|
272
|
+
rejectOrder --> sendRejectionEmailToCustomer
|
|
273
|
+
|
|
274
|
+
Along with this flowchart, you'll be passed a "context", which contain the steps in the flowchart that was executed so far, along with
|
|
275
|
+
their results. Based on the context, you need to return the name of the step that needs to execute next. If you have reached the end
|
|
276
|
+
of the chart, return 'DONE'.
|
|
277
|
+
|
|
278
|
+
At the beginning of the execution, the context will contain only the order information, say something like:
|
|
279
|
+
|
|
280
|
+
OrderNo: 101, Item: "ProductB", customerEmail: "manager@acme.com"
|
|
281
|
+
|
|
282
|
+
This means you have to return 'checkOrder' as the next step (i.e you move the root node of the flowchart).
|
|
283
|
+
After the step checkOrder executes, you'll be passed the following context:
|
|
284
|
+
|
|
285
|
+
orderNo: 101, Item: "ProductB", customerEmail: "manager@acme.com"
|
|
286
|
+
checkOrder --> "ProductB"
|
|
287
|
+
|
|
288
|
+
Now you can infer from the context that if the result of checkOrder is either "ProductA" or "ProductB", you must move to the step 'acceptOrder'.
|
|
289
|
+
So you return 'acceptOrder'. After this, you'll return the updated context as:
|
|
290
|
+
|
|
291
|
+
OrderNo: 101, Item: "ProductB", customerEmail: "manager@acme.com"
|
|
292
|
+
checkOrder --> "ProductB"
|
|
293
|
+
acceptOrder --> {orderNo: 101, customerEmail: "manager@acme.com", acceptedOn: "2025-07-01"}
|
|
294
|
+
|
|
295
|
+
You see that 'acceptOrder' has produced the result '{orderNo: 101, customerEmail: "manager@acme.com", acceptedOn: "2025-07-01"}' - but from the flowchart you know that, whatever the result of 'acceptOrder',
|
|
296
|
+
you have to move to the 'sendPaymentLinkToCustomer' step and so you return 'sendPaymentLinkToCustomer'.
|
|
297
|
+
|
|
298
|
+
The next context you'll see will be:
|
|
299
|
+
|
|
300
|
+
OrderNo: 101, Item: "ProductB", customerEmail: "manager@acme.com"
|
|
301
|
+
checkOrder --> "ProductB"
|
|
302
|
+
acceptOrder --> {orderNo: 101, customerEmail: "manager@acme.com", acceptedOn: "2025-07-01"}
|
|
303
|
+
sendPaymentLinkToCustomer --> "manager@acme.com"
|
|
304
|
+
|
|
305
|
+
The 'sendPaymentLinkToCustomer' has returned the customer email. You look at the flowchart and detect that, whatever the return value of
|
|
306
|
+
'sendPaymentLinkToCustomer' there is nothing else to do. So you return 'DONE'.
|
|
307
|
+
|
|
308
|
+
Generally a flowchart has the following two types of entries:
|
|
309
|
+
1. a --> b, meaning after step 'a' do step 'b'.
|
|
310
|
+
2. a --> "x" b - this means if 'a' returns the string "x", then do step 'b'.
|
|
311
|
+
If you detect that you have reached the end of the chart, return 'DONE'. Otherwise, return only the name of the next step. Never return
|
|
312
|
+
any additional description, direction or comments.
|
|
313
|
+
`;
|
|
266
314
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/runtime/agents/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwQlC,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/runtime/agents/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwQlC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CnC,CAAC"}
|
|
@@ -17,7 +17,9 @@ export function provider(service) {
|
|
|
17
17
|
if (p)
|
|
18
18
|
return p;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const errorMessage = `${service} provider requested but ${service.toUpperCase()}_API_KEY not found. Available providers: ${getAvailableProviders().join(', ') || 'none'}`;
|
|
21
|
+
console.error(errorMessage);
|
|
22
|
+
throw new Error(errorMessage);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/runtime/agents/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAE9F,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAExC,IAAI,CAAC,EAAE,CAAC;QACN,4DAA4D;QAC5D,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,CAAC;QACX,CAAC;aAAM,CAAC;YACN,gDAAgD;YAChD,MAAM,gBAAgB,GAAG,oBAAoB,EAAE,CAAC;YAChD,IAAI,gBAAgB,IAAI,gBAAgB,KAAK,gBAAgB,EAAE,CAAC;gBAC9D,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBACpC,IAAI,CAAC;oBAAE,OAAO,CAAC,CAAC;YAClB,CAAC;YACD,MAAM,
|
|
1
|
+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AAS,mBAAmB,CAAC,OAAe;IAC1C,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QACtC,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACzC;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB;IAC5B,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAAE,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -756,7 +756,7 @@ export class CognitoAuth {
|
|
|
756
756
|
try {
|
|
757
757
|
// Get additional user details from Cognito
|
|
758
758
|
const client = new CognitoIdentityProviderClient({
|
|
759
|
-
region: process.env.AWS_REGION || 'us-west-2'
|
|
759
|
+
region: process.env.AWS_REGION || 'us-west-2',
|
|
760
760
|
});
|
|
761
761
|
const command = new AdminGetUserCommand({
|
|
762
762
|
UserPoolId: this.fetchUserPoolId(),
|
package/out/runtime/defs.d.ts
CHANGED
|
@@ -38,4 +38,5 @@ export declare function setModuleFnFetcher(f: Function): void;
|
|
|
38
38
|
export declare let SetSubscription: any;
|
|
39
39
|
export declare function setSubscriptionFn(f: Function): void;
|
|
40
40
|
export declare const ForceReadPermFlag = "f-r-f";
|
|
41
|
+
export declare const FlowSuspensionTag = "--";
|
|
41
42
|
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../src/runtime/defs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,EAAE,MAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,EAAE,MAAoB,CAAC;AAC1D,eAAO,MAAM,mBAAmB,EAAE,MAAqB,CAAC;AACxD,eAAO,MAAM,wBAAwB,EAAE,MAAyB,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAUF,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY;CAMjE;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGrD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGrD;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAMrD;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGrD;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGrD;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGrD;AAED,qBAAa,gBA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E,OAAO,CAAC,CAAC;IAC5F,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAgB,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,IAAI,uDAAuD,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;CACF;AAED,MAAM,CAAC,IAAI,aAAa,GAAQ,SAAS,CAAC;AAE1C,MAAM,UAAU,kBAAkB,CAAC,CAAW;IAC5C,aAAa,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,IAAI,eAAe,GAAQ,SAAS,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,CAAW;IAC3C,eAAe,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC"}
|
|
@@ -36,6 +36,10 @@ export declare class Environment extends Instance {
|
|
|
36
36
|
lookup(k: string): Result;
|
|
37
37
|
bind(k: string, v: any): Environment;
|
|
38
38
|
bindInstance(inst: Instance): Environment;
|
|
39
|
+
private static FlowContextTag;
|
|
40
|
+
setFlowContext(s: string): Environment;
|
|
41
|
+
resetFlowContext(): Environment;
|
|
42
|
+
getFlowContext(): string | undefined;
|
|
39
43
|
static SuspensionUserData: string;
|
|
40
44
|
bindSuspensionUserData(userData: string): Environment;
|
|
41
45
|
lookupSuspensionUserData(): string | undefined;
|
|
@@ -92,6 +96,7 @@ export declare function evaluateAsEvent(moduleName: string, eventName: string, a
|
|
|
92
96
|
export declare function makeEventEvaluator(moduleName: string): Function;
|
|
93
97
|
export declare function evaluateStatements(stmts: Statement[], env: Environment, continuation?: Function): Promise<void>;
|
|
94
98
|
export declare function parseAndEvaluateStatement(stmtString: string, activeUserId?: string, actievEnv?: Environment): Promise<Result>;
|
|
99
|
+
export declare function restartFlow(flowContext: string[], userData: string, env: Environment): Promise<void>;
|
|
95
100
|
export declare function callPostEventOnSubscription(crudType: CrudType, inst: Instance, env?: Environment): Promise<any>;
|
|
96
101
|
export declare function runPostCreateEvents(inst: Instance, env: Environment): Promise<void>;
|
|
97
102
|
export declare function runPostUpdateEvents(inst: Instance, oldInst: Instance | undefined, env: Environment): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../../src/runtime/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EA0BL,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAKL,QAAQ,EAaR,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAY,QAAQ,EAAoB,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EACL,QAAQ,EAgBT,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,iBAAiB,EAA6B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../../src/runtime/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EA0BL,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAKL,QAAQ,EAaR,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAY,QAAQ,EAAoB,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EACL,QAAQ,EAgBT,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,iBAAiB,EAA6B,MAAM,gBAAgB,CAAC;AA6B9E,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC;AAIzB,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,KAAK,cAAc,GAAG;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,QAAQ,CAAC;CAC7B,CAAC;AAaF,KAAK,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE5C,qBAAa,WAAY,SAAQ,QAAQ;IACvC,MAAM,EAAE,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AM,EACjB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,EAC1B,aAAa,CAAC,EAAE,iBAAiB,EACjC,GAAG,CAAC,EAAE,WAAW,EACjB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAa/D;AAuBD,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,SAAS,EAAE,EAClB,GAAG,EAAE,WAAW,EAChB,YAAY,CAAC,EAAE,QAAQ,iBAYxB;AAiJD,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,WAAW,GACtB,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAomBD,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAQf;AAkVD,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EACd,GAAG,CAAC,EAAE,WAAW,GAChB,OAAO,CAAC,GAAG,CAAC,CAId;AAqDD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,iBAKzE;AAMD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,QAAQ,GAAG,SAAS,EAC7B,GAAG,EAAE,WAAW,iBAMjB;AAMD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,iBAKzE"}
|
|
@@ -6,9 +6,9 @@ import { CrudType, DefaultModuleName, escapeFqName, escapeQueryName, escapeSpeci
|
|
|
6
6
|
import { getResolver, getResolverNameForPath } from './resolvers/registry.js';
|
|
7
7
|
import { parseStatement, parseWorkflow } from '../language/parser.js';
|
|
8
8
|
import { AdminSession, AdminUserId } from './auth/defs.js';
|
|
9
|
-
import { AgentEntityName, AgentFqName, findAgentByName } from './modules/ai.js';
|
|
9
|
+
import { AgentInstance, AgentEntityName, AgentFqName, findAgentByName, getAgentFlow, } from './modules/ai.js';
|
|
10
10
|
import { logger } from './logger.js';
|
|
11
|
-
import { ParentAttributeName, PathAttributeName, PathAttributeNameQuery } from './defs.js';
|
|
11
|
+
import { FlowSuspensionTag, ParentAttributeName, PathAttributeName, PathAttributeNameQuery, } from './defs.js';
|
|
12
12
|
import { addCreateAudit, addDeleteAudit, addUpdateAudit, createSuspension, maybeCancelTimer, setTimerRunning, } from './modules/core.js';
|
|
13
13
|
import { invokeModuleFn } from './jsmodules.js';
|
|
14
14
|
import { invokeOpenApiEvent, isOpenApiEventInstance } from './openapi.js';
|
|
@@ -131,6 +131,17 @@ export class Environment extends Instance {
|
|
|
131
131
|
this.attributes.set(n, inst);
|
|
132
132
|
return this;
|
|
133
133
|
}
|
|
134
|
+
setFlowContext(s) {
|
|
135
|
+
this.attributes.set(Environment.FlowContextTag, s);
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
resetFlowContext() {
|
|
139
|
+
this.attributes.set(Environment.FlowContextTag, undefined);
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
getFlowContext() {
|
|
143
|
+
return this.attributes.get(Environment.FlowContextTag);
|
|
144
|
+
}
|
|
134
145
|
bindSuspensionUserData(userData) {
|
|
135
146
|
this.bind(Environment.SuspensionUserData, userData);
|
|
136
147
|
return this;
|
|
@@ -399,6 +410,7 @@ export class Environment extends Instance {
|
|
|
399
410
|
return r;
|
|
400
411
|
}
|
|
401
412
|
}
|
|
413
|
+
Environment.FlowContextTag = 'flow-context';
|
|
402
414
|
Environment.SuspensionUserData = '^';
|
|
403
415
|
export const GlobalEnvironment = new Environment();
|
|
404
416
|
export async function evaluate(eventInstance, continuation, activeEnv, kernelCall) {
|
|
@@ -907,7 +919,7 @@ async function evaluateCrudMap(crud, env) {
|
|
|
907
919
|
await runPostCreateEvents(inst, env);
|
|
908
920
|
}
|
|
909
921
|
if (r && entryName == AgentEntityName) {
|
|
910
|
-
defineAgentEvent(env.getActiveModuleName(), r.lookup('name'));
|
|
922
|
+
defineAgentEvent(env.getActiveModuleName(), r.lookup('name'), r.lookup('instruction'));
|
|
911
923
|
}
|
|
912
924
|
env.setLastResult(r);
|
|
913
925
|
const betRelInfo = env.getBetweenRelInfo();
|
|
@@ -1145,10 +1157,9 @@ async function walkJoinQueryPattern(rp, joinsSpec, env) {
|
|
|
1145
1157
|
}
|
|
1146
1158
|
}
|
|
1147
1159
|
const MAX_PLANNER_RETRIES = 3;
|
|
1148
|
-
async function
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
const msg = isString(origMsg) ? origMsg : agentInputAsString(origMsg);
|
|
1160
|
+
async function agentInvoke(agent, msg, env) {
|
|
1161
|
+
const flowContext = env.getFlowContext();
|
|
1162
|
+
msg = flowContext ? `context: ${flowContext}\n${msg}` : msg;
|
|
1152
1163
|
await agent.invoke(msg, env);
|
|
1153
1164
|
const r = env.getLastResult();
|
|
1154
1165
|
const isPlanner = agent.isPlanner();
|
|
@@ -1203,7 +1214,65 @@ async function handleAgentInvocation(agentEventInst, env) {
|
|
|
1203
1214
|
}
|
|
1204
1215
|
}
|
|
1205
1216
|
else {
|
|
1206
|
-
|
|
1217
|
+
throw new Error(`Agent ${agent.name} failed to generate a response`);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
async function handleAgentInvocation(agentEventInst, env) {
|
|
1221
|
+
const agent = await findAgentByName(agentEventInst.name, env);
|
|
1222
|
+
const origMsg = agentEventInst.lookup('message');
|
|
1223
|
+
const msg = isString(origMsg) ? origMsg : agentInputAsString(origMsg);
|
|
1224
|
+
const flow = getAgentFlow(agent.name);
|
|
1225
|
+
if (flow) {
|
|
1226
|
+
await handleAgentInvocationWithFlow(agent, flow, msg, env);
|
|
1227
|
+
}
|
|
1228
|
+
else {
|
|
1229
|
+
await agentInvoke(agent, msg, env).catch((reason) => {
|
|
1230
|
+
logger.warn(reason);
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
async function handleAgentInvocationWithFlow(rootAgent, flow, msg, env) {
|
|
1235
|
+
await iterateOnFlow(flow, rootAgent, msg, env);
|
|
1236
|
+
}
|
|
1237
|
+
async function saveFlowSuspension(agent, context, step, env) {
|
|
1238
|
+
const suspId = await createSuspension(env.getSuspensionId(), [FlowSuspensionTag, agent.name, step, context], env);
|
|
1239
|
+
env.setLastResult({ suspension: suspId || 'null' });
|
|
1240
|
+
}
|
|
1241
|
+
export async function restartFlow(flowContext, userData, env) {
|
|
1242
|
+
const [_, agentName, step, ctx] = flowContext;
|
|
1243
|
+
const flow = getAgentFlow(agentName);
|
|
1244
|
+
if (flow) {
|
|
1245
|
+
const rootAgent = await findAgentByName(agentName, env);
|
|
1246
|
+
const newCtx = `${ctx}\n${step} --> ${userData}\n`;
|
|
1247
|
+
await iterateOnFlow(flow, rootAgent, newCtx, env);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
const MaxFlowSteps = 25;
|
|
1251
|
+
async function iterateOnFlow(flow, rootAgent, msg, env) {
|
|
1252
|
+
rootAgent.disableSession();
|
|
1253
|
+
const s = `Now consider the following flowchart and context:\n${flow}\n\n${msg}`;
|
|
1254
|
+
await agentInvoke(rootAgent, s, env);
|
|
1255
|
+
let step = env.getLastResult();
|
|
1256
|
+
let context = msg;
|
|
1257
|
+
let stepc = 0;
|
|
1258
|
+
while (step != 'DONE') {
|
|
1259
|
+
if (stepc > MaxFlowSteps) {
|
|
1260
|
+
throw new Error(`Flow execution exceeded maximum steps limit`);
|
|
1261
|
+
}
|
|
1262
|
+
++stepc;
|
|
1263
|
+
const agent = AgentInstance.FromFlowStep(step, rootAgent);
|
|
1264
|
+
agent.disableSession();
|
|
1265
|
+
env.setFlowContext(context);
|
|
1266
|
+
await agentInvoke(agent, '', env);
|
|
1267
|
+
env.resetFlowContext();
|
|
1268
|
+
if (env.isSuspended()) {
|
|
1269
|
+
await saveFlowSuspension(rootAgent, context, step, env);
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
const r = env.getLastResult();
|
|
1273
|
+
context = `${context}\n${step} --> ${agentInputAsString(r)}\n`;
|
|
1274
|
+
await agentInvoke(rootAgent, `${s}\n${context}`, env);
|
|
1275
|
+
step = env.getLastResult();
|
|
1207
1276
|
}
|
|
1208
1277
|
}
|
|
1209
1278
|
function agentInputAsString(result) {
|