summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/sdk/app.go
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-09 08:16:10 -0500
committeradamdottv <[email protected]>2025-07-09 08:16:10 -0500
commitca8ce88354fa2f8e7cc8f0a911197a2550ebc269 (patch)
tree07902e77aadb66113897c8363488d0b3a90ebf5d /packages/tui/sdk/app.go
parent37a86439c426bc735e3b3e76767ddd4c321fbe1a (diff)
downloadopencode-ca8ce88354fa2f8e7cc8f0a911197a2550ebc269.tar.gz
opencode-ca8ce88354fa2f8e7cc8f0a911197a2550ebc269.zip
feat(tui): move logging to server logs
Diffstat (limited to 'packages/tui/sdk/app.go')
-rw-r--r--packages/tui/sdk/app.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/tui/sdk/app.go b/packages/tui/sdk/app.go
index dc44a74b3..39ca3bd9e 100644
--- a/packages/tui/sdk/app.go
+++ b/packages/tui/sdk/app.go
@@ -7,6 +7,7 @@ import (
"net/http"
"github.com/sst/opencode-sdk-go/internal/apijson"
+ "github.com/sst/opencode-sdk-go/internal/param"
"github.com/sst/opencode-sdk-go/internal/requestconfig"
"github.com/sst/opencode-sdk-go/option"
)
@@ -46,6 +47,14 @@ func (r *AppService) Init(ctx context.Context, opts ...option.RequestOption) (re
return
}
+// Write a log entry to the server logs
+func (r *AppService) Log(ctx context.Context, body AppLogParams, opts ...option.RequestOption) (res *bool, err error) {
+ opts = append(r.Options[:], opts...)
+ path := "log"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return
+}
+
type App struct {
Git bool `json:"git,required"`
Hostname string `json:"hostname,required"`
@@ -121,3 +130,35 @@ func (r *AppTime) UnmarshalJSON(data []byte) (err error) {
func (r appTimeJSON) RawJSON() string {
return r.raw
}
+
+type AppLogParams struct {
+ // Log level
+ Level param.Field[AppLogParamsLevel] `json:"level,required"`
+ // Log message
+ Message param.Field[string] `json:"message,required"`
+ // Service name for the log entry
+ Service param.Field[string] `json:"service,required"`
+ // Additional metadata for the log entry
+ Extra param.Field[map[string]interface{}] `json:"extra"`
+}
+
+func (r AppLogParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+// Log level
+type AppLogParamsLevel string
+
+const (
+ AppLogParamsLevelInfo AppLogParamsLevel = "info"
+ AppLogParamsLevelError AppLogParamsLevel = "error"
+ AppLogParamsLevelWarn AppLogParamsLevel = "warn"
+)
+
+func (r AppLogParamsLevel) IsKnown() bool {
+ switch r {
+ case AppLogParamsLevelInfo, AppLogParamsLevelError, AppLogParamsLevelWarn:
+ return true
+ }
+ return false
+}