WIP: Save agent roles integration work before CHORUS rebrand

- Agent roles and coordination features
- Chat API integration testing
- New configuration and workspace management

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-08-01 02:21:11 +10:00
parent 81b473d48f
commit 5978a0b8f5
3713 changed files with 1103925 additions and 59 deletions

152
vendor/go.uber.org/fx/fxevent/console.go generated vendored Normal file
View File

@@ -0,0 +1,152 @@
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package fxevent
import (
"fmt"
"io"
"strings"
)
// ConsoleLogger is an Fx event logger that attempts to write human-readable
// messages to the console.
//
// Use this during development.
type ConsoleLogger struct {
W io.Writer
}
var _ Logger = (*ConsoleLogger)(nil)
func (l *ConsoleLogger) logf(msg string, args ...interface{}) {
fmt.Fprintf(l.W, "[Fx] "+msg+"\n", args...)
}
// LogEvent logs the given event to the provided Zap logger.
func (l *ConsoleLogger) LogEvent(event Event) {
switch e := event.(type) {
case *OnStartExecuting:
l.logf("HOOK OnStart\t\t%s executing (caller: %s)", e.FunctionName, e.CallerName)
case *OnStartExecuted:
if e.Err != nil {
l.logf("HOOK OnStart\t\t%s called by %s failed in %s: %+v", e.FunctionName, e.CallerName, e.Runtime, e.Err)
} else {
l.logf("HOOK OnStart\t\t%s called by %s ran successfully in %s", e.FunctionName, e.CallerName, e.Runtime)
}
case *OnStopExecuting:
l.logf("HOOK OnStop\t\t%s executing (caller: %s)", e.FunctionName, e.CallerName)
case *OnStopExecuted:
if e.Err != nil {
l.logf("HOOK OnStop\t\t%s called by %s failed in %s: %+v", e.FunctionName, e.CallerName, e.Runtime, e.Err)
} else {
l.logf("HOOK OnStop\t\t%s called by %s ran successfully in %s", e.FunctionName, e.CallerName, e.Runtime)
}
case *Supplied:
if e.Err != nil {
l.logf("ERROR\tFailed to supply %v: %+v", e.TypeName, e.Err)
} else if e.ModuleName != "" {
l.logf("SUPPLY\t%v from module %q", e.TypeName, e.ModuleName)
} else {
l.logf("SUPPLY\t%v", e.TypeName)
}
case *Provided:
var privateStr string
if e.Private {
privateStr = " (PRIVATE)"
}
for _, rtype := range e.OutputTypeNames {
if e.ModuleName != "" {
l.logf("PROVIDE%v\t%v <= %v from module %q", privateStr, rtype, e.ConstructorName, e.ModuleName)
} else {
l.logf("PROVIDE%v\t%v <= %v", privateStr, rtype, e.ConstructorName)
}
}
if e.Err != nil {
l.logf("Error after options were applied: %+v", e.Err)
}
case *Replaced:
for _, rtype := range e.OutputTypeNames {
if e.ModuleName != "" {
l.logf("REPLACE\t%v from module %q", rtype, e.ModuleName)
} else {
l.logf("REPLACE\t%v", rtype)
}
}
if e.Err != nil {
l.logf("ERROR\tFailed to replace: %+v", e.Err)
}
case *Decorated:
for _, rtype := range e.OutputTypeNames {
if e.ModuleName != "" {
l.logf("DECORATE\t%v <= %v from module %q", rtype, e.DecoratorName, e.ModuleName)
} else {
l.logf("DECORATE\t%v <= %v", rtype, e.DecoratorName)
}
}
if e.Err != nil {
l.logf("Error after options were applied: %+v", e.Err)
}
case *Run:
var moduleStr string
if e.ModuleName != "" {
moduleStr = fmt.Sprintf(" from module %q", e.ModuleName)
}
l.logf("RUN\t%v: %v%v", e.Kind, e.Name, moduleStr)
if e.Err != nil {
l.logf("Error returned: %+v", e.Err)
}
case *Invoking:
if e.ModuleName != "" {
l.logf("INVOKE\t\t%s from module %q", e.FunctionName, e.ModuleName)
} else {
l.logf("INVOKE\t\t%s", e.FunctionName)
}
case *Invoked:
if e.Err != nil {
l.logf("ERROR\t\tfx.Invoke(%v) called from:\n%+vFailed: %+v", e.FunctionName, e.Trace, e.Err)
}
case *Stopping:
l.logf("%v", strings.ToUpper(e.Signal.String()))
case *Stopped:
if e.Err != nil {
l.logf("ERROR\t\tFailed to stop cleanly: %+v", e.Err)
}
case *RollingBack:
l.logf("ERROR\t\tStart failed, rolling back: %+v", e.StartErr)
case *RolledBack:
if e.Err != nil {
l.logf("ERROR\t\tCouldn't roll back cleanly: %+v", e.Err)
}
case *Started:
if e.Err != nil {
l.logf("ERROR\t\tFailed to start: %+v", e.Err)
} else {
l.logf("RUNNING")
}
case *LoggerInitialized:
if e.Err != nil {
l.logf("ERROR\t\tFailed to initialize custom logger: %+v", e.Err)
} else {
l.logf("LOGGER\tInitialized custom logger from %v", e.ConstructorName)
}
}
}

282
vendor/go.uber.org/fx/fxevent/event.go generated vendored Normal file
View File

@@ -0,0 +1,282 @@
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package fxevent
import (
"os"
"time"
)
// Event defines an event emitted by fx.
type Event interface {
event() // Only fxlog can implement this interface.
}
// Passing events by type to make Event hashable in the future.
func (*OnStartExecuting) event() {}
func (*OnStartExecuted) event() {}
func (*OnStopExecuting) event() {}
func (*OnStopExecuted) event() {}
func (*Supplied) event() {}
func (*Provided) event() {}
func (*Replaced) event() {}
func (*Decorated) event() {}
func (*Run) event() {}
func (*Invoking) event() {}
func (*Invoked) event() {}
func (*Stopping) event() {}
func (*Stopped) event() {}
func (*RollingBack) event() {}
func (*RolledBack) event() {}
func (*Started) event() {}
func (*LoggerInitialized) event() {}
// OnStartExecuting is emitted before an OnStart hook is executed.
type OnStartExecuting struct {
// FunctionName is the name of the function that will be executed.
FunctionName string
// CallerName is the name of the function that scheduled the hook for
// execution.
CallerName string
}
// OnStartExecuted is emitted after an OnStart hook has been executed.
type OnStartExecuted struct {
// FunctionName is the name of the function that was executed.
FunctionName string
// CallerName is the name of the function that scheduled the hook for
// execution.
CallerName string
// Method specifies the kind of the hook. This is one of "OnStart" and
// "OnStop".
Method string
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// OnStopExecuting is emitted before an OnStop hook is executed.
type OnStopExecuting struct {
// FunctionName is the name of the function that will be executed.
FunctionName string
// CallerName is the name of the function that scheduled the hook for
// execution.
CallerName string
}
// OnStopExecuted is emitted after an OnStop hook has been executed.
type OnStopExecuted struct {
// FunctionName is the name of the function that was executed.
FunctionName string
// CallerName is the name of the function that scheduled the hook for
// execution.
CallerName string
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// Supplied is emitted after a value is added with fx.Supply.
type Supplied struct {
// TypeName is the name of the type of value that was added.
TypeName string
// StackTrace is the stack trace of the call to Supply.
StackTrace []string
// ModuleTrace contains the module locations through which this value was added.
ModuleTrace []string
// ModuleName is the name of the module in which the value was added to.
ModuleName string
// Err is non-nil if we failed to supply the value.
Err error
}
// Provided is emitted when a constructor is provided to Fx.
type Provided struct {
// ConstructorName is the name of the constructor that was provided to
// Fx.
ConstructorName string
// StackTrace is the stack trace of where the constructor was provided to Fx.
StackTrace []string
// ModuleTrace contains the module locations through which this was provided to Fx.
ModuleTrace []string
// OutputTypeNames is a list of names of types that are produced by
// this constructor.
OutputTypeNames []string
// ModuleName is the name of the module in which the constructor was
// provided to.
ModuleName string
// Err is non-nil if we failed to provide this constructor.
Err error
// Private denotes whether the provided constructor is a [Private] constructor.
Private bool
}
// Replaced is emitted when a value replaces a type in Fx.
type Replaced struct {
// OutputTypeNames is a list of names of types that were replaced.
OutputTypeNames []string
// StackTrace is the stack trace of the call to Replace.
StackTrace []string
// ModuleTrace contains the module locations through which this value was added.
ModuleTrace []string
// ModuleName is the name of the module in which the value was added to.
ModuleName string
// Err is non-nil if we failed to supply the value.
Err error
}
// Decorated is emitted when a decorator is executed in Fx.
type Decorated struct {
// DecoratorName is the name of the decorator function that was
// provided to Fx.
DecoratorName string
// StackTrace is the stack trace of where the decorator was given to Fx.
StackTrace []string
// ModuleTrace contains the module locations through which this value was added.
ModuleTrace []string
// ModuleName is the name of the module in which the value was added to.
ModuleName string
// OutputTypeNames is a list of names of types that are decorated by
// this decorator.
OutputTypeNames []string
// Err is non-nil if we failed to run this decorator.
Err error
}
// Run is emitted after a constructor, decorator, or supply/replace stub is run by Fx.
type Run struct {
// Name is the name of the function that was run.
Name string
// Kind indicates which Fx option was used to pass along the function.
// It is either "provide", "decorate", "supply", or "replace".
Kind string
// ModuleName is the name of the module in which the function belongs.
ModuleName string
// Err is non-nil if the function returned an error.
// If fx.RecoverFromPanics is used, this will include panics.
Err error
}
// Invoking is emitted before we invoke a function specified with fx.Invoke.
type Invoking struct {
// FunctionName is the name of the function that will be invoked.
FunctionName string
// ModuleName is the name of the module in which the value was added to.
ModuleName string
}
// Invoked is emitted after we invoke a function specified with fx.Invoke,
// whether it succeeded or failed.
type Invoked struct {
// Functionname is the name of the function that was invoked.
FunctionName string
// ModuleName is the name of the module in which the value was added to.
ModuleName string
// Err is non-nil if the function failed to execute.
Err error
// Trace records information about where the fx.Invoke call was made.
// Note that this is NOT a stack trace of the error itself.
Trace string
}
// Started is emitted when an application is started successfully and/or it
// errored.
type Started struct {
// Err is non-nil if the application failed to start successfully.
Err error
}
// Stopping is emitted when the application receives a signal to shut down
// after starting. This may happen with fx.Shutdowner or by sending a signal to
// the application on the command line.
type Stopping struct {
// Signal is the signal that caused this shutdown.
Signal os.Signal
}
// Stopped is emitted when the application has finished shutting down, whether
// successfully or not.
type Stopped struct {
// Err is non-nil if errors were encountered during shutdown.
Err error
}
// RollingBack is emitted when the application failed to start up due to an
// error, and is being rolled back.
type RollingBack struct {
// StartErr is the error that caused this rollback.
StartErr error
}
// RolledBack is emitted after a service has been rolled back, whether it
// succeeded or not.
type RolledBack struct {
// Err is non-nil if the rollback failed.
Err error
}
// LoggerInitialized is emitted when a logger supplied with fx.WithLogger is
// instantiated, or if it fails to instantiate.
type LoggerInitialized struct {
// ConstructorName is the name of the constructor that builds this
// logger.
ConstructorName string
// Err is non-nil if the logger failed to build.
Err error
}

38
vendor/go.uber.org/fx/fxevent/logger.go generated vendored Normal file
View File

@@ -0,0 +1,38 @@
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package fxevent
// Logger defines interface used for logging.
type Logger interface {
// LogEvent is called when a logging event is emitted.
LogEvent(Event)
}
// NopLogger is an Fx event logger that ignores all messages.
var NopLogger = nopLogger{}
type nopLogger struct{}
var _ Logger = nopLogger{}
func (nopLogger) LogEvent(Event) {}
func (nopLogger) String() string { return "NopLogger" }

240
vendor/go.uber.org/fx/fxevent/zap.go generated vendored Normal file
View File

@@ -0,0 +1,240 @@
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package fxevent
import (
"strings"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// ZapLogger is an Fx event logger that logs events to Zap.
type ZapLogger struct {
Logger *zap.Logger
logLevel zapcore.Level // default: zapcore.InfoLevel
errorLevel *zapcore.Level
}
var _ Logger = (*ZapLogger)(nil)
// UseErrorLevel sets the level of error logs emitted by Fx to level.
func (l *ZapLogger) UseErrorLevel(level zapcore.Level) {
l.errorLevel = &level
}
// UseLogLevel sets the level of non-error logs emitted by Fx to level.
func (l *ZapLogger) UseLogLevel(level zapcore.Level) {
l.logLevel = level
}
func (l *ZapLogger) logEvent(msg string, fields ...zap.Field) {
l.Logger.Log(l.logLevel, msg, fields...)
}
func (l *ZapLogger) logError(msg string, fields ...zap.Field) {
lvl := zapcore.ErrorLevel
if l.errorLevel != nil {
lvl = *l.errorLevel
}
l.Logger.Log(lvl, msg, fields...)
}
// LogEvent logs the given event to the provided Zap logger.
func (l *ZapLogger) LogEvent(event Event) {
switch e := event.(type) {
case *OnStartExecuting:
l.logEvent("OnStart hook executing",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
)
case *OnStartExecuted:
if e.Err != nil {
l.logError("OnStart hook failed",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
zap.Error(e.Err),
)
} else {
l.logEvent("OnStart hook executed",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
zap.String("runtime", e.Runtime.String()),
)
}
case *OnStopExecuting:
l.logEvent("OnStop hook executing",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
)
case *OnStopExecuted:
if e.Err != nil {
l.logError("OnStop hook failed",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
zap.Error(e.Err),
)
} else {
l.logEvent("OnStop hook executed",
zap.String("callee", e.FunctionName),
zap.String("caller", e.CallerName),
zap.String("runtime", e.Runtime.String()),
)
}
case *Supplied:
if e.Err != nil {
l.logError("error encountered while applying options",
zap.String("type", e.TypeName),
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.Error(e.Err))
} else {
l.logEvent("supplied",
zap.String("type", e.TypeName),
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
)
}
case *Provided:
for _, rtype := range e.OutputTypeNames {
l.logEvent("provided",
zap.String("constructor", e.ConstructorName),
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.String("type", rtype),
maybeBool("private", e.Private),
)
}
if e.Err != nil {
l.logError("error encountered while applying options",
moduleField(e.ModuleName),
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
zap.Error(e.Err))
}
case *Replaced:
for _, rtype := range e.OutputTypeNames {
l.logEvent("replaced",
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.String("type", rtype),
)
}
if e.Err != nil {
l.logError("error encountered while replacing",
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.Error(e.Err))
}
case *Decorated:
for _, rtype := range e.OutputTypeNames {
l.logEvent("decorated",
zap.String("decorator", e.DecoratorName),
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.String("type", rtype),
)
}
if e.Err != nil {
l.logError("error encountered while applying options",
zap.Strings("stacktrace", e.StackTrace),
zap.Strings("moduletrace", e.ModuleTrace),
moduleField(e.ModuleName),
zap.Error(e.Err))
}
case *Run:
if e.Err != nil {
l.logError("error returned",
zap.String("name", e.Name),
zap.String("kind", e.Kind),
moduleField(e.ModuleName),
zap.Error(e.Err),
)
} else {
l.logEvent("run",
zap.String("name", e.Name),
zap.String("kind", e.Kind),
moduleField(e.ModuleName),
)
}
case *Invoking:
// Do not log stack as it will make logs hard to read.
l.logEvent("invoking",
zap.String("function", e.FunctionName),
moduleField(e.ModuleName),
)
case *Invoked:
if e.Err != nil {
l.logError("invoke failed",
zap.Error(e.Err),
zap.String("stack", e.Trace),
zap.String("function", e.FunctionName),
moduleField(e.ModuleName),
)
}
case *Stopping:
l.logEvent("received signal",
zap.String("signal", strings.ToUpper(e.Signal.String())))
case *Stopped:
if e.Err != nil {
l.logError("stop failed", zap.Error(e.Err))
}
case *RollingBack:
l.logError("start failed, rolling back", zap.Error(e.StartErr))
case *RolledBack:
if e.Err != nil {
l.logError("rollback failed", zap.Error(e.Err))
}
case *Started:
if e.Err != nil {
l.logError("start failed", zap.Error(e.Err))
} else {
l.logEvent("started")
}
case *LoggerInitialized:
if e.Err != nil {
l.logError("custom logger initialization failed", zap.Error(e.Err))
} else {
l.logEvent("initialized custom fxevent.Logger", zap.String("function", e.ConstructorName))
}
}
}
func moduleField(name string) zap.Field {
if len(name) == 0 {
return zap.Skip()
}
return zap.String("module", name)
}
func maybeBool(name string, b bool) zap.Field {
if b {
return zap.Bool(name, true)
}
return zap.Skip()
}