anbaric-state-machine 1.8.0 → 1.9.0

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/README.md CHANGED
@@ -26,8 +26,8 @@ Throws `Invalid properties` / `Unauthorized`.
26
26
 
27
27
  **`updateJob(jobId, properties, actor) : Promise<void>`** — explicit change
28
28
  with a declared actor. Validates (required-ness is not re-checked on
29
- update), merges via `updateProperties`, audits `Properties updated`,
30
- re-enqueues.
29
+ update), merges the changed properties through `save` (which audits
30
+ `Properties updated`), re-enqueues.
31
31
 
32
32
  **`executeAction(jobId, action) : Promise<void>`** — runs one action now,
33
33
  its embedded actor as the responsible party. Refuses when the action's
@@ -48,17 +48,20 @@ audited through a transaction flushed at the end.
48
48
 
49
49
  ## Actors
50
50
 
51
- `Code`, `Human` and `Agent` implement the `Actor` interface as pure identity
52
- objects: `new Code(id, role = "code")`, `new Human(id, role)`,
53
- `new Agent(id, role)`. Behaviour never lives on an actoran `Action`'s
51
+ `Code` and `Human` implement the `Actor` interface as pure identity objects:
52
+ `new Code(id, role = "code")`, `new Human(id, role)`. An `Agent` is an actor
53
+ too, but carries a `Client` for its model calls construct a concrete
54
+ `OpenAIAgent` (or `AnbaricServicesAgent` from `anbaric-services-client`) rather
55
+ than a bare agent. Behaviour never lives on a plain actor — an `Action`'s
54
56
  `run` field carries the code, the actor says who is responsible.
55
57
 
56
58
  ## Auditing
57
59
 
58
- `Auditor.instance()` is a singleton logging
59
- `[jobId] actorId description details`. `audit(jobId, actor, description, details)`
60
- logs immediately; `transaction()` returns an `AuditorTransaction` that
61
- collects entries and `flush()`es them in order, once.
60
+ `AuditorFactory.instance()` returns the configured `Auditor` (a `ConsoleAuditor`
61
+ by default, a `CloudAuditor` when `ANBARIC_AUDITOR_TYPE=cloud`). Its
62
+ `audit(resourceType, resourceId, actor, interactions, description, details)`
63
+ records who did what to which resource; the persistence bases call it for you,
64
+ so app code rarely calls it directly.
62
65
 
63
66
  ## In-memory implementations and factories
64
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anbaric-state-machine",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "This is the state machine library that one can use to add state management to an application. It will, by default, be locally runnable but can deployed to the Anbaric Cloud via the CLI",
5
5
  "license": "MIT",
6
6
  "author": "chris@anbaric.ai",
@@ -15,8 +15,8 @@
15
15
  "typescript": "^7.0.2"
16
16
  },
17
17
  "dependencies": {
18
- "anbaric-impl-cloud": "^1.8.0",
19
- "anbaric-tsapi": "^1.8.0"
18
+ "anbaric-impl-cloud": "^1.9.0",
19
+ "anbaric-tsapi": "^1.9.0"
20
20
  },
21
21
  "files": [
22
22
  "src"
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Action,
3
3
  Actor,
4
- AuditInteraction,
5
4
  Consumer,
6
5
  Job,
7
6
  JobPersistence,
@@ -1,8 +1,8 @@
1
- import {Actor, AuditInteraction, Auditor} from "anbaric-tsapi";
1
+ import {Actor, Auditor} from "anbaric-tsapi";
2
2
 
3
3
  class ConsoleAuditor implements Auditor {
4
4
 
5
- async audit(resourceType : string, resourceId : string, actor : Actor, interaction : AuditInteraction[],
5
+ async audit(resourceType : string, resourceId : string, actor : Actor, interaction : Array<string>,
6
6
  description : string, details : any) : Promise<void> {
7
7
  console.log(`[${resourceType} ${resourceId}] ${actor.id} ${interaction.join(",")} ${description} ${JSON.stringify(details ?? null)}`);
8
8
  }