agentlang 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/out/runtime/agents/impl/anthropic.d.ts.map +1 -1
  2. package/out/runtime/agents/impl/anthropic.js +6 -2
  3. package/out/runtime/agents/impl/anthropic.js.map +1 -1
  4. package/out/runtime/agents/impl/openai.d.ts +1 -1
  5. package/out/runtime/agents/impl/openai.d.ts.map +1 -1
  6. package/out/runtime/agents/impl/openai.js +12 -3
  7. package/out/runtime/agents/impl/openai.js.map +1 -1
  8. package/out/runtime/agents/provider.d.ts +1 -1
  9. package/out/runtime/agents/provider.d.ts.map +1 -1
  10. package/out/runtime/agents/provider.js +5 -1
  11. package/out/runtime/agents/provider.js.map +1 -1
  12. package/out/runtime/auth/defs.d.ts +2 -0
  13. package/out/runtime/auth/defs.d.ts.map +1 -1
  14. package/out/runtime/auth/defs.js +8 -0
  15. package/out/runtime/auth/defs.js.map +1 -1
  16. package/out/runtime/defs.d.ts +0 -1
  17. package/out/runtime/defs.d.ts.map +1 -1
  18. package/out/runtime/defs.js +0 -1
  19. package/out/runtime/defs.js.map +1 -1
  20. package/out/runtime/interpreter.d.ts +3 -0
  21. package/out/runtime/interpreter.d.ts.map +1 -1
  22. package/out/runtime/interpreter.js +14 -5
  23. package/out/runtime/interpreter.js.map +1 -1
  24. package/out/runtime/loader.js +1 -1
  25. package/out/runtime/loader.js.map +1 -1
  26. package/out/runtime/module.d.ts +2 -0
  27. package/out/runtime/module.d.ts.map +1 -1
  28. package/out/runtime/module.js +39 -24
  29. package/out/runtime/module.js.map +1 -1
  30. package/out/runtime/modules/ai.d.ts +4 -0
  31. package/out/runtime/modules/ai.d.ts.map +1 -1
  32. package/out/runtime/modules/ai.js +60 -17
  33. package/out/runtime/modules/ai.js.map +1 -1
  34. package/out/runtime/resolvers/interface.d.ts +4 -0
  35. package/out/runtime/resolvers/interface.d.ts.map +1 -1
  36. package/out/runtime/resolvers/interface.js +23 -2
  37. package/out/runtime/resolvers/interface.js.map +1 -1
  38. package/out/runtime/resolvers/sqldb/impl.js +2 -2
  39. package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/runtime/agents/impl/anthropic.ts +7 -2
  42. package/src/runtime/agents/impl/openai.ts +13 -3
  43. package/src/runtime/agents/provider.ts +6 -2
  44. package/src/runtime/auth/defs.ts +11 -0
  45. package/src/runtime/defs.ts +0 -1
  46. package/src/runtime/interpreter.ts +12 -5
  47. package/src/runtime/loader.ts +1 -1
  48. package/src/runtime/module.ts +49 -29
  49. package/src/runtime/modules/ai.ts +66 -15
  50. package/src/runtime/resolvers/interface.ts +37 -2
  51. package/src/runtime/resolvers/sqldb/impl.ts +2 -2
@@ -1,4 +1,10 @@
1
- import { Environment, evaluate } from '../interpreter.js';
1
+ import {
2
+ Environment,
3
+ evaluate,
4
+ runPostCreateEvents,
5
+ runPostDeleteEvents,
6
+ runPostUpdateEvents,
7
+ } from '../interpreter.js';
2
8
  import { logger } from '../logger.js';
3
9
  import {
4
10
  Instance,
@@ -7,7 +13,7 @@ import {
7
13
  newInstanceAttributes,
8
14
  Relationship,
9
15
  } from '../module.js';
10
- import { splitFqName } from '../util.js';
16
+ import { CrudType, splitFqName } from '../util.js';
11
17
 
12
18
  export class ResolverAuthInfo {
13
19
  userId: string;
@@ -191,6 +197,35 @@ export class Resolver {
191
197
  return undefined;
192
198
  }
193
199
 
200
+ private async onOutOfBandCrud(
201
+ inst: Instance,
202
+ operation: CrudType,
203
+ env: Environment
204
+ ): Promise<any> {
205
+ switch (operation) {
206
+ case CrudType.CREATE:
207
+ return await runPostCreateEvents(inst, env);
208
+ case CrudType.UPDATE:
209
+ return await runPostUpdateEvents(inst, env);
210
+ case CrudType.DELETE:
211
+ return await runPostDeleteEvents(inst, env);
212
+ default:
213
+ return inst;
214
+ }
215
+ }
216
+
217
+ public async onCreate(inst: Instance, env: Environment): Promise<any> {
218
+ return this.onOutOfBandCrud(inst, CrudType.CREATE, env);
219
+ }
220
+
221
+ public async onUpdate(inst: Instance, env: Environment): Promise<any> {
222
+ return this.onOutOfBandCrud(inst, CrudType.UPDATE, env);
223
+ }
224
+
225
+ public async onDelete(inst: Instance, env: Environment): Promise<any> {
226
+ return this.onOutOfBandCrud(inst, CrudType.DELETE, env);
227
+ }
228
+
194
229
  public async onSubscription(result: any): Promise<any> {
195
230
  if (result != undefined) {
196
231
  try {
@@ -94,8 +94,8 @@ export class SqlDbResolver extends Resolver {
94
94
  const idAttrName: string | undefined = maybeFindIdAttributeName(inst);
95
95
  ensureOneToOneAttributes(inst);
96
96
  const attrs: InstanceAttributes = inst.attributes;
97
- if (idAttrName != undefined) {
98
- const idAttrVal: any = attrs.get(idAttrName);
97
+ const idAttrVal: any = idAttrName ? attrs.get(idAttrName) : crypto.randomUUID();
98
+ if (idAttrVal != undefined) {
99
99
  const pp: string | undefined = attrs.get(PathAttributeName);
100
100
  const n: string = `${inst.moduleName}/${inst.name}`;
101
101
  let p: string = '';