WIP: preserve remaining background task output work
This commit is contained in:
@@ -13,6 +13,8 @@ const LargeChatFixtureSessionID = "ses_large_chat_fixture"
|
||||
// LargeChatFixturePassword authenticates the disposable fixture endpoint. It is
|
||||
// fixed fixture data, not an operator credential.
|
||||
const LargeChatFixturePassword = "large-chat-fixture"
|
||||
const LargeChatFixtureShellID = "sh_large_chat_fixture"
|
||||
const LargeChatFixtureShellOutput = "fixture shell output marker\n"
|
||||
|
||||
const (
|
||||
LargeChatFixtureNewestAnswer = "Controlled newest answer: large history fixture"
|
||||
@@ -24,6 +26,13 @@ const (
|
||||
// It deliberately serves fixed, paged data: no model is invoked and no production
|
||||
// history is read or written.
|
||||
func LargeChatFixtureHandler(workspace string) http.Handler {
|
||||
return LargeChatFixtureHandlerWithShell(workspace, false)
|
||||
}
|
||||
|
||||
// LargeChatFixtureHandlerWithShell is the foreground fixture surface used by
|
||||
// the readback check. exited selects the provider's observed terminal state;
|
||||
// the output remains fixed and bounded in either state.
|
||||
func LargeChatFixtureHandlerWithShell(workspace string, exited bool) http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /api/info", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !largeChatFixtureAuthenticated(w, r) {
|
||||
@@ -63,6 +72,33 @@ func LargeChatFixtureHandler(workspace string) http.Handler {
|
||||
}
|
||||
writeLargeChatFixturePage(w, page)
|
||||
})
|
||||
status := "running"
|
||||
if exited {
|
||||
status = "exited"
|
||||
}
|
||||
mux.HandleFunc("GET /api/shell", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !largeChatFixtureAuthenticated(w, r) {
|
||||
return
|
||||
}
|
||||
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":[{"id":%q,"status":%q,"command":"printf fixture","metadata":{"sessionID":%q}}]}`, LargeChatFixtureShellID, status, LargeChatFixtureSessionID))
|
||||
})
|
||||
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureShellID, func(w http.ResponseWriter, r *http.Request) {
|
||||
if !largeChatFixtureAuthenticated(w, r) {
|
||||
return
|
||||
}
|
||||
exit := "null"
|
||||
if exited {
|
||||
exit = "0"
|
||||
}
|
||||
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"id":%q,"status":%q,"command":"printf fixture","exit":%s,"metadata":{"sessionID":%q}}}`, LargeChatFixtureShellID, status, exit, LargeChatFixtureSessionID))
|
||||
})
|
||||
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureShellID+"/output", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !largeChatFixtureAuthenticated(w, r) {
|
||||
return
|
||||
}
|
||||
cursor := int64(len(LargeChatFixtureShellOutput))
|
||||
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"output":%q,"cursor":%d,"size":%d,"truncated":false}}`, LargeChatFixtureShellOutput, cursor, cursor))
|
||||
})
|
||||
return mux
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user