Skip to content

Commit 07ebcec

Browse files
committed
feat: update asyncmachine to v0.15
- fix: pull correct docker in `task sync-configs` - fix: stabilize searchxng - fix: bump jaeger version
1 parent 5746a18 commit 07ebcec

File tree

30 files changed

+297
-257
lines changed

30 files changed

+297
-257
lines changed

.aiignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

Taskfile.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ includes:
88

99
tasks:
1010

11-
docker:
11+
docker-build:
1212
env:
1313
DOCKER_BUILDKIT: 1
1414
cmd: docker build -t secai/{{.SECAI_ID}}
1515
--build-arg SECAI_ID="{{.SECAI_ID}}"
1616
-f deploy/agent/Dockerfile ..
1717

18-
docker-compose:
18+
docker-compose-start:
1919
dotenv: ["deploy/agent/agent.env"]
2020
# cmd: env
2121
cmd: docker-compose -f ./deploy/agent/docker-compose.yml
@@ -26,14 +26,14 @@ tasks:
2626
cmd: docker-compose -f ./deploy/agent/docker-compose.yml
2727
down
2828

29-
dev-docker:
29+
dev-docker-build:
3030
env:
3131
DOCKER_BUILDKIT: 1
3232
cmd: docker build -t secai/{{.SECAI_ID}}-dev
3333
--build-arg SECAI_ID="{{.SECAI_ID}}"
3434
-f deploy/agent/Dockerfile ..
3535

36-
dev-docker-compose:
36+
dev-docker-compose-start:
3737
dotenv: ["deploy/agent/agent.env"]
3838
env:
3939
SECAI_ENV: "-dev"
@@ -153,3 +153,10 @@ tasks:
153153
--graph 3
154154
--clean-on-connect
155155
{{.CLI_ARGS}}
156+
157+
start-metrics-docker:
158+
desc: Start docker-compose with Grafana for Docker Engine
159+
cmds:
160+
- docker-compose -f deploy/docker-metrics/docker-compose.yml up -d --force-recreate
161+
- |
162+
echo Grafana: http://localhost:3001

config/Taskfile.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 3
22

33
vars:
4-
AM_VER: 'v0.13.0'
4+
AM_VER: 'v0.15.0'
55
SECAI_DIR_ABS: '{{.USER_WORKING_DIR}}/{{.SECAI_AGENT_DIR}}/{{.SECAI_DIR}}'
66
SECAI_DIR: '{{.SECAI_DIR | default "tmp"}}'
77
SECAI_ID: '{{.SECAI_ID | default "myagent"}}'
@@ -138,18 +138,11 @@ tasks:
138138
start-metrics-agent:
139139
desc: Start docker-compose with Grafana and Jaeger for agents
140140
cmds:
141-
- docker-compose -f config/agent-metrics/docker-compose.yml up -d --force-recreate
141+
- docker-compose -f deploy/agent-metrics/docker-compose.yml up -d --force-recreate
142142
- |
143143
echo Grafana: http://localhost:3000
144144
echo Jaeger: http://localhost:16686
145145
146-
start-metrics-docker:
147-
desc: Start docker-compose with Grafana for Docker
148-
cmds:
149-
- docker-compose -f config/docker-metrics/docker-compose.yml up -d --force-recreate
150-
- |
151-
echo Grafana: http://localhost:3001
152-
153146
start-deploy:
154147
desc: Start a full deployment
155148
vars:
@@ -239,7 +232,7 @@ tasks:
239232
--create
240233

241234
tui-auto:
242-
desc: Start the full desktop TUI and reconnect
235+
desc: Start the full desktop TUI and keep reconnecting
243236
silent: false
244237
ignore_error: true
245238
cmds:
@@ -369,7 +362,7 @@ tasks:
369362

370363
sync-configs:
371364

372-
desc: Pull the newest ./config and ./template
365+
desc: Pull the newest `./template.env`, `./config`, and `./docker`1
373366
ignore_error: true
374367
cmd: |
375368
files=(
@@ -384,10 +377,12 @@ tasks:
384377
"./config/tui-mobile-auto.kdl"
385378
"./config/tui-mobile.kdl"
386379
"./config/tui.kdl"
387-
"./deploy/docker-metrics/docker-compose.yml"
388-
"./deploy/docker-metrics/prometheus.yml"
380+
"./deploy/agent-metrics/docker-compose.yml"
381+
"./deploy/agent-metrics/loki.yaml"
382+
"./deploy/agent-metrics/otel-collector-config.yaml"
383+
"./deploy/agent-metrics/prometheus.yml"
389384
)
390-
mkdir -p deploy/docker-metrics
385+
mkdir -p deploy/agent-metrics
391386
for file in "${files[@]}"; do
392387
rm -f "$file"
393388
wget -O "$file" "https://raw.githubusercontent.com/pancsta/secai/refs/heads/main${file:1}"

deploy/agent-metrics/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ services:
6464
# TODO update https://docs.google.com/document/d/18B1yTMewRft2N0nW9K-ecVRTt5VaNgnrPTW1eL236t4/edit?tab=t.0#heading=h.5j21da1bep6t
6565

6666
jaeger:
67-
image: jaegertracing/all-in-one:1.26
67+
image: jaegertracing/all-in-one:1.71.0
6868
container_name: jaeger
6969
environment:
7070
- COLLECTOR_OTLP_ENABLED=true

deploy/agent/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
4343

4444
EXPOSE 7000-8000
4545
ENTRYPOINT ["task", "start-deploy"]
46+
#ENTRYPOINT ["/usr/sbin/bash"]

deploy/agent/Taskfile.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
dotenv: ["agent.env"]
3+
vars:
4+
SECAI_ID: '{{.SECAI_ID}}'
5+
SECAI_ENV: '{{.SECAI_ENV}}'
6+
7+
tasks:
8+
9+
start: docker-compose up -d --force-recreate
10+
11+
start-container: docker run -it secai/${SECAI_ID}${SECAI_ENV}
12+
13+
stop: docker-compose down
14+
15+
reboot:
16+
cmds:
17+
- task: stop
18+
- task: start
19+
20+
reset:
21+
cmds:
22+
- task: stop
23+
- sudo rm -Rf ./data
24+
- mkdir data
25+
- chown tob:tob data
26+
- task: start

deploy/agent/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ services:
1515
- "${SECAI_WEB_MOBILE_PORT}:${SECAI_WEB_MOBILE_PORT}"
1616
- "${SECAI_WEB_LOGS_PORT}:${SECAI_WEB_LOGS_PORT}"
1717
- "${SECAI_WEB_DIR_PORT}:${SECAI_WEB_DIR_PORT}"
18-
restart: unless-stopped
18+
# restart: unless-stopped
19+
restart: no
1920
depends_on:
2021
- am-dbg
2122
deploy:
@@ -24,6 +25,7 @@ services:
2425
cpus: '0.5'
2526
memory: 300m
2627

28+
2729
am-dbg:
2830
image: asyncmachine/web-am-dbg
2931
stdin_open: true

examples/cook/agent.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var mock = Mock{
5252

5353
FlowPromptIngredients: "I have 2 carrots, 3 eggs and rice",
5454
FlowPromptRecipe: "cake",
55-
FlowPromptCooking: "wipe your memory",
55+
// FlowPromptCooking: "wipe your memory",
5656
// FlowPromptRecipe: "egg fried rice",
5757

5858
// TODO MockDump state for dumping mocked fields
@@ -225,17 +225,18 @@ func New(
225225

226226
func (a *Agent) Init(agent secai.AgentAPI) error {
227227
// call super
228-
err := a.Agent.Init(agent)
228+
err := a.Agent.Init(agent, schema.CookGroups, schema.CookStates)
229229
if err != nil {
230230
return err
231231
}
232232
mach := a.Mach()
233233

234-
a.Mach().AddBreakpoint(S{ss.StoryWakingUp}, nil)
235-
236234
// args mapper for logging
237-
mach.SetLogArgs(LogArgs)
238-
mach.AddBreakpoint(nil, S{ss.StoryRecipePicking})
235+
mach.SemLogger().SetArgsMapper(LogArgs)
236+
mach.AddBreakpoint(nil, S{ss.StoryRecipePicking}, true)
237+
238+
// loop guards
239+
a.loop = amhelp.NewStateLoop(mach, ss.Loop, nil)
239240

240241
// init searxng - websearch tool
241242
a.tSearxng, err = searxng.New(a)
@@ -401,8 +402,8 @@ func (a *Agent) initStories() {
401402
Action: func() {
402403
// TODO as TellJokeState
403404
s := a.Stories[ss.StoryJoke]
404-
// TODO check mach.CanAdd1(ss.StoryJoke, nil) once impl
405-
if !a.canJoke() {
405+
406+
if !a.hasJokes() {
406407
a.Output("The cook is working on new jokes.", shared.FromNarrator)
407408
}
408409
s.Epoch = a.MemCutoff.Load()
@@ -607,8 +608,7 @@ func (a *Agent) storiesButtons() []shared.StoryButton {
607608
return buts
608609
}
609610

610-
// TODO replace with machine.CanAdd
611-
func (a *Agent) canJoke() bool {
611+
func (a *Agent) hasJokes() bool {
612612
j := a.jokes.Load()
613613
return j != nil && len(j.Jokes) > 0
614614
}

examples/cook/handlers.go

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ func (a *Agent) CheckStoriesState(e *am.Event) {
224224
continue
225225
}
226226

227-
// add to the list
228-
if mach.Is1(s.State) && !activate || mach.Not1(s.State) && activate {
227+
// add to the list after a passed "impossibility check"
228+
if mach.Is1(s.State) && !activate && !amhelp.CantRemove1(mach, s.State, nil) ||
229+
mach.Not1(s.State) && activate && !amhelp.CantAdd1(mach, s.State, nil) {
230+
229231
if isDebug {
230232
a.Log("story changed", "story", s.State)
231233
}
@@ -264,7 +266,8 @@ func (a *Agent) StoryChangedState(e *am.Event) {
264266
// deactivate
265267
if mach.Is1(s.State) && !activate {
266268
res := mach.EvRemove1(e, s.State, nil)
267-
// TODO handle Queued? use CanRemove1, when available
269+
270+
// TODO handle Queued?
268271
if res != am.Canceled {
269272
s.Cook.TimeDeactivated = mach.Time(nil)
270273
s.Memory.TimeDeactivated = a.mem.Time(nil)
@@ -276,7 +279,8 @@ func (a *Agent) StoryChangedState(e *am.Event) {
276279
// activate
277280
} else if mach.Not1(s.State) && activate {
278281
res := mach.EvAdd1(e, s.State, nil)
279-
// TODO handle Queued? use CanAdd1, when available
282+
283+
// TODO handle Queued?
280284
if res != am.Canceled {
281285
s.Cook.TimeActivated = mach.Time(nil)
282286
s.Memory.TimeActivated = a.mem.Time(nil)
@@ -324,7 +328,7 @@ func (a *Agent) ReadyState(e *am.Event) {
324328
// TODO enter
325329

326330
func (a *Agent) UISessConnState(e *am.Event) {
327-
mach := e.Machine()
331+
mach := a.Mach()
328332
args := ParseArgs(e.Args)
329333
sess := args.SSHSess
330334
done := args.Done
@@ -658,7 +662,9 @@ func (a *Agent) OrientingState(e *am.Event) {
658662
prompt := ParseArgs(e.Args).Prompt
659663

660664
// possible moves: all cooking steps, most stories and some states
661-
moves := map[string]string{}
665+
666+
// moves from stories
667+
movesStories := map[string]string{}
662668
for _, name := range mach.StateNames() {
663669
state := cookSchema[name]
664670

@@ -671,18 +677,25 @@ func (a *Agent) OrientingState(e *am.Event) {
671677
desc = a.Stories[name].Desc
672678
}
673679

674-
// TODO check CanAdd1 for the stories
675680
if isTrigger || (isStory && !isManual) {
676-
moves[name] = desc
681+
impossible := amhelp.CantAdd1(mach, name, nil)
682+
if !impossible {
683+
movesStories[name] = desc
684+
}
677685
}
678686
}
679687

688+
// collect and filter cooking moves
689+
movesCooking := a.mem.StateNamesMatch(schema.MatchSteps)
690+
movesCooking = slices.DeleteFunc(movesCooking, func(state string) bool {
691+
return amhelp.CantAdd1(a.mem, state, nil)
692+
})
693+
680694
// build params
681695
params := schema.ParamsOrienting{
682-
Prompt: prompt,
683-
// TODO check CanAdd1 for the steps
684-
MovesCooking: a.mem.StateNamesMatch(schema.MatchSteps),
685-
MovesStories: moves,
696+
Prompt: prompt,
697+
MovesCooking: movesCooking,
698+
MovesStories: movesStories,
686699
}
687700

688701
// unblock
@@ -1142,7 +1155,7 @@ func (a *Agent) StoryCookingStartedEnd(e *am.Event) {
11421155
}
11431156

11441157
func (a *Agent) StoryJokeEnter(e *am.Event) bool {
1145-
return a.canJoke()
1158+
return a.hasJokes()
11461159
}
11471160

11481161
func (a *Agent) StoryJokeState(e *am.Event) {

examples/cook/schema/states_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ var StateSet = am.StateSet
2222
var SchemaMerge = am.SchemaMerge
2323

2424
// Exception is a type alias for the exception state.
25-
var Exception = am.Exception
25+
var Exception = am.StateException

0 commit comments

Comments
 (0)