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 +12 -9
- package/package.json +3 -3
- package/src/StateMachine.ts +0 -1
- package/src/auditing/ConsoleAuditor.ts +2 -2
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
|
|
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
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
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.
|
|
19
|
-
"anbaric-tsapi": "^1.
|
|
18
|
+
"anbaric-impl-cloud": "^1.9.0",
|
|
19
|
+
"anbaric-tsapi": "^1.9.0"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"src"
|
package/src/StateMachine.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {Actor,
|
|
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 :
|
|
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
|
}
|