server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
if call.number == 0 {
modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"echo hi"}`)}, 100, 0, 5))
+
return
}
second.WaitFor(t, "[connected to OneChat]")
first.Type("Run echo hi.")
+
for _, client := range []*TerminalTestClient{first, second} {
client.WaitFor(t, "[done]")
require.Equal(t, "[connected to OneChat]\n[working]\n[tool] shell {\"command\":\"echo hi\"}\n[result] hi\nIt said hi.\n[done]\n", client.Output())
close(release)
})
- server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
+ server.reply = func(_ http.ResponseWriter, _ ModelFakeCall) {
close(arrived)
<-release
}
require.Empty(t, entries)
}
+func TestDaemonLogHasATimeStampOnlyOutsideTheJournal(t *testing.T) {
+ testCases := []struct {
+ name string
+ journal string
+ line string
+ }{
+ {
+ name: "the journal adds the time itself",
+ journal: "8:12345",
+ line: `^<6>onechat: the agent is ready\n$`,
+ },
+ {
+ name: "a terminal gets the time in the line",
+ journal: "",
+ line: `^\d{4}/\d\d/\d\d \d\d:\d\d:\d\d INFO onechat: the agent is ready\n$`,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ t.Setenv("JOURNAL_STREAM", tc.journal)
+
+ var out strings.Builder
+
+ daemonLogger(&out, "onechat: ").Info("the agent is ready")
+ require.Regexp(t, tc.line, out.String())
+ })
+ }
+}
+
// daemonStartTest serves a new agent on a socket in a temporary directory and
// returns the socket path. The commands of the agent run in a temporary
// directory.