Merge remote-tracking branch 'origin/main' into mike/openai-reasoning-continuity
# Conflicts: # coderd/x/chatd/integration_responses_test.go # go.mod # go.sum
This commit is contained in:
commit
29a705e099
219 files changed
+3883
-1113
No files matched your search
@@ -915,6 +915,12 @@ func (m *Manager) createTransport(ctx context.Context, cfg ServerConfig) (mcp.Tr
|
||||
return &mcp.StreamableClientTransport{
|
||||
Endpoint: cfg.URL,
|
||||
HTTPClient: httpClientWithHeaders(cfg.Headers),
|
||||
// The SDK opens the standalone GET inside Connect on a context
|
||||
// connectTimeout does not cancel, so a server that never answers
|
||||
// it hangs Connect, and every later reload, indefinitely. This
|
||||
// also means server-initiated handlers on the client never fire
|
||||
// over HTTP.
|
||||
DisableStandaloneSSE: true,
|
||||
}, nil
|
||||
case "sse":
|
||||
return &mcp.SSEClientTransport{
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -272,6 +274,65 @@ func TestConnectServer_StdioProcessSurvivesConnect(t *testing.T) {
|
||||
assert.Equal(t, "echo", result.Tools[0].Name)
|
||||
}
|
||||
|
||||
// TestConnectServer_HTTPConnectsWhenStandaloneSSEHangs guards against the
|
||||
// SDK's standalone GET, which connectTimeout does not bound, hanging
|
||||
// Connect. See DisableStandaloneSSE in createTransport. The GET is only
|
||||
// sent when the negotiated protocol is below 2026-07-28, so this test
|
||||
// stops exercising it if an SDK upgrade negotiates that version or later.
|
||||
func TestConnectServer_HTTPConnectsWhenStandaloneSSEHangs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
server := mcp.NewServer(&mcp.Implementation{Name: "fake", Version: "1.0.0"}, nil)
|
||||
server.AddTool(&mcp.Tool{
|
||||
Name: "echo",
|
||||
InputSchema: map[string]any{"type": "object"},
|
||||
}, func(context.Context, *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
return &mcp.CallToolResult{}, nil
|
||||
})
|
||||
handler := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server { return server }, nil)
|
||||
|
||||
release := make(chan struct{})
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
select {
|
||||
case <-release:
|
||||
case <-r.Context().Done():
|
||||
}
|
||||
return
|
||||
}
|
||||
handler.ServeHTTP(w, r)
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
t.Cleanup(func() { close(release) })
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
m := NewManager(ctx, slogtest.Make(t, nil), agentexec.DefaultExecer, nil, nil, nil, nil)
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
|
||||
type connectResult struct {
|
||||
client *mcp.ClientSession
|
||||
err error
|
||||
}
|
||||
done := make(chan connectResult, 1)
|
||||
go func() {
|
||||
client, err := m.connectServer(ctx, ServerConfig{
|
||||
Name: "fake",
|
||||
Transport: "http",
|
||||
URL: srv.URL,
|
||||
})
|
||||
done <- connectResult{client: client, err: err}
|
||||
}()
|
||||
|
||||
res := testutil.RequireReceive(ctx, t, done)
|
||||
require.NoError(t, res.err)
|
||||
t.Cleanup(func() { _ = res.client.Close() })
|
||||
|
||||
result, err := res.client.ListTools(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, result.Tools, 1)
|
||||
assert.Equal(t, "echo", result.Tools[0].Name)
|
||||
}
|
||||
|
||||
func TestManager_WaitReloadTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
+15
@@ -69,6 +69,10 @@
|
||||
]
|
||||
},
|
||||
// "#/components/Stack/Stack": "Use Tailwind flex utilities instead (e.g., <div className='flex flex-col gap-4'>).",
|
||||
"sonner": {
|
||||
"message": "Import toast from #/components/Toaster/toast.",
|
||||
"importNames": ["toast"]
|
||||
},
|
||||
"lodash": "Use lodash/<name> instead."
|
||||
}
|
||||
}
|
||||
@@ -115,6 +119,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// toast.ts is the single choke point allowed to import Sonner's toast.
|
||||
"includes": ["**/components/Toaster/toast.ts"],
|
||||
"linter": {
|
||||
"rules": {
|
||||
"style": {
|
||||
"noRestrictedImports": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json"
|
||||
|
||||
Generated
+37
@@ -21301,6 +21301,10 @@ const docTemplate = `{
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"narration": {
|
||||
"description": "Narration marks assistant text that the model labeled as commentary\non its work rather than its answer. Only providers that label their\noutput set it.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"parsed_commands": {
|
||||
"description": "ParsedCommands holds parsed programs from an execute tool call's\nshell command, one entry per simple command in source order. Each\nentry is [program] or [program, arg] where arg is the first non-flag\npositional argument. Program names are normalized to their base\nname (e.g. /usr/bin/go becomes go). Only populated when ToolName\nis \"execute\" and the command parses successfully; nil otherwise.",
|
||||
"type": "array",
|
||||
@@ -33280,6 +33284,13 @@ const docTemplate = `{
|
||||
"cron": {
|
||||
"type": "string"
|
||||
},
|
||||
"dependencies": {
|
||||
"description": "Dependencies lists the scripts this one waits for, as the\nprovisioner resolved them. It is omitted when empty.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/codersdk.WorkspaceAgentScriptDependency"
|
||||
}
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -33297,6 +33308,10 @@ const docTemplate = `{
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"resource_address": {
|
||||
"description": "ResourceAddress is the full Terraform address of the coder_script\nresource, for example \"module.git_clone.coder_script.clone\". It is\nempty for scripts that are not coder_script resources.",
|
||||
"type": "string"
|
||||
},
|
||||
"run_on_start": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -33317,6 +33332,28 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptDependency": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prerequisite_resource_address": {
|
||||
"type": "string"
|
||||
},
|
||||
"requirement": {
|
||||
"$ref": "#/definitions/codersdk.WorkspaceAgentScriptDependencyRequirement"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptDependencyRequirement": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"success",
|
||||
"completion"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"WorkspaceAgentScriptDependencyRequirementSuccess",
|
||||
"WorkspaceAgentScriptDependencyRequirementCompletion"
|
||||
]
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptStatus": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
||||
Generated
+34
@@ -19231,6 +19231,10 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"narration": {
|
||||
"description": "Narration marks assistant text that the model labeled as commentary\non its work rather than its answer. Only providers that label their\noutput set it.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"parsed_commands": {
|
||||
"description": "ParsedCommands holds parsed programs from an execute tool call's\nshell command, one entry per simple command in source order. Each\nentry is [program] or [program, arg] where arg is the first non-flag\npositional argument. Program names are normalized to their base\nname (e.g. /usr/bin/go becomes go). Only populated when ToolName\nis \"execute\" and the command parses successfully; nil otherwise.",
|
||||
"type": "array",
|
||||
@@ -30747,6 +30751,13 @@
|
||||
"cron": {
|
||||
"type": "string"
|
||||
},
|
||||
"dependencies": {
|
||||
"description": "Dependencies lists the scripts this one waits for, as the\nprovisioner resolved them. It is omitted when empty.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/codersdk.WorkspaceAgentScriptDependency"
|
||||
}
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -30764,6 +30775,10 @@
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"resource_address": {
|
||||
"description": "ResourceAddress is the full Terraform address of the coder_script\nresource, for example \"module.git_clone.coder_script.clone\". It is\nempty for scripts that are not coder_script resources.",
|
||||
"type": "string"
|
||||
},
|
||||
"run_on_start": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -30784,6 +30799,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptDependency": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prerequisite_resource_address": {
|
||||
"type": "string"
|
||||
},
|
||||
"requirement": {
|
||||
"$ref": "#/definitions/codersdk.WorkspaceAgentScriptDependencyRequirement"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptDependencyRequirement": {
|
||||
"type": "string",
|
||||
"enum": ["success", "completion"],
|
||||
"x-enum-varnames": [
|
||||
"WorkspaceAgentScriptDependencyRequirementSuccess",
|
||||
"WorkspaceAgentScriptDependencyRequirementCompletion"
|
||||
]
|
||||
},
|
||||
"codersdk.WorkspaceAgentScriptStatus": {
|
||||
"type": "string",
|
||||
"enum": ["ok", "exit_failure", "timed_out", "pipes_left_open"],
|
||||
|
||||
Generated
+1
@@ -76,6 +76,7 @@ const (
|
||||
CheckUserSkillsDescriptionSize CheckConstraint = "user_skills_description_size" // user_skills
|
||||
CheckUserSkillsNameFormat CheckConstraint = "user_skills_name_format" // user_skills
|
||||
CheckUserSkillsNameSize CheckConstraint = "user_skills_name_size" // user_skills
|
||||
CheckWorkspaceAgentScriptsDependenciesIsArray CheckConstraint = "workspace_agent_scripts_dependencies_is_array" // workspace_agent_scripts
|
||||
CheckMaxLogsLength CheckConstraint = "max_logs_length" // workspace_agents
|
||||
CheckSubsystemsNotNone CheckConstraint = "subsystems_not_none" // workspace_agents
|
||||
CheckWorkspaceBuildOrchestrationsAttemptCountCheck CheckConstraint = "workspace_build_orchestrations_attempt_count_check" // workspace_build_orchestrations
|
||||
|
||||
@@ -768,7 +768,31 @@ func WorkspaceAgentLog(log database.WorkspaceAgentLog) codersdk.WorkspaceAgentLo
|
||||
}
|
||||
}
|
||||
|
||||
func WorkspaceAgentScript(dbScript database.GetWorkspaceAgentScriptsByAgentIDsRow) codersdk.WorkspaceAgentScript {
|
||||
// WorkspaceAgentScript converts a script row to the SDK type. It fails on a
|
||||
// dependencies column that cannot be decoded or that holds an entry the SDK
|
||||
// cannot represent, so a caller never receives a partial list. The write
|
||||
// path already rejects such rows, so one here means a bug or a manual edit
|
||||
// of the database.
|
||||
func WorkspaceAgentScript(dbScript database.GetWorkspaceAgentScriptsByAgentIDsRow) (codersdk.WorkspaceAgentScript, error) {
|
||||
var dependencies []codersdk.WorkspaceAgentScriptDependency
|
||||
if len(dbScript.Dependencies) > 0 {
|
||||
if err := json.Unmarshal(dbScript.Dependencies, &dependencies); err != nil {
|
||||
return codersdk.WorkspaceAgentScript{}, xerrors.Errorf("decode dependencies: %w", err)
|
||||
}
|
||||
}
|
||||
if len(dependencies) == 0 {
|
||||
// nil rather than an empty slice so omitempty leaves the key out.
|
||||
dependencies = nil
|
||||
}
|
||||
for i, dependency := range dependencies {
|
||||
if dependency.PrerequisiteResourceAddress == "" {
|
||||
return codersdk.WorkspaceAgentScript{}, xerrors.Errorf("dependency %d has an empty prerequisite resource address", i)
|
||||
}
|
||||
if !dependency.Requirement.Valid() {
|
||||
return codersdk.WorkspaceAgentScript{}, xerrors.Errorf("dependency %d has unsupported requirement %q", i, dependency.Requirement)
|
||||
}
|
||||
}
|
||||
|
||||
script := codersdk.WorkspaceAgentScript{
|
||||
ID: dbScript.ID,
|
||||
LogPath: dbScript.LogPath,
|
||||
@@ -780,13 +804,15 @@ func WorkspaceAgentScript(dbScript database.GetWorkspaceAgentScriptsByAgentIDsRo
|
||||
StartBlocksLogin: dbScript.StartBlocksLogin,
|
||||
Timeout: time.Duration(dbScript.TimeoutSeconds) * time.Second,
|
||||
DisplayName: dbScript.DisplayName,
|
||||
ResourceAddress: dbScript.ResourceAddress,
|
||||
Dependencies: dependencies,
|
||||
ExitCode: nullInt32Ptr(dbScript.ExitCode),
|
||||
}
|
||||
if dbScript.Status.Valid {
|
||||
status := codersdk.WorkspaceAgentScriptStatus(dbScript.Status.WorkspaceAgentScriptTimingStatus)
|
||||
script.Status = &status
|
||||
}
|
||||
return script
|
||||
return script, nil
|
||||
}
|
||||
|
||||
func ProvisionerDaemon(dbDaemon database.ProvisionerDaemon) codersdk.ProvisionerDaemon {
|
||||
|
||||
@@ -12,6 +12,80 @@ import (
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
)
|
||||
|
||||
func TestWorkspaceAgentScriptDependencies(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
dependencies string
|
||||
want []codersdk.WorkspaceAgentScriptDependency
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "EmptyArrayIsNil",
|
||||
dependencies: `[]`,
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "EmptyColumnIsNil",
|
||||
dependencies: ``,
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
// A hand-written literal, so the column format is a tested
|
||||
// contract rather than whatever the encoder produces.
|
||||
name: "DecodesLiteral",
|
||||
dependencies: `[{"prerequisite_resource_address":"coder_script.clone_repo","requirement":"success"},` +
|
||||
`{"prerequisite_resource_address":"coder_script.warm_cache","requirement":"completion"}]`,
|
||||
want: []codersdk.WorkspaceAgentScriptDependency{
|
||||
{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: codersdk.WorkspaceAgentScriptDependencyRequirementSuccess,
|
||||
},
|
||||
{
|
||||
PrerequisiteResourceAddress: "coder_script.warm_cache",
|
||||
Requirement: codersdk.WorkspaceAgentScriptDependencyRequirementCompletion,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MalformedJSON",
|
||||
dependencies: `[`,
|
||||
wantErr: "decode dependencies",
|
||||
},
|
||||
{
|
||||
name: "EmptyAddress",
|
||||
dependencies: `[{"requirement":"success"}]`,
|
||||
wantErr: "dependency 0 has an empty prerequisite resource address",
|
||||
},
|
||||
{
|
||||
name: "UnknownRequirement",
|
||||
dependencies: `[{"prerequisite_resource_address":"coder_script.clone_repo","requirement":"eventually"}]`,
|
||||
wantErr: `dependency 0 has unsupported requirement "eventually"`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := WorkspaceAgentScript(database.GetWorkspaceAgentScriptsByAgentIDsRow{
|
||||
ID: uuid.New(),
|
||||
DisplayName: "Install tools",
|
||||
ResourceAddress: "coder_script.install_tools",
|
||||
Dependencies: json.RawMessage(tc.dependencies),
|
||||
})
|
||||
if tc.wantErr != "" {
|
||||
require.ErrorContains(t, err, tc.wantErr)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "coder_script.install_tools", got.ResourceAddress)
|
||||
require.Equal(t, tc.want, got.Dependencies)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAggregateTokenMetadata(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -828,6 +828,12 @@ func WorkspaceSubAgent(t testing.TB, db database.Store, parentAgent database.Wor
|
||||
}
|
||||
|
||||
func WorkspaceAgentScript(t testing.TB, db database.Store, orig database.WorkspaceAgentScript) database.WorkspaceAgentScript {
|
||||
// Casting an empty string to jsonb is a Postgres error, not an empty
|
||||
// list, so the default has to be written out.
|
||||
dependencies := orig.Dependencies
|
||||
if len(dependencies) == 0 {
|
||||
dependencies = json.RawMessage(`[]`)
|
||||
}
|
||||
scripts, err := db.InsertWorkspaceAgentScripts(genCtx, database.InsertWorkspaceAgentScriptsParams{
|
||||
WorkspaceAgentID: takeFirst(orig.WorkspaceAgentID, uuid.New()),
|
||||
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
|
||||
@@ -841,6 +847,8 @@ func WorkspaceAgentScript(t testing.TB, db database.Store, orig database.Workspa
|
||||
TimeoutSeconds: []int32{takeFirst(orig.TimeoutSeconds, 0)},
|
||||
DisplayName: []string{takeFirst(orig.DisplayName, "")},
|
||||
ID: []uuid.UUID{takeFirst(orig.ID, uuid.New())},
|
||||
ResourceAddress: []string{takeFirst(orig.ResourceAddress, "")},
|
||||
Dependencies: []string{string(dependencies)},
|
||||
})
|
||||
require.NoError(t, err, "insert workspace agent script")
|
||||
require.NotEmpty(t, scripts, "insert workspace agent script returned no scripts")
|
||||
|
||||
Generated
+4
-1
@@ -3777,7 +3777,10 @@ CREATE TABLE workspace_agent_scripts (
|
||||
run_on_stop boolean NOT NULL,
|
||||
timeout_seconds integer NOT NULL,
|
||||
display_name text NOT NULL,
|
||||
id uuid DEFAULT gen_random_uuid() NOT NULL
|
||||
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
resource_address text DEFAULT ''::text NOT NULL,
|
||||
dependencies jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||
CONSTRAINT workspace_agent_scripts_dependencies_is_array CHECK ((jsonb_typeof(dependencies) = 'array'::text))
|
||||
);
|
||||
|
||||
CREATE SEQUENCE workspace_agent_startup_logs_id_seq
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE workspace_agent_scripts
|
||||
DROP COLUMN dependencies,
|
||||
DROP COLUMN resource_address;
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE workspace_agent_scripts
|
||||
ADD COLUMN resource_address TEXT NOT NULL DEFAULT '',
|
||||
ADD COLUMN dependencies JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
ADD CONSTRAINT workspace_agent_scripts_dependencies_is_array
|
||||
CHECK (jsonb_typeof(dependencies) = 'array');
|
||||
@@ -356,3 +356,100 @@ func TestMigration000596ChainFrom589(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Zero(t, leftovers)
|
||||
}
|
||||
|
||||
// The rollback can't tell which minutes a family's apps shared, so it adds up
|
||||
// their minutes in each 30-minute bucket and caps the total at 30. App names
|
||||
// missing from the migration's copy of the registry count as SSH.
|
||||
//
|
||||
//nolint:tparallel,paralleltest // Subtests share one database with transaction-local fixtures.
|
||||
func TestMigration000596DownOverlap(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
sqlDB := testSQLDB(t)
|
||||
stepTo(t, sqlDB, 596)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitSuperLong)
|
||||
down596, err := os.ReadFile("000596_template_usage_stats_session_usage.down.sql")
|
||||
require.NoError(t, err)
|
||||
|
||||
type familyMins struct {
|
||||
ssh, sftp, reconnectingPTY, vscode, jetbrains int64
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
apps map[string]int64
|
||||
want familyMins
|
||||
}{
|
||||
{
|
||||
// vscode: cursor, vscode
|
||||
name: "same family past the cap",
|
||||
apps: map[string]int64{"cursor": 20, "vscode": 20},
|
||||
want: familyMins{vscode: 30},
|
||||
},
|
||||
{
|
||||
// vscode: cursor, vscode
|
||||
name: "same family under the cap",
|
||||
apps: map[string]int64{"cursor": 5, "vscode": 5},
|
||||
want: familyMins{vscode: 10},
|
||||
},
|
||||
{
|
||||
// ssh: ssh, zed, plus the unlisted some_new_ide, port_forwarding,
|
||||
// overflow, unknown
|
||||
name: "unlisted names count as ssh under the cap",
|
||||
apps: map[string]int64{
|
||||
"ssh": 5, "zed": 6, "some_new_ide": 5, "port_forwarding": 4, "overflow": 3, "unknown": 2,
|
||||
},
|
||||
want: familyMins{ssh: 25},
|
||||
},
|
||||
{
|
||||
// jetbrains: goland, intellij; reconnecting_pty: reconnecting_pty;
|
||||
// sftp: sftp; vscode: kiro
|
||||
name: "families cap separately",
|
||||
apps: map[string]int64{"goland": 25, "intellij": 10, "reconnecting_pty": 12, "sftp": 2, "kiro": 1},
|
||||
want: familyMins{sftp: 2, reconnectingPTY: 12, vscode: 1, jetbrains: 30},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tx, err := sqlDB.BeginTx(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { _ = tx.Rollback() })
|
||||
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO template_usage_stats (
|
||||
start_time, end_time, template_id, user_id, median_latency_ms,
|
||||
usage_mins, app_usage_mins
|
||||
) VALUES (
|
||||
date_trunc('hour', statement_timestamp()),
|
||||
date_trunc('hour', statement_timestamp()) + interval '30 minutes',
|
||||
'22222222-2222-2222-2222-222222222222'::uuid,
|
||||
'11111111-1111-1111-1111-111111111111'::uuid,
|
||||
NULL, 30, NULL
|
||||
)
|
||||
`)
|
||||
require.NoError(t, err)
|
||||
for appName, mins := range tt.apps {
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
INSERT INTO template_usage_stats_session_apps (
|
||||
start_time, template_id, user_id, app_name, usage_mins
|
||||
)
|
||||
SELECT start_time, template_id, user_id, $1, $2
|
||||
FROM template_usage_stats
|
||||
`, appName, mins)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(ctx, string(down596))
|
||||
require.NoError(t, err)
|
||||
|
||||
var got familyMins
|
||||
err = tx.QueryRowContext(ctx, `
|
||||
SELECT ssh_mins, sftp_mins, reconnecting_pty_mins, vscode_mins, jetbrains_mins
|
||||
FROM template_usage_stats
|
||||
`).Scan(&got.ssh, &got.sftp, &got.reconnectingPTY, &got.vscode, &got.jetbrains)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
INSERT INTO workspace_agent_scripts (
|
||||
workspace_agent_id,
|
||||
created_at,
|
||||
log_source_id,
|
||||
log_path,
|
||||
script,
|
||||
cron,
|
||||
start_blocks_login,
|
||||
run_on_start,
|
||||
run_on_stop,
|
||||
timeout_seconds,
|
||||
display_name,
|
||||
resource_address,
|
||||
dependencies
|
||||
) VALUES (
|
||||
'45e89705-e09d-4850-bcec-f9a937f5d78d',
|
||||
'2022-11-02 13:03:45.046432+02',
|
||||
'0ff953c0-92a6-4fe6-a415-eb0139a36ad1',
|
||||
'/tmp/install.log',
|
||||
'npm install',
|
||||
'',
|
||||
FALSE,
|
||||
TRUE,
|
||||
FALSE,
|
||||
0,
|
||||
'Install tools',
|
||||
'coder_script.install_tools',
|
||||
'[{"prerequisite_resource_address":"coder_script.clone_repo","requirement":"success"}]'
|
||||
) ON CONFLICT DO NOTHING;
|
||||
Generated
+14
-12
@@ -6705,18 +6705,20 @@ type WorkspaceAgentPortShare struct {
|
||||
}
|
||||
|
||||
type WorkspaceAgentScript struct {
|
||||
WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"`
|
||||
LogSourceID uuid.UUID `db:"log_source_id" json:"log_source_id"`
|
||||
LogPath string `db:"log_path" json:"log_path"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
Script string `db:"script" json:"script"`
|
||||
Cron string `db:"cron" json:"cron"`
|
||||
StartBlocksLogin bool `db:"start_blocks_login" json:"start_blocks_login"`
|
||||
RunOnStart bool `db:"run_on_start" json:"run_on_start"`
|
||||
RunOnStop bool `db:"run_on_stop" json:"run_on_stop"`
|
||||
TimeoutSeconds int32 `db:"timeout_seconds" json:"timeout_seconds"`
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"`
|
||||
LogSourceID uuid.UUID `db:"log_source_id" json:"log_source_id"`
|
||||
LogPath string `db:"log_path" json:"log_path"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
Script string `db:"script" json:"script"`
|
||||
Cron string `db:"cron" json:"cron"`
|
||||
StartBlocksLogin bool `db:"start_blocks_login" json:"start_blocks_login"`
|
||||
RunOnStart bool `db:"run_on_start" json:"run_on_start"`
|
||||
RunOnStop bool `db:"run_on_stop" json:"run_on_stop"`
|
||||
TimeoutSeconds int32 `db:"timeout_seconds" json:"timeout_seconds"`
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
ResourceAddress string `db:"resource_address" json:"resource_address"`
|
||||
Dependencies json.RawMessage `db:"dependencies" json:"dependencies"`
|
||||
}
|
||||
|
||||
type WorkspaceAgentScriptTiming struct {
|
||||
|
||||
Generated
+4
-2
@@ -907,8 +907,10 @@ type sqlcQuerier interface {
|
||||
// GetTemplateInsightsByTemplate is used for Prometheus metrics. Keep
|
||||
// in sync with GetTemplateInsights and UpsertTemplateUsageStats.
|
||||
//
|
||||
// Session usage comes out per app name, as in GetTemplateInsights, so either
|
||||
// query reports the same family totals once the names are grouped.
|
||||
// Session usage is reported per app family. It reads the raw agent stats
|
||||
// because the rollup stores minutes per app, which can't show whether two
|
||||
// apps of one family were open in the same minute. @app_families maps each
|
||||
// app name to its family; names missing from the map count as unknown.
|
||||
GetTemplateInsightsByTemplate(ctx context.Context, arg GetTemplateInsightsByTemplateParams) ([]GetTemplateInsightsByTemplateRow, error)
|
||||
// GetTemplateParameterInsights does for each template in a given timeframe,
|
||||
// look for the latest workspace build (for every workspace) that has been
|
||||
|
||||
@@ -857,20 +857,33 @@ func TestGetTemplateInsightsByTemplate(t *testing.T) {
|
||||
insertStat(15*time.Second, sharedConnectionTemplateID, sharedConnectionUserID, uuid.New(), 0, map[string]int64{"vscode": 1})
|
||||
insertStat(30*time.Second, sharedConnectionTemplateID, sharedConnectionUserID, uuid.New(), 1, map[string]int64{"unknown": 1})
|
||||
|
||||
insights, err := db.GetTemplateInsightsByTemplate(ctx, database.GetTemplateInsightsByTemplateParams{
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
})
|
||||
// Apps of one family open in the same minute count that minute once.
|
||||
overlapTemplateID := uuid.New()
|
||||
overlapUserID := uuid.New()
|
||||
insertStat(5*time.Second, overlapTemplateID, overlapUserID, uuid.New(), 1, map[string]int64{"vscode": 1, "cursor": 1, "zed": 1, "ssh": 1})
|
||||
insertStat(10*time.Second, overlapTemplateID, overlapUserID, uuid.New(), 0, map[string]int64{"port_forwarding": 1, "some_new_ide": 1, "overflow": 1})
|
||||
insertStat(time.Minute+5*time.Second, overlapTemplateID, overlapUserID, uuid.New(), 0, map[string]int64{"cursor": 1})
|
||||
|
||||
insights, err := db.GetTemplateInsightsByTemplate(ctx, templateInsightsByTemplateParams(t, startTime, endTime))
|
||||
require.NoError(t, err)
|
||||
byTemplate := make(map[uuid.UUID]database.GetTemplateInsightsByTemplateRow)
|
||||
for _, row := range insights {
|
||||
byTemplate[row.TemplateID] = row
|
||||
}
|
||||
require.Len(t, byTemplate, 2)
|
||||
require.Len(t, byTemplate, 3)
|
||||
require.EqualValues(t, 2, byTemplate[templateID].ActiveUsers)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 120, "jetbrains": 60, "reconnecting_pty": 60, "ssh": 120, "unknown": 60}, byTemplate[templateID].SessionAppUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 120, "jetbrains": 60, "reconnecting_pty": 60, "ssh": 120, "unknown": 60}, byTemplate[templateID].SessionFamilyUsageSeconds)
|
||||
require.EqualValues(t, 1, byTemplate[sharedConnectionTemplateID].ActiveUsers)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 60, "unknown": 60}, byTemplate[sharedConnectionTemplateID].SessionAppUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 60, "unknown": 60}, byTemplate[sharedConnectionTemplateID].SessionFamilyUsageSeconds)
|
||||
require.EqualValues(t, 1, byTemplate[overlapTemplateID].ActiveUsers)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 120, "ssh": 60, "port_forwarding": 60, "unknown": 60}, byTemplate[overlapTemplateID].SessionFamilyUsageSeconds)
|
||||
}
|
||||
|
||||
func templateInsightsByTemplateParams(t *testing.T, startTime, endTime time.Time) database.GetTemplateInsightsByTemplateParams {
|
||||
t.Helper()
|
||||
appFamilies, err := json.Marshal(codersdk.SessionCountAppFamilies())
|
||||
require.NoError(t, err)
|
||||
return database.GetTemplateInsightsByTemplateParams{StartTime: startTime, EndTime: endTime, AppFamilies: appFamilies}
|
||||
}
|
||||
|
||||
func TestGetWorkspaceAgentUsageStats(t *testing.T) {
|
||||
@@ -19474,24 +19487,21 @@ func TestSessionCountsAttributeByFamily(t *testing.T) {
|
||||
require.Zero(t, sessionFamilyCounts(t, stats.SessionCounts)["jetbrains"])
|
||||
require.Zero(t, sessionFamilyCounts(t, stats.SessionCounts)["reconnecting_pty"])
|
||||
|
||||
insights, err := db.GetTemplateInsightsByTemplate(ctx, database.GetTemplateInsightsByTemplateParams{
|
||||
StartTime: dbtime.Now().Add(-time.Hour),
|
||||
EndTime: dbtime.Now().Add(time.Hour),
|
||||
})
|
||||
insights, err := db.GetTemplateInsightsByTemplate(ctx, templateInsightsByTemplateParams(t, dbtime.Now().Add(-time.Hour), dbtime.Now().Add(time.Hour)))
|
||||
require.NoError(t, err)
|
||||
|
||||
byTemplate := make(map[uuid.UUID]database.GetTemplateInsightsByTemplateRow, len(insights))
|
||||
for _, row := range insights {
|
||||
byTemplate[row.TemplateID] = row
|
||||
}
|
||||
require.Equal(t, database.StringMapOfInt{"cursor": 60}, byTemplate[cursorTemplate].SessionAppUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"zed": 60}, byTemplate[zedTemplate].SessionAppUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"vscode": 60}, byTemplate[cursorTemplate].SessionFamilyUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"ssh": 60}, byTemplate[zedTemplate].SessionFamilyUsageSeconds)
|
||||
|
||||
// An app with no family is still activity, so the user is not counted idle.
|
||||
unknown, ok := byTemplate[unknownTemplate]
|
||||
require.True(t, ok, "a session with no family must still appear as usage")
|
||||
require.Equal(t, int64(1), unknown.ActiveUsers)
|
||||
require.Equal(t, database.StringMapOfInt{"some_new_ide": 60}, unknown.SessionAppUsageSeconds)
|
||||
require.Equal(t, database.StringMapOfInt{"unknown": 60}, unknown.SessionFamilyUsageSeconds)
|
||||
}
|
||||
|
||||
// The rollup stores the app name the agent reported, whether or not the
|
||||
|
||||
Generated
+43
-26
@@ -18284,14 +18284,14 @@ WITH
|
||||
BOOL_OR(connection_count > 0)
|
||||
),
|
||||
insights AS (
|
||||
-- A minute counts once per app however many of its sessions were open,
|
||||
-- which COUNT(DISTINCT) does in the grouping. Deduplicating the
|
||||
-- A minute counts once per family, however many of its apps were
|
||||
-- open, which COUNT(DISTINCT) does in the grouping. Deduplicating the
|
||||
-- expanded rows first instead spills to disk once a deployment has a
|
||||
-- few thousand agents.
|
||||
SELECT
|
||||
was.template_id,
|
||||
was.user_id,
|
||||
app_name,
|
||||
COALESCE($3::jsonb ->> app_name, 'unknown') AS family,
|
||||
COUNT(DISTINCT date_trunc('minute', was.created_at)) AS usage_mins
|
||||
FROM
|
||||
workspace_agent_stats AS was
|
||||
@@ -18307,22 +18307,22 @@ WITH
|
||||
AND was.created_at < $2::timestamptz
|
||||
AND was.session_counts <> '{}'::jsonb
|
||||
GROUP BY
|
||||
was.template_id, was.user_id, app_name
|
||||
was.template_id, was.user_id, family
|
||||
),
|
||||
app_usage AS (
|
||||
app_family_usage AS (
|
||||
SELECT
|
||||
template_id,
|
||||
jsonb_object_agg(app_name, usage_seconds) AS session_app_usage_seconds
|
||||
jsonb_object_agg(family, usage_seconds) AS session_family_usage_seconds
|
||||
FROM (
|
||||
SELECT
|
||||
template_id,
|
||||
app_name,
|
||||
family,
|
||||
(SUM(usage_mins) * 60)::bigint AS usage_seconds
|
||||
FROM
|
||||
insights
|
||||
GROUP BY
|
||||
template_id, app_name
|
||||
) AS app_seconds
|
||||
template_id, family
|
||||
) AS family_seconds
|
||||
GROUP BY
|
||||
template_id
|
||||
),
|
||||
@@ -18339,35 +18339,38 @@ WITH
|
||||
SELECT
|
||||
active_users.template_id,
|
||||
active_users.active_users,
|
||||
app_usage.session_app_usage_seconds
|
||||
app_family_usage.session_family_usage_seconds
|
||||
FROM
|
||||
active_users
|
||||
JOIN
|
||||
-- Every counted template has at least one app; both sides come from
|
||||
-- Every counted template has at least one family; both sides come from
|
||||
-- insights.
|
||||
app_usage
|
||||
app_family_usage
|
||||
ON
|
||||
app_usage.template_id = active_users.template_id
|
||||
app_family_usage.template_id = active_users.template_id
|
||||
`
|
||||
|
||||
type GetTemplateInsightsByTemplateParams struct {
|
||||
StartTime time.Time `db:"start_time" json:"start_time"`
|
||||
EndTime time.Time `db:"end_time" json:"end_time"`
|
||||
StartTime time.Time `db:"start_time" json:"start_time"`
|
||||
EndTime time.Time `db:"end_time" json:"end_time"`
|
||||
AppFamilies json.RawMessage `db:"app_families" json:"app_families"`
|
||||
}
|
||||
|
||||
type GetTemplateInsightsByTemplateRow struct {
|
||||
TemplateID uuid.UUID `db:"template_id" json:"template_id"`
|
||||
ActiveUsers int64 `db:"active_users" json:"active_users"`
|
||||
SessionAppUsageSeconds StringMapOfInt `db:"session_app_usage_seconds" json:"session_app_usage_seconds"`
|
||||
TemplateID uuid.UUID `db:"template_id" json:"template_id"`
|
||||
ActiveUsers int64 `db:"active_users" json:"active_users"`
|
||||
SessionFamilyUsageSeconds StringMapOfInt `db:"session_family_usage_seconds" json:"session_family_usage_seconds"`
|
||||
}
|
||||
|
||||
// GetTemplateInsightsByTemplate is used for Prometheus metrics. Keep
|
||||
// in sync with GetTemplateInsights and UpsertTemplateUsageStats.
|
||||
//
|
||||
// Session usage comes out per app name, as in GetTemplateInsights, so either
|
||||
// query reports the same family totals once the names are grouped.
|
||||
// Session usage is reported per app family. It reads the raw agent stats
|
||||
// because the rollup stores minutes per app, which can't show whether two
|
||||
// apps of one family were open in the same minute. @app_families maps each
|
||||
// app name to its family; names missing from the map count as unknown.
|
||||
func (q *sqlQuerier) GetTemplateInsightsByTemplate(ctx context.Context, arg GetTemplateInsightsByTemplateParams) ([]GetTemplateInsightsByTemplateRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTemplateInsightsByTemplate, arg.StartTime, arg.EndTime)
|
||||
rows, err := q.db.QueryContext(ctx, getTemplateInsightsByTemplate, arg.StartTime, arg.EndTime, arg.AppFamilies)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -18375,7 +18378,7 @@ func (q *sqlQuerier) GetTemplateInsightsByTemplate(ctx context.Context, arg GetT
|
||||
var items []GetTemplateInsightsByTemplateRow
|
||||
for rows.Next() {
|
||||
var i GetTemplateInsightsByTemplateRow
|
||||
if err := rows.Scan(&i.TemplateID, &i.ActiveUsers, &i.SessionAppUsageSeconds); err != nil {
|
||||
if err := rows.Scan(&i.TemplateID, &i.ActiveUsers, &i.SessionFamilyUsageSeconds); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
@@ -42228,7 +42231,7 @@ func (q *sqlQuerier) UpdateWorkspacesTTLByTemplateID(ctx context.Context, arg Up
|
||||
|
||||
const getWorkspaceAgentScriptsByAgentIDs = `-- name: GetWorkspaceAgentScriptsByAgentIDs :many
|
||||
SELECT
|
||||
DISTINCT ON (workspace_agent_scripts.id) workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds, workspace_agent_scripts.display_name, workspace_agent_scripts.id,
|
||||
DISTINCT ON (workspace_agent_scripts.id) workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds, workspace_agent_scripts.display_name, workspace_agent_scripts.id, workspace_agent_scripts.resource_address, workspace_agent_scripts.dependencies,
|
||||
workspace_agent_script_timings.exit_code,
|
||||
workspace_agent_script_timings.status
|
||||
FROM workspace_agent_scripts
|
||||
@@ -42252,6 +42255,8 @@ type GetWorkspaceAgentScriptsByAgentIDsRow struct {
|
||||
TimeoutSeconds int32 `db:"timeout_seconds" json:"timeout_seconds"`
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
ResourceAddress string `db:"resource_address" json:"resource_address"`
|
||||
Dependencies json.RawMessage `db:"dependencies" json:"dependencies"`
|
||||
ExitCode sql.NullInt32 `db:"exit_code" json:"exit_code"`
|
||||
Status NullWorkspaceAgentScriptTimingStatus `db:"status" json:"status"`
|
||||
}
|
||||
@@ -42278,6 +42283,8 @@ func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids
|
||||
&i.TimeoutSeconds,
|
||||
&i.DisplayName,
|
||||
&i.ID,
|
||||
&i.ResourceAddress,
|
||||
&i.Dependencies,
|
||||
&i.ExitCode,
|
||||
&i.Status,
|
||||
); err != nil {
|
||||
@@ -42296,7 +42303,7 @@ func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids
|
||||
|
||||
const insertWorkspaceAgentScripts = `-- name: InsertWorkspaceAgentScripts :many
|
||||
INSERT INTO
|
||||
workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds, display_name, id)
|
||||
workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds, display_name, id, resource_address, dependencies)
|
||||
SELECT
|
||||
$1 :: uuid AS workspace_agent_id,
|
||||
$2 :: timestamptz AS created_at,
|
||||
@@ -42309,8 +42316,12 @@ SELECT
|
||||
unnest($9 :: boolean [ ]) AS run_on_stop,
|
||||
unnest($10 :: integer [ ]) AS timeout_seconds,
|
||||
unnest($11 :: text [ ]) AS display_name,
|
||||
unnest($12 :: uuid [ ]) AS id
|
||||
RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds, workspace_agent_scripts.display_name, workspace_agent_scripts.id
|
||||
unnest($12 :: uuid [ ]) AS id,
|
||||
unnest($13 :: text [ ]) AS resource_address,
|
||||
-- The driver accepts a text array more reliably than a jsonb array,
|
||||
-- so each element is cast to jsonb inside the query.
|
||||
unnest($14 :: text [ ]) :: jsonb AS dependencies
|
||||
RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds, workspace_agent_scripts.display_name, workspace_agent_scripts.id, workspace_agent_scripts.resource_address, workspace_agent_scripts.dependencies
|
||||
`
|
||||
|
||||
type InsertWorkspaceAgentScriptsParams struct {
|
||||
@@ -42326,6 +42337,8 @@ type InsertWorkspaceAgentScriptsParams struct {
|
||||
TimeoutSeconds []int32 `db:"timeout_seconds" json:"timeout_seconds"`
|
||||
DisplayName []string `db:"display_name" json:"display_name"`
|
||||
ID []uuid.UUID `db:"id" json:"id"`
|
||||
ResourceAddress []string `db:"resource_address" json:"resource_address"`
|
||||
Dependencies []string `db:"dependencies" json:"dependencies"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg InsertWorkspaceAgentScriptsParams) ([]WorkspaceAgentScript, error) {
|
||||
@@ -42342,6 +42355,8 @@ func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg Insert
|
||||
pq.Array(arg.TimeoutSeconds),
|
||||
pq.Array(arg.DisplayName),
|
||||
pq.Array(arg.ID),
|
||||
pq.Array(arg.ResourceAddress),
|
||||
pq.Array(arg.Dependencies),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -42363,6 +42378,8 @@ func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg Insert
|
||||
&i.TimeoutSeconds,
|
||||
&i.DisplayName,
|
||||
&i.ID,
|
||||
&i.ResourceAddress,
|
||||
&i.Dependencies,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -211,8 +211,10 @@ FROM
|
||||
-- GetTemplateInsightsByTemplate is used for Prometheus metrics. Keep
|
||||
-- in sync with GetTemplateInsights and UpsertTemplateUsageStats.
|
||||
--
|
||||
-- Session usage comes out per app name, as in GetTemplateInsights, so either
|
||||
-- query reports the same family totals once the names are grouped.
|
||||
-- Session usage is reported per app family. It reads the raw agent stats
|
||||
-- because the rollup stores minutes per app, which can't show whether two
|
||||
-- apps of one family were open in the same minute. @app_families maps each
|
||||
-- app name to its family; names missing from the map count as unknown.
|
||||
WITH
|
||||
connected AS (
|
||||
-- NOTE(mafredri): connection_count covers one report interval, while
|
||||
@@ -235,14 +237,14 @@ WITH
|
||||
BOOL_OR(connection_count > 0)
|
||||
),
|
||||
insights AS (
|
||||
-- A minute counts once per app however many of its sessions were open,
|
||||
-- which COUNT(DISTINCT) does in the grouping. Deduplicating the
|
||||
-- A minute counts once per family, however many of its apps were
|
||||
-- open, which COUNT(DISTINCT) does in the grouping. Deduplicating the
|
||||
-- expanded rows first instead spills to disk once a deployment has a
|
||||
-- few thousand agents.
|
||||
SELECT
|
||||
was.template_id,
|
||||
was.user_id,
|
||||
app_name,
|
||||
COALESCE(@app_families::jsonb ->> app_name, 'unknown') AS family,
|
||||
COUNT(DISTINCT date_trunc('minute', was.created_at)) AS usage_mins
|
||||
FROM
|
||||
workspace_agent_stats AS was
|
||||
@@ -258,22 +260,22 @@ WITH
|
||||
AND was.created_at < @end_time::timestamptz
|
||||
AND was.session_counts <> '{}'::jsonb
|
||||
GROUP BY
|
||||
was.template_id, was.user_id, app_name
|
||||
was.template_id, was.user_id, family
|
||||
),
|
||||
app_usage AS (
|
||||
app_family_usage AS (
|
||||
SELECT
|
||||
template_id,
|
||||
jsonb_object_agg(app_name, usage_seconds) AS session_app_usage_seconds
|
||||
jsonb_object_agg(family, usage_seconds) AS session_family_usage_seconds
|
||||
FROM (
|
||||
SELECT
|
||||
template_id,
|
||||
app_name,
|
||||
family,
|
||||
(SUM(usage_mins) * 60)::bigint AS usage_seconds
|
||||
FROM
|
||||
insights
|
||||
GROUP BY
|
||||
template_id, app_name
|
||||
) AS app_seconds
|
||||
template_id, family
|
||||
) AS family_seconds
|
||||
GROUP BY
|
||||
template_id
|
||||
),
|
||||
@@ -290,15 +292,15 @@ WITH
|
||||
SELECT
|
||||
active_users.template_id,
|
||||
active_users.active_users,
|
||||
app_usage.session_app_usage_seconds
|
||||
app_family_usage.session_family_usage_seconds
|
||||
FROM
|
||||
active_users
|
||||
JOIN
|
||||
-- Every counted template has at least one app; both sides come from
|
||||
-- Every counted template has at least one family; both sides come from
|
||||
-- insights.
|
||||
app_usage
|
||||
app_family_usage
|
||||
ON
|
||||
app_usage.template_id = active_users.template_id;
|
||||
app_family_usage.template_id = active_users.template_id;
|
||||
|
||||
-- name: GetTemplateAppInsights :many
|
||||
-- GetTemplateAppInsights returns the aggregate usage of each app in a given
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- name: InsertWorkspaceAgentScripts :many
|
||||
INSERT INTO
|
||||
workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds, display_name, id)
|
||||
workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds, display_name, id, resource_address, dependencies)
|
||||
SELECT
|
||||
@workspace_agent_id :: uuid AS workspace_agent_id,
|
||||
@created_at :: timestamptz AS created_at,
|
||||
@@ -13,7 +13,11 @@ SELECT
|
||||
unnest(@run_on_stop :: boolean [ ]) AS run_on_stop,
|
||||
unnest(@timeout_seconds :: integer [ ]) AS timeout_seconds,
|
||||
unnest(@display_name :: text [ ]) AS display_name,
|
||||
unnest(@id :: uuid [ ]) AS id
|
||||
unnest(@id :: uuid [ ]) AS id,
|
||||
unnest(@resource_address :: text [ ]) AS resource_address,
|
||||
-- The driver accepts a text array more reliably than a jsonb array,
|
||||
-- so each element is cast to jsonb inside the query.
|
||||
unnest(@dependencies :: text [ ]) :: jsonb AS dependencies
|
||||
RETURNING workspace_agent_scripts.*;
|
||||
|
||||
-- name: GetWorkspaceAgentScriptsByAgentIDs :many
|
||||
|
||||
@@ -140,10 +140,8 @@ func TestSessionUsageRollup(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, sessionUsageMins(ctx, t, sqlDB, start, user, template))
|
||||
|
||||
// Live insights report the raw app names without half-hour caps.
|
||||
live, err := db.GetTemplateInsightsByTemplate(ctx, database.GetTemplateInsightsByTemplateParams{
|
||||
StartTime: start.Add(30 * time.Second), EndTime: start.Add(30 * time.Minute),
|
||||
})
|
||||
// Live insights count distinct minutes per family, with no 30-minute cap.
|
||||
live, err := db.GetTemplateInsightsByTemplate(ctx, templateInsightsByTemplateParams(t, start.Add(30*time.Second), start.Add(30*time.Minute)))
|
||||
require.NoError(t, err)
|
||||
require.Len(t, live, 0, "no connected report occurs in this partial request window")
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ sql:
|
||||
- column: "template_usage_stats.app_usage_mins"
|
||||
go_type:
|
||||
type: "StringMapOfInt"
|
||||
- column: "app_usage.session_app_usage_seconds"
|
||||
- column: "app_family_usage.session_family_usage_seconds"
|
||||
go_type:
|
||||
type: "StringMapOfInt"
|
||||
- column: "tasks_with_status.workspace_user_acl"
|
||||
|
||||
+5
-5
@@ -601,7 +601,7 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
|
||||
{
|
||||
TemplateIDs: templateIDs(codersdk.AppFamilyVSCode),
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameVSCode,
|
||||
DisplayName: codersdk.AppFamilyVSCode.DisplayName(),
|
||||
Slug: "vscode",
|
||||
Icon: "/icon/code.svg",
|
||||
Seconds: usageSeconds[codersdk.AppFamilyVSCode],
|
||||
@@ -609,7 +609,7 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
|
||||
{
|
||||
TemplateIDs: templateIDs(codersdk.AppFamilyJetBrains),
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameJetBrains,
|
||||
DisplayName: codersdk.AppFamilyJetBrains.DisplayName(),
|
||||
Slug: "jetbrains",
|
||||
Icon: "/icon/intellij.svg",
|
||||
Seconds: usageSeconds[codersdk.AppFamilyJetBrains],
|
||||
@@ -623,7 +623,7 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
|
||||
{
|
||||
TemplateIDs: templateIDs(codersdk.AppFamilyReconnectingPTY),
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameWebTerminal,
|
||||
DisplayName: codersdk.AppFamilyReconnectingPTY.DisplayName(),
|
||||
Slug: "reconnecting-pty",
|
||||
Icon: "/icon/terminal.svg",
|
||||
Seconds: usageSeconds[codersdk.AppFamilyReconnectingPTY],
|
||||
@@ -631,7 +631,7 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
|
||||
{
|
||||
TemplateIDs: templateIDs(codersdk.AppFamilySSH),
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameSSH,
|
||||
DisplayName: codersdk.AppFamilySSH.DisplayName(),
|
||||
Slug: "ssh",
|
||||
Icon: "/icon/terminal.svg",
|
||||
Seconds: usageSeconds[codersdk.AppFamilySSH],
|
||||
@@ -639,7 +639,7 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
|
||||
{
|
||||
TemplateIDs: templateIDs(codersdk.AppFamilySFTP),
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameSFTP,
|
||||
DisplayName: codersdk.AppFamilySFTP.DisplayName(),
|
||||
Slug: "sftp",
|
||||
Icon: "/icon/terminal.svg",
|
||||
Seconds: usageSeconds[codersdk.AppFamilySFTP],
|
||||
|
||||
@@ -399,7 +399,7 @@ func TestConvertTemplateInsightsApps(t *testing.T) {
|
||||
// from the old sftp_mins column still report it.
|
||||
TemplateIDs: []uuid.UUID{sftpTemplateID},
|
||||
Type: codersdk.TemplateAppsTypeBuiltin,
|
||||
DisplayName: codersdk.TemplateBuiltinAppDisplayNameSFTP,
|
||||
DisplayName: codersdk.AppFamilySFTP.DisplayName(),
|
||||
Slug: "sftp",
|
||||
Icon: "/icon/terminal.svg",
|
||||
Seconds: 300,
|
||||
|
||||
@@ -2,6 +2,7 @@ package insights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"slices"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -20,7 +21,7 @@ import (
|
||||
|
||||
var (
|
||||
templatesActiveUsersDesc = prometheus.NewDesc("coderd_insights_templates_active_users", "The number of active users of the template.", []string{"template_name", "organization_name"}, nil)
|
||||
applicationsUsageSecondsDesc = prometheus.NewDesc("coderd_insights_applications_usage_seconds", "The application usage per template.", []string{"template_name", "application_name", "slug", "organization_name"}, nil)
|
||||
applicationsUsageSecondsDesc = prometheus.NewDesc("coderd_insights_applications_usage_seconds", "The application usage per template. Built-in apps are grouped by app family, such as Visual Studio Code, JetBrains, Web Terminal, or SSH, with an empty slug. A user-minute counts once per family.", []string{"template_name", "application_name", "slug", "organization_name"}, nil)
|
||||
parametersDesc = prometheus.NewDesc("coderd_insights_parameters", "The parameter usage per template.", []string{"template_name", "parameter_name", "parameter_type", "parameter_value", "organization_name"}, nil)
|
||||
)
|
||||
|
||||
@@ -29,12 +30,13 @@ type MetricsCollector struct {
|
||||
logger slog.Logger
|
||||
timeWindow time.Duration
|
||||
tickInterval time.Duration
|
||||
appFamilies json.RawMessage
|
||||
|
||||
data atomic.Pointer[insightsData]
|
||||
}
|
||||
|
||||
type insightsData struct {
|
||||
templates []templateInsightsRow
|
||||
templates []database.GetTemplateInsightsByTemplateRow
|
||||
apps []database.GetTemplateAppInsightsByTemplateRow
|
||||
params []parameterRow
|
||||
|
||||
@@ -42,14 +44,6 @@ type insightsData struct {
|
||||
organizationNames map[uuid.UUID]string // template ID → org name
|
||||
}
|
||||
|
||||
// templateInsightsRow is a GetTemplateInsightsByTemplateRow with its session
|
||||
// usage decoded and grouped into families.
|
||||
type templateInsightsRow struct {
|
||||
templateID uuid.UUID
|
||||
activeUsers int64
|
||||
usageSecondsByFamily map[codersdk.AppFamilyName]int64
|
||||
}
|
||||
|
||||
type parameterRow struct {
|
||||
templateID uuid.UUID
|
||||
name string
|
||||
@@ -71,12 +65,17 @@ func NewMetricsCollector(db database.Store, logger slog.Logger, timeWindow time.
|
||||
if tickInterval == 0 {
|
||||
tickInterval = timeWindow
|
||||
}
|
||||
appFamilies, err := json.Marshal(codersdk.SessionCountAppFamilies())
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("marshal app families: %w", err)
|
||||
}
|
||||
|
||||
return &MetricsCollector{
|
||||
database: db,
|
||||
logger: logger.Named("insights_metrics_collector"),
|
||||
timeWindow: timeWindow,
|
||||
tickInterval: tickInterval,
|
||||
appFamilies: appFamilies,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -99,21 +98,21 @@ func (mc *MetricsCollector) Run(ctx context.Context) (func(), error) {
|
||||
eg, egCtx := errgroup.WithContext(ctx)
|
||||
eg.SetLimit(3)
|
||||
|
||||
var templateInsights []templateInsightsRow
|
||||
var templateInsights []database.GetTemplateInsightsByTemplateRow
|
||||
var appInsights []database.GetTemplateAppInsightsByTemplateRow
|
||||
var paramInsights []parameterRow
|
||||
|
||||
eg.Go(func() error {
|
||||
rows, err := mc.database.GetTemplateInsightsByTemplate(egCtx, database.GetTemplateInsightsByTemplateParams{
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
var err error
|
||||
templateInsights, err = mc.database.GetTemplateInsightsByTemplate(egCtx, database.GetTemplateInsightsByTemplateParams{
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
AppFamilies: mc.appFamilies,
|
||||
})
|
||||
if err != nil {
|
||||
mc.logger.Error(ctx, "unable to fetch template insights from database", slog.Error(err))
|
||||
return err
|
||||
}
|
||||
templateInsights = convertTemplateInsights(rows)
|
||||
return nil
|
||||
return err
|
||||
})
|
||||
eg.Go(func() error {
|
||||
var err error
|
||||
@@ -234,38 +233,21 @@ func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric) {
|
||||
appRow.DisplayName, appRow.SlugOrPort, data.organizationNames[appRow.TemplateID])
|
||||
}
|
||||
|
||||
// Built-in apps
|
||||
// Built-in apps, one series per app family.
|
||||
for _, templateRow := range data.templates {
|
||||
orgName := data.organizationNames[templateRow.templateID]
|
||||
|
||||
metricsCh <- prometheus.MustNewConstMetric(applicationsUsageSecondsDesc, prometheus.GaugeValue,
|
||||
float64(templateRow.usageSecondsByFamily[codersdk.AppFamilyVSCode]),
|
||||
data.templateNames[templateRow.templateID],
|
||||
codersdk.TemplateBuiltinAppDisplayNameVSCode,
|
||||
"", orgName)
|
||||
|
||||
metricsCh <- prometheus.MustNewConstMetric(applicationsUsageSecondsDesc, prometheus.GaugeValue,
|
||||
float64(templateRow.usageSecondsByFamily[codersdk.AppFamilyJetBrains]),
|
||||
data.templateNames[templateRow.templateID],
|
||||
codersdk.TemplateBuiltinAppDisplayNameJetBrains,
|
||||
"", orgName)
|
||||
|
||||
metricsCh <- prometheus.MustNewConstMetric(applicationsUsageSecondsDesc, prometheus.GaugeValue,
|
||||
float64(templateRow.usageSecondsByFamily[codersdk.AppFamilyReconnectingPTY]),
|
||||
data.templateNames[templateRow.templateID],
|
||||
codersdk.TemplateBuiltinAppDisplayNameWebTerminal,
|
||||
"", orgName)
|
||||
|
||||
metricsCh <- prometheus.MustNewConstMetric(applicationsUsageSecondsDesc, prometheus.GaugeValue,
|
||||
float64(templateRow.usageSecondsByFamily[codersdk.AppFamilySSH]),
|
||||
data.templateNames[templateRow.templateID],
|
||||
codersdk.TemplateBuiltinAppDisplayNameSSH,
|
||||
"", orgName)
|
||||
orgName := data.organizationNames[templateRow.TemplateID]
|
||||
for _, family := range appFamilySeries {
|
||||
metricsCh <- prometheus.MustNewConstMetric(applicationsUsageSecondsDesc, prometheus.GaugeValue,
|
||||
float64(templateRow.SessionFamilyUsageSeconds[string(family)]),
|
||||
data.templateNames[templateRow.TemplateID],
|
||||
family.DisplayName(),
|
||||
"", orgName)
|
||||
}
|
||||
}
|
||||
|
||||
// Templates
|
||||
for _, templateRow := range data.templates {
|
||||
metricsCh <- prometheus.MustNewConstMetric(templatesActiveUsersDesc, prometheus.GaugeValue, float64(templateRow.activeUsers), data.templateNames[templateRow.templateID], data.organizationNames[templateRow.templateID])
|
||||
metricsCh <- prometheus.MustNewConstMetric(templatesActiveUsersDesc, prometheus.GaugeValue, float64(templateRow.ActiveUsers), data.templateNames[templateRow.TemplateID], data.organizationNames[templateRow.TemplateID])
|
||||
}
|
||||
|
||||
// Parameters
|
||||
@@ -276,10 +258,10 @@ func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric) {
|
||||
|
||||
// Helper functions below.
|
||||
|
||||
func uniqueTemplateIDs(templateInsights []templateInsightsRow, appInsights []database.GetTemplateAppInsightsByTemplateRow, paramInsights []parameterRow) []uuid.UUID {
|
||||
func uniqueTemplateIDs(templateInsights []database.GetTemplateInsightsByTemplateRow, appInsights []database.GetTemplateAppInsightsByTemplateRow, paramInsights []parameterRow) []uuid.UUID {
|
||||
tids := map[uuid.UUID]bool{}
|
||||
for _, t := range templateInsights {
|
||||
tids[t.templateID] = true
|
||||
tids[t.TemplateID] = true
|
||||
}
|
||||
for _, t := range appInsights {
|
||||
tids[t.TemplateID] = true
|
||||
@@ -305,18 +287,12 @@ func onlyTemplateNames(templates []database.Template) map[uuid.UUID]string {
|
||||
return m
|
||||
}
|
||||
|
||||
// convertTemplateInsights groups each row's per-app session usage into
|
||||
// families.
|
||||
func convertTemplateInsights(rows []database.GetTemplateInsightsByTemplateRow) []templateInsightsRow {
|
||||
converted := make([]templateInsightsRow, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
converted = append(converted, templateInsightsRow{
|
||||
templateID: row.TemplateID,
|
||||
activeUsers: row.ActiveUsers,
|
||||
usageSecondsByFamily: codersdk.SumByFamily(row.SessionAppUsageSeconds),
|
||||
})
|
||||
}
|
||||
return converted
|
||||
// appFamilySeries lists the app families reported as built-in app series.
|
||||
var appFamilySeries = []codersdk.AppFamilyName{
|
||||
codersdk.AppFamilyVSCode,
|
||||
codersdk.AppFamilyJetBrains,
|
||||
codersdk.AppFamilyReconnectingPTY,
|
||||
codersdk.AppFamilySSH,
|
||||
}
|
||||
|
||||
func convertParameterInsights(rows []database.GetTemplateParameterInsightsRow) []parameterRow {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package insights
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
)
|
||||
|
||||
func TestConvertTemplateInsights(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rows := convertTemplateInsights([]database.GetTemplateInsightsByTemplateRow{
|
||||
{
|
||||
TemplateID: uuid.New(),
|
||||
SessionAppUsageSeconds: database.StringMapOfInt{"vscode": 300, "cursor": 120, "zed": 60},
|
||||
},
|
||||
})
|
||||
require.Len(t, rows, 1)
|
||||
require.EqualValues(t, 420, rows[0].usageSecondsByFamily[codersdk.AppFamilyVSCode])
|
||||
require.EqualValues(t, 60, rows[0].usageSecondsByFamily[codersdk.AppFamilySSH])
|
||||
}
|
||||
@@ -112,10 +112,15 @@ func TestCollectInsights(t *testing.T) {
|
||||
ConnectionCount: 1,
|
||||
ConnectionMedianLatencyMs: 15,
|
||||
// Session counts must be positive, but the exact value is ignored.
|
||||
// Database query approximates it to 60s of usage.
|
||||
SessionCountSsh: 99,
|
||||
SessionCountJetbrains: 47,
|
||||
SessionCountVscode: 34,
|
||||
// The query counts 60s per family, however many of its apps
|
||||
// report: cursor counts toward VS Code and zed toward SSH.
|
||||
SessionCounts: map[string]int64{
|
||||
"vscode": 34,
|
||||
"cursor": 2,
|
||||
"jetbrains": 47,
|
||||
"ssh": 99,
|
||||
"zed": 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err, "unable to post fake stats")
|
||||
|
||||
@@ -3037,7 +3037,10 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
}
|
||||
}
|
||||
|
||||
scriptsParams := agentScriptsFromProto(prAgent.Scripts)
|
||||
scriptsParams, err := agentScriptsFromProto(prAgent.Scripts)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("convert agent scripts: %w", err)
|
||||
}
|
||||
|
||||
// Dev Containers require a script and log/source, so we do this before
|
||||
// the logs insert below.
|
||||
@@ -3084,6 +3087,10 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
scriptsParams.ScriptStartBlocksLogin = append(scriptsParams.ScriptStartBlocksLogin, false)
|
||||
scriptsParams.ScriptRunOnStart = append(scriptsParams.ScriptRunOnStart, false)
|
||||
scriptsParams.ScriptRunOnStop = append(scriptsParams.ScriptRunOnStop, false)
|
||||
// Every slice must stay the same length: unnest pads a short
|
||||
// array with NULL and the NOT NULL columns reject the insert.
|
||||
scriptsParams.ScriptResourceAddresses = append(scriptsParams.ScriptResourceAddresses, "")
|
||||
scriptsParams.ScriptDependencies = append(scriptsParams.ScriptDependencies, "[]")
|
||||
}
|
||||
|
||||
_, err = db.InsertWorkspaceAgentDevcontainers(ctx, database.InsertWorkspaceAgentDevcontainersParams{
|
||||
@@ -3533,7 +3540,11 @@ func insertDevcontainerSubagent(
|
||||
}
|
||||
}
|
||||
|
||||
if err := insertAgentScriptsAndLogSources(ctx, db, subAgentID, agentScriptsFromProto(dc.GetScripts())); err != nil {
|
||||
dcScriptsParams, err := agentScriptsFromProto(dc.GetScripts())
|
||||
if err != nil {
|
||||
return uuid.UUID{}, xerrors.Errorf("convert devcontainer agent scripts: %w", err)
|
||||
}
|
||||
if err := insertAgentScriptsAndLogSources(ctx, db, subAgentID, dcScriptsParams); err != nil {
|
||||
return uuid.UUID{}, xerrors.Errorf("insert agent scripts and log sources: %w", err)
|
||||
}
|
||||
|
||||
@@ -3604,34 +3615,41 @@ type agentScriptsParams struct {
|
||||
LogSourceDisplayNames []string
|
||||
LogSourceIcons []string
|
||||
|
||||
ScriptIDs []uuid.UUID
|
||||
ScriptDisplayNames []string
|
||||
ScriptLogPaths []string
|
||||
ScriptSources []string
|
||||
ScriptCron []string
|
||||
ScriptTimeout []int32
|
||||
ScriptStartBlocksLogin []bool
|
||||
ScriptRunOnStart []bool
|
||||
ScriptRunOnStop []bool
|
||||
ScriptIDs []uuid.UUID
|
||||
ScriptDisplayNames []string
|
||||
ScriptLogPaths []string
|
||||
ScriptSources []string
|
||||
ScriptCron []string
|
||||
ScriptTimeout []int32
|
||||
ScriptStartBlocksLogin []bool
|
||||
ScriptRunOnStart []bool
|
||||
ScriptRunOnStop []bool
|
||||
ScriptResourceAddresses []string
|
||||
// ScriptDependencies holds one JSON array per script, "[]" when none.
|
||||
ScriptDependencies []string
|
||||
}
|
||||
|
||||
// agentScriptsFromProto converts a slice of proto scripts into the
|
||||
// agentScriptsParams struct needed for database insertion.
|
||||
func agentScriptsFromProto(scripts []*sdkproto.Script) agentScriptsParams {
|
||||
// agentScriptsParams struct needed for database insertion. It fails on a
|
||||
// dependency entry coderd cannot store, so the job fails before any row
|
||||
// is written.
|
||||
func agentScriptsFromProto(scripts []*sdkproto.Script) (agentScriptsParams, error) {
|
||||
params := agentScriptsParams{
|
||||
LogSourceIDs: make([]uuid.UUID, 0, len(scripts)),
|
||||
LogSourceDisplayNames: make([]string, 0, len(scripts)),
|
||||
LogSourceIcons: make([]string, 0, len(scripts)),
|
||||
|
||||
ScriptIDs: make([]uuid.UUID, 0, len(scripts)),
|
||||
ScriptDisplayNames: make([]string, 0, len(scripts)),
|
||||
ScriptLogPaths: make([]string, 0, len(scripts)),
|
||||
ScriptSources: make([]string, 0, len(scripts)),
|
||||
ScriptCron: make([]string, 0, len(scripts)),
|
||||
ScriptTimeout: make([]int32, 0, len(scripts)),
|
||||
ScriptStartBlocksLogin: make([]bool, 0, len(scripts)),
|
||||
ScriptRunOnStart: make([]bool, 0, len(scripts)),
|
||||
ScriptRunOnStop: make([]bool, 0, len(scripts)),
|
||||
ScriptIDs: make([]uuid.UUID, 0, len(scripts)),
|
||||
ScriptDisplayNames: make([]string, 0, len(scripts)),
|
||||
ScriptLogPaths: make([]string, 0, len(scripts)),
|
||||
ScriptSources: make([]string, 0, len(scripts)),
|
||||
ScriptCron: make([]string, 0, len(scripts)),
|
||||
ScriptTimeout: make([]int32, 0, len(scripts)),
|
||||
ScriptStartBlocksLogin: make([]bool, 0, len(scripts)),
|
||||
ScriptRunOnStart: make([]bool, 0, len(scripts)),
|
||||
ScriptRunOnStop: make([]bool, 0, len(scripts)),
|
||||
ScriptResourceAddresses: make([]string, 0, len(scripts)),
|
||||
ScriptDependencies: make([]string, 0, len(scripts)),
|
||||
}
|
||||
|
||||
for _, script := range scripts {
|
||||
@@ -3648,9 +3666,59 @@ func agentScriptsFromProto(scripts []*sdkproto.Script) agentScriptsParams {
|
||||
params.ScriptStartBlocksLogin = append(params.ScriptStartBlocksLogin, script.GetStartBlocksLogin())
|
||||
params.ScriptRunOnStart = append(params.ScriptRunOnStart, script.GetRunOnStart())
|
||||
params.ScriptRunOnStop = append(params.ScriptRunOnStop, script.GetRunOnStop())
|
||||
params.ScriptResourceAddresses = append(params.ScriptResourceAddresses, script.GetResourceAddress())
|
||||
|
||||
dependencies, err := scriptDependenciesJSON(script.GetDependencies())
|
||||
if err != nil {
|
||||
return agentScriptsParams{}, xerrors.Errorf("script %q dependencies: %w", script.GetResourceAddress(), err)
|
||||
}
|
||||
params.ScriptDependencies = append(params.ScriptDependencies, dependencies)
|
||||
}
|
||||
|
||||
return params
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// scriptDependenciesJSON encodes the provisioner's dependency list as the
|
||||
// JSON stored in workspace_agent_scripts.dependencies. The document is
|
||||
// []codersdk.WorkspaceAgentScriptDependency encoded with encoding/json, so
|
||||
// the row, the REST API and the manifest spell the list one way.
|
||||
func scriptDependenciesJSON(dependencies []*sdkproto.ScriptDependency) (string, error) {
|
||||
encoded := make([]codersdk.WorkspaceAgentScriptDependency, 0, len(dependencies))
|
||||
for i, dependency := range dependencies {
|
||||
requirement, err := scriptDependencyRequirementFromProto(dependency.GetRequirement())
|
||||
if err != nil {
|
||||
return "", xerrors.Errorf("dependency %d: %w", i, err)
|
||||
}
|
||||
if dependency.GetPrerequisiteResourceAddress() == "" {
|
||||
return "", xerrors.Errorf("dependency %d has an empty prerequisite resource address", i)
|
||||
}
|
||||
encoded = append(encoded, codersdk.WorkspaceAgentScriptDependency{
|
||||
PrerequisiteResourceAddress: dependency.GetPrerequisiteResourceAddress(),
|
||||
Requirement: requirement,
|
||||
})
|
||||
}
|
||||
|
||||
// An empty slice encodes as `[]`, never `null`, which the column's
|
||||
// array check would reject.
|
||||
data, err := json.Marshal(encoded)
|
||||
if err != nil {
|
||||
return "", xerrors.Errorf("marshal dependencies: %w", err)
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
// scriptDependencyRequirementFromProto maps the wire enum to the stored
|
||||
// string. UNSPECIFIED is an error: the provisioner never sends it, so
|
||||
// receiving it is a bug rather than a third kind of requirement.
|
||||
func scriptDependencyRequirementFromProto(requirement sdkproto.ScriptDependencyRequirement) (codersdk.WorkspaceAgentScriptDependencyRequirement, error) {
|
||||
switch requirement {
|
||||
case sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS:
|
||||
return codersdk.WorkspaceAgentScriptDependencyRequirementSuccess, nil
|
||||
case sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_COMPLETION:
|
||||
return codersdk.WorkspaceAgentScriptDependencyRequirementCompletion, nil
|
||||
default:
|
||||
return "", xerrors.Errorf("unsupported requirement %q", requirement)
|
||||
}
|
||||
}
|
||||
|
||||
// insertAgentScriptsAndLogSources inserts log sources and scripts for an agent (or
|
||||
@@ -3686,6 +3754,8 @@ func insertAgentScriptsAndLogSources(ctx context.Context, db database.Store, age
|
||||
RunOnStart: params.ScriptRunOnStart,
|
||||
RunOnStop: params.ScriptRunOnStop,
|
||||
DisplayName: params.ScriptDisplayNames,
|
||||
ResourceAddress: params.ScriptResourceAddresses,
|
||||
Dependencies: params.ScriptDependencies,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert scripts: %w", err)
|
||||
|
||||
@@ -3265,6 +3265,112 @@ func TestCompleteJob(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("WorkspaceBuildRejectsBadScriptDependency", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
srv, db, ps, pd := setup(t, false, &overrides{})
|
||||
|
||||
user := dbgen.User(t, db, database.User{})
|
||||
template := dbgen.Template(t, db, database.Template{
|
||||
CreatedBy: user.ID,
|
||||
Name: "template",
|
||||
Provisioner: database.ProvisionerTypeEcho,
|
||||
OrganizationID: pd.OrganizationID,
|
||||
})
|
||||
file := dbgen.File(t, db, database.File{CreatedBy: user.ID})
|
||||
workspaceTable := dbgen.Workspace(t, db, database.WorkspaceTable{
|
||||
TemplateID: template.ID,
|
||||
OwnerID: user.ID,
|
||||
OrganizationID: pd.OrganizationID,
|
||||
})
|
||||
version := dbgen.TemplateVersion(t, db, database.TemplateVersion{
|
||||
CreatedBy: user.ID,
|
||||
OrganizationID: pd.OrganizationID,
|
||||
TemplateID: uuid.NullUUID{
|
||||
UUID: template.ID,
|
||||
Valid: true,
|
||||
},
|
||||
JobID: uuid.New(),
|
||||
})
|
||||
buildID := uuid.New()
|
||||
job := dbgen.ProvisionerJob(t, db, ps, database.ProvisionerJob{
|
||||
FileID: file.ID,
|
||||
InitiatorID: user.ID,
|
||||
Type: database.ProvisionerJobTypeWorkspaceBuild,
|
||||
Input: must(json.Marshal(provisionerdserver.WorkspaceProvisionJob{
|
||||
WorkspaceBuildID: buildID,
|
||||
})),
|
||||
OrganizationID: pd.OrganizationID,
|
||||
})
|
||||
_ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
|
||||
ID: buildID,
|
||||
JobID: job.ID,
|
||||
WorkspaceID: workspaceTable.ID,
|
||||
InitiatorID: user.ID,
|
||||
TemplateVersionID: version.ID,
|
||||
Transition: database.WorkspaceTransitionStart,
|
||||
Reason: database.BuildReasonInitiator,
|
||||
})
|
||||
_, err := db.AcquireProvisionerJob(ctx, database.AcquireProvisionerJobParams{
|
||||
OrganizationID: pd.OrganizationID,
|
||||
WorkerID: uuid.NullUUID{
|
||||
UUID: pd.ID,
|
||||
Valid: true,
|
||||
},
|
||||
Types: []database.ProvisionerType{database.ProvisionerTypeEcho},
|
||||
ProvisionerTags: must(json.Marshal(job.Tags)),
|
||||
StartedAt: sql.NullTime{Time: job.CreatedAt, Valid: true},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = srv.CompleteJob(ctx, &proto.CompletedJob{
|
||||
JobId: job.ID.String(),
|
||||
Type: &proto.CompletedJob_WorkspaceBuild_{
|
||||
WorkspaceBuild: &proto.CompletedJob_WorkspaceBuild{
|
||||
State: []byte{},
|
||||
Resources: []*sdkproto.Resource{
|
||||
{
|
||||
Name: "vm-ok",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Name: "main",
|
||||
Auth: &sdkproto.Agent_Token{Token: uuid.NewString()},
|
||||
Scripts: []*sdkproto.Script{
|
||||
{DisplayName: "Clone repo", ResourceAddress: "coder_script.clone_repo"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
Name: "vm-bad",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Name: "other",
|
||||
Auth: &sdkproto.Agent_Token{Token: uuid.NewString()},
|
||||
Scripts: []*sdkproto.Script{
|
||||
{
|
||||
DisplayName: "Install tools",
|
||||
ResourceAddress: "coder_script.install_tools",
|
||||
Dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
// Requirement is left at UNSPECIFIED on purpose.
|
||||
}},
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.ErrorContains(t, err, `script "coder_script.install_tools" dependencies: dependency 0: unsupported requirement`)
|
||||
|
||||
// The first resource was valid, but the whole job rolls back.
|
||||
resources, err := db.GetWorkspaceResourcesByJobID(ctx, job.ID)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, resources, "the transaction must roll back every row of the job")
|
||||
})
|
||||
|
||||
t.Run("PrebuiltWorkspaceClaimWithResourceReplacements", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -3851,10 +3957,26 @@ func TestInsertWorkspaceResource(t *testing.T) {
|
||||
Value: "I laugh in the face of danger.",
|
||||
},
|
||||
},
|
||||
Scripts: []*sdkproto.Script{{
|
||||
DisplayName: "Startup",
|
||||
Icon: "/test.png",
|
||||
}},
|
||||
Scripts: []*sdkproto.Script{
|
||||
{
|
||||
// A legacy inline startup_script has no Terraform
|
||||
// address of its own.
|
||||
DisplayName: "Startup",
|
||||
Icon: "/test.png",
|
||||
},
|
||||
{
|
||||
DisplayName: "Clone repo",
|
||||
ResourceAddress: "coder_script.clone_repo",
|
||||
},
|
||||
{
|
||||
DisplayName: "Install tools",
|
||||
ResourceAddress: "coder_script.install_tools",
|
||||
Dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS,
|
||||
}},
|
||||
},
|
||||
},
|
||||
DisplayApps: &sdkproto.DisplayApps{
|
||||
Vscode: true,
|
||||
PortForwardingHelper: true,
|
||||
@@ -3887,6 +4009,48 @@ func TestInsertWorkspaceResource(t *testing.T) {
|
||||
database.DisplayAppSSHHelper,
|
||||
database.DisplayAppVscode,
|
||||
}, agent.DisplayApps)
|
||||
|
||||
scripts, err := db.GetWorkspaceAgentScriptsByAgentIDs(ctx, []uuid.UUID{agent.ID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, scripts, 3)
|
||||
byName := make(map[string]database.GetWorkspaceAgentScriptsByAgentIDsRow, len(scripts))
|
||||
for _, script := range scripts {
|
||||
byName[script.DisplayName] = script
|
||||
}
|
||||
require.Equal(t, "", byName["Startup"].ResourceAddress)
|
||||
require.JSONEq(t, `[]`, string(byName["Startup"].Dependencies))
|
||||
require.Equal(t, "coder_script.clone_repo", byName["Clone repo"].ResourceAddress)
|
||||
require.JSONEq(t, `[]`, string(byName["Clone repo"].Dependencies))
|
||||
require.Equal(t, "coder_script.install_tools", byName["Install tools"].ResourceAddress)
|
||||
require.JSONEq(t,
|
||||
`[{"prerequisite_resource_address":"coder_script.clone_repo","requirement":"success"}]`,
|
||||
string(byName["Install tools"].Dependencies),
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("RejectsBadDependency", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db, _ := dbtestutil.NewDB(t)
|
||||
job := dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{})
|
||||
err := insert(db, job.ID, &sdkproto.Resource{
|
||||
Name: "something",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Name: "dev",
|
||||
Scripts: []*sdkproto.Script{
|
||||
{DisplayName: "Clone repo", ResourceAddress: "coder_script.clone_repo"},
|
||||
{
|
||||
DisplayName: "Install tools",
|
||||
ResourceAddress: "coder_script.install_tools",
|
||||
Dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
// Requirement is left at UNSPECIFIED on purpose.
|
||||
}},
|
||||
},
|
||||
},
|
||||
}},
|
||||
})
|
||||
require.ErrorContains(t, err, `script "coder_script.install_tools" dependencies: dependency 0: unsupported requirement`)
|
||||
})
|
||||
|
||||
t.Run("AllDisplayApps", func(t *testing.T) {
|
||||
@@ -4119,6 +4283,89 @@ func TestInsertWorkspaceResource(t *testing.T) {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SubAgentWithOrderedScripts",
|
||||
resource: &sdkproto.Resource{
|
||||
Name: "something",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Id: agentID.String(),
|
||||
Name: "dev",
|
||||
Devcontainers: []*sdkproto.Devcontainer{{
|
||||
Id: devcontainerID.String(),
|
||||
Name: "repo",
|
||||
WorkspaceFolder: "/workspace",
|
||||
SubagentId: subAgentID.String(),
|
||||
Scripts: []*sdkproto.Script{
|
||||
{DisplayName: "a", ResourceAddress: "coder_script.a", RunOnStart: true},
|
||||
{
|
||||
DisplayName: "b",
|
||||
ResourceAddress: "coder_script.b",
|
||||
RunOnStart: true,
|
||||
Dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.a",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_COMPLETION,
|
||||
}},
|
||||
},
|
||||
},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
expectSubAgentCount: 1,
|
||||
check: func(t *testing.T, db database.Store, parentAgent database.WorkspaceAgent, subAgents []database.WorkspaceAgent, _ bool) {
|
||||
require.Len(t, subAgents, 1)
|
||||
|
||||
// The devcontainer's own scripts live under the subagent.
|
||||
scripts, err := db.GetWorkspaceAgentScriptsByAgentIDs(ctx, []uuid.UUID{subAgents[0].ID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, scripts, 2)
|
||||
byName := make(map[string]database.GetWorkspaceAgentScriptsByAgentIDsRow, len(scripts))
|
||||
for _, script := range scripts {
|
||||
byName[script.DisplayName] = script
|
||||
}
|
||||
assert.Equal(t, "coder_script.a", byName["a"].ResourceAddress)
|
||||
assert.JSONEq(t, `[]`, string(byName["a"].Dependencies))
|
||||
assert.Equal(t, "coder_script.b", byName["b"].ResourceAddress)
|
||||
assert.JSONEq(t,
|
||||
`[{"prerequisite_resource_address":"coder_script.a","requirement":"completion"}]`,
|
||||
string(byName["b"].Dependencies),
|
||||
)
|
||||
|
||||
// The start script coderd adds to the parent has no
|
||||
// address and nothing can order it.
|
||||
parentScripts, err := db.GetWorkspaceAgentScriptsByAgentIDs(ctx, []uuid.UUID{parentAgent.ID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, parentScripts, 1)
|
||||
assert.Equal(t, "Dev Container (repo)", parentScripts[0].DisplayName)
|
||||
assert.Equal(t, "", parentScripts[0].ResourceAddress)
|
||||
assert.JSONEq(t, `[]`, string(parentScripts[0].Dependencies))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SubAgentRejectsBadDependency",
|
||||
wantErr: `script "coder_script.b" dependencies: dependency 0: unsupported requirement`,
|
||||
resource: &sdkproto.Resource{
|
||||
Name: "something",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Id: agentID.String(),
|
||||
Name: "dev",
|
||||
Devcontainers: []*sdkproto.Devcontainer{{
|
||||
Id: devcontainerID.String(),
|
||||
Name: "repo",
|
||||
WorkspaceFolder: "/workspace",
|
||||
SubagentId: subAgentID.String(),
|
||||
Scripts: []*sdkproto.Script{{
|
||||
DisplayName: "b",
|
||||
ResourceAddress: "coder_script.b",
|
||||
Dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.a",
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MultipleDevcontainersWithSubagents",
|
||||
resource: &sdkproto.Resource{
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package provisionerdserver
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
sdkproto "github.com/coder/coder/v2/provisionersdk/proto"
|
||||
)
|
||||
|
||||
func TestScriptDependenciesJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
dependencies []*sdkproto.ScriptDependency
|
||||
want string
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "NilIsEmptyArray",
|
||||
want: `[]`,
|
||||
},
|
||||
{
|
||||
name: "TwoEntriesKeepOrder",
|
||||
dependencies: []*sdkproto.ScriptDependency{
|
||||
{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS,
|
||||
},
|
||||
{
|
||||
PrerequisiteResourceAddress: "coder_script.warm_cache",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_COMPLETION,
|
||||
},
|
||||
},
|
||||
want: `[{"prerequisite_resource_address":"coder_script.clone_repo","requirement":"success"},` +
|
||||
`{"prerequisite_resource_address":"coder_script.warm_cache","requirement":"completion"}]`,
|
||||
},
|
||||
{
|
||||
name: "UnspecifiedRequirement",
|
||||
dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_UNSPECIFIED,
|
||||
}},
|
||||
wantErr: "dependency 0: unsupported requirement",
|
||||
},
|
||||
{
|
||||
name: "UnknownRequirement",
|
||||
dependencies: []*sdkproto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement(99),
|
||||
}},
|
||||
wantErr: "dependency 0: unsupported requirement",
|
||||
},
|
||||
{
|
||||
name: "EmptyAddress",
|
||||
dependencies: []*sdkproto.ScriptDependency{
|
||||
{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS,
|
||||
},
|
||||
{
|
||||
PrerequisiteResourceAddress: "",
|
||||
Requirement: sdkproto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS,
|
||||
},
|
||||
},
|
||||
wantErr: "dependency 1 has an empty prerequisite resource address",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got, err := scriptDependenciesJSON(tc.dependencies)
|
||||
if tc.wantErr != "" {
|
||||
require.ErrorContains(t, err, tc.wantErr)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, tc.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -328,8 +328,17 @@ func (api *API) provisionerJobResources(rw http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
}
|
||||
|
||||
apiScripts, err := convertScripts(dbScripts)
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Internal error reading workspace agent scripts.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
apiAgent, err := db2sdk.WorkspaceAgent(
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), agent, convertProvisionedApps(dbApps), convertScripts(dbScripts), convertLogSources(dbLogSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), agent, convertProvisionedApps(dbApps), apiScripts, convertLogSources(dbLogSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DeploymentValues.AgentFallbackTroubleshootingURL.String(),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -112,8 +112,17 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
apiScripts, err := convertScripts(scripts)
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Internal error reading workspace agent scripts.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
apiAgent, err := db2sdk.WorkspaceAgent(
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), waws.WorkspaceAgent, db2sdk.Apps(dbApps, statuses, waws.WorkspaceAgent, waws.OwnerUsername, waws.WorkspaceTable), convertScripts(scripts), convertLogSources(logSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), waws.WorkspaceAgent, db2sdk.Apps(dbApps, statuses, waws.WorkspaceAgent, waws.OwnerUsername, waws.WorkspaceTable), apiScripts, convertLogSources(logSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DeploymentValues.AgentFallbackTroubleshootingURL.String(),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -1802,12 +1811,16 @@ func convertLogSources(dbLogSources []database.WorkspaceAgentLogSource) []coders
|
||||
return logSources
|
||||
}
|
||||
|
||||
func convertScripts(dbScripts []database.GetWorkspaceAgentScriptsByAgentIDsRow) []codersdk.WorkspaceAgentScript {
|
||||
scripts := make([]codersdk.WorkspaceAgentScript, 0)
|
||||
for _, dbScript := range dbScripts {
|
||||
scripts = append(scripts, db2sdk.WorkspaceAgentScript(dbScript))
|
||||
func convertScripts(dbScripts []database.GetWorkspaceAgentScriptsByAgentIDsRow) ([]codersdk.WorkspaceAgentScript, error) {
|
||||
scripts := make([]codersdk.WorkspaceAgentScript, 0, len(dbScripts))
|
||||
for i, dbScript := range dbScripts {
|
||||
script, err := db2sdk.WorkspaceAgentScript(dbScript)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("convert script %d: %w", i, err)
|
||||
}
|
||||
scripts = append(scripts, script)
|
||||
}
|
||||
return scripts
|
||||
return scripts, nil
|
||||
}
|
||||
|
||||
// @Summary Watch for workspace agent metadata updates
|
||||
|
||||
@@ -97,6 +97,48 @@ func TestWorkspaceAgent(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.False(t, workspace.LatestBuild.Resources[0].Agents[0].Health.Healthy)
|
||||
})
|
||||
t.Run("ScriptDependencies", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client, db := coderdtest.NewWithDatabase(t, nil)
|
||||
user := coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
|
||||
OrganizationID: user.OrganizationID,
|
||||
OwnerID: user.UserID,
|
||||
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
|
||||
agents[0].Scripts = []*proto.Script{
|
||||
{DisplayName: "Clone repo", ResourceAddress: "coder_script.clone_repo"},
|
||||
{
|
||||
DisplayName: "Install tools",
|
||||
ResourceAddress: "coder_script.install_tools",
|
||||
Dependencies: []*proto.ScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: proto.ScriptDependencyRequirement_SCRIPT_DEPENDENCY_REQUIREMENT_SUCCESS,
|
||||
}},
|
||||
},
|
||||
}
|
||||
return agents
|
||||
}).Do()
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
workspace, err := client.Workspace(ctx, r.Workspace.ID)
|
||||
require.NoError(t, err)
|
||||
agent, err := client.WorkspaceAgent(ctx, workspace.LatestBuild.Resources[0].Agents[0].ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, agent.Scripts, 2)
|
||||
byName := make(map[string]codersdk.WorkspaceAgentScript, len(agent.Scripts))
|
||||
for _, script := range agent.Scripts {
|
||||
byName[script.DisplayName] = script
|
||||
}
|
||||
require.Equal(t, "coder_script.clone_repo", byName["Clone repo"].ResourceAddress)
|
||||
require.Empty(t, byName["Clone repo"].Dependencies)
|
||||
require.Equal(t, "coder_script.install_tools", byName["Install tools"].ResourceAddress)
|
||||
require.Equal(t, []codersdk.WorkspaceAgentScriptDependency{{
|
||||
PrerequisiteResourceAddress: "coder_script.clone_repo",
|
||||
Requirement: codersdk.WorkspaceAgentScriptDependencyRequirementSuccess,
|
||||
}}, byName["Install tools"].Dependencies)
|
||||
})
|
||||
t.Run("HasFallbackTroubleshootingURL", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client, db := coderdtest.NewWithDatabase(t, nil)
|
||||
|
||||
@@ -1551,8 +1551,12 @@ func (api *API) convertWorkspaceBuild(
|
||||
scripts := index.scriptsByAgentID[agent.ID]
|
||||
statuses := index.statusesByAgentID[agent.ID]
|
||||
logSources := index.logSourcesByAgentID[agent.ID]
|
||||
apiScripts, err := convertScripts(scripts)
|
||||
if err != nil {
|
||||
return codersdk.WorkspaceBuild{}, xerrors.Errorf("converting workspace agent scripts: %w", err)
|
||||
}
|
||||
apiAgent, err := db2sdk.WorkspaceAgent(
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), agent, db2sdk.Apps(apps, statuses, agent, workspace.OwnerUsername, workspace.WorkspaceTable()), convertScripts(scripts), convertLogSources(logSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DERPMap(), *api.TailnetCoordinator.Load(), agent, db2sdk.Apps(apps, statuses, agent, workspace.OwnerUsername, workspace.WorkspaceTable()), apiScripts, convertLogSources(logSources), api.AgentInactiveDisconnectTimeout,
|
||||
api.DeploymentValues.AgentFallbackTroubleshootingURL.String(),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -8864,36 +8864,57 @@ func TestActiveServer_AnthropicDropsUnpairedProviderToolBeforePersist(t *testing
|
||||
func TestActiveServer_AnthropicKeepsPairedWebSearchBeforePersist(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
db, ps := dbtestutil.NewDB(t)
|
||||
requests := newAnthropicRequestRecorder()
|
||||
anthropicURL := chattest.NewAnthropic(t, func(req *chattest.AnthropicRequest) chattest.AnthropicResponse {
|
||||
requests.record(req)
|
||||
return chattest.AnthropicStreamingResponse(
|
||||
anthropicWebSearchPairChunks("ws-1", `{"query":"coder"}`, "search done", "end_turn")...,
|
||||
)
|
||||
})
|
||||
user, org, model := seedAnthropicChatDependencies(t, db, anthropicURL)
|
||||
model = enableAnthropicWebSearchForTest(t, db, model)
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
noResults bool
|
||||
}{
|
||||
{name: "WithResults"},
|
||||
// Clients see a search that found nothing while it streams, so it
|
||||
// must persist like any other.
|
||||
{name: "NoResults", noResults: true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
server := newActiveTestServer(t, db, ps, func(cfg *chatd.Config) {
|
||||
cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(chattest.NewMockAIBridgeTransport(t, anthropicURL, chattest.WithPreservePath()))
|
||||
})
|
||||
chat := createChatThroughServer(ctx, t, db, server, org.ID, user.ID, model.ID, "search for coder")
|
||||
waitForChatStatus(ctx, t, db, chat.ID, database.ChatStatusWaiting)
|
||||
chunks := anthropicWebSearchPairChunks("ws-1", `{"query":"coder"}`, "search done", "end_turn")
|
||||
if tt.noResults {
|
||||
for i := range chunks {
|
||||
if chunks[i].ContentBlock.Type == "web_search_tool_result" {
|
||||
chunks[i].ContentBlock.Content = []map[string]any{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generationRequests := filterAnthropicStreamingRequests(requests.all())
|
||||
require.Len(t, generationRequests, 1)
|
||||
parts := chatToolParts(ctx, t, db, chat.ID)
|
||||
toolCall := requireToolCallPart(t, parts, "web_search")
|
||||
require.Equal(t, "ws-1", toolCall.ToolCallID)
|
||||
require.True(t, toolCall.ProviderExecuted)
|
||||
toolResult := requireToolResultPart(t, parts, "web_search")
|
||||
require.Equal(t, "ws-1", toolResult.ToolCallID)
|
||||
require.True(t, toolResult.ProviderExecuted)
|
||||
require.NotEmpty(t, toolResult.ProviderMetadata)
|
||||
messages := chatMessages(ctx, t, db, chat.ID)
|
||||
requireTextPart(t, messages[len(messages)-1], "search done")
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
db, ps := dbtestutil.NewDB(t)
|
||||
requests := newAnthropicRequestRecorder()
|
||||
anthropicURL := chattest.NewAnthropic(t, func(req *chattest.AnthropicRequest) chattest.AnthropicResponse {
|
||||
requests.record(req)
|
||||
return chattest.AnthropicStreamingResponse(chunks...)
|
||||
})
|
||||
user, org, model := seedAnthropicChatDependencies(t, db, anthropicURL)
|
||||
model = enableAnthropicWebSearchForTest(t, db, model)
|
||||
|
||||
server := newActiveTestServer(t, db, ps, func(cfg *chatd.Config) {
|
||||
cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(chattest.NewMockAIBridgeTransport(t, anthropicURL, chattest.WithPreservePath()))
|
||||
})
|
||||
chat := createChatThroughServer(ctx, t, db, server, org.ID, user.ID, model.ID, "search for coder")
|
||||
waitForChatStatus(ctx, t, db, chat.ID, database.ChatStatusWaiting)
|
||||
|
||||
generationRequests := filterAnthropicStreamingRequests(requests.all())
|
||||
require.Len(t, generationRequests, 1)
|
||||
parts := chatToolParts(ctx, t, db, chat.ID)
|
||||
toolCall := requireToolCallPart(t, parts, "web_search")
|
||||
require.Equal(t, "ws-1", toolCall.ToolCallID)
|
||||
require.True(t, toolCall.ProviderExecuted)
|
||||
toolResult := requireToolResultPart(t, parts, "web_search")
|
||||
require.Equal(t, "ws-1", toolResult.ToolCallID)
|
||||
require.True(t, toolResult.ProviderExecuted)
|
||||
require.NotEmpty(t, toolResult.ProviderMetadata)
|
||||
messages := chatMessages(ctx, t, db, chat.ID)
|
||||
requireTextPart(t, messages[len(messages)-1], "search done")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestActiveServer_AnthropicWebSearchFollowUpHasNoSyntheticCancellation
|
||||
|
||||
@@ -308,6 +308,12 @@ type reasoningState struct {
|
||||
startedAt time.Time
|
||||
}
|
||||
|
||||
type textState struct {
|
||||
text string
|
||||
options fantasy.ProviderMetadata
|
||||
narration bool
|
||||
}
|
||||
|
||||
// GenerateAssistant performs one assistant model stream and returns the
|
||||
// durable assistant-side content. It does not execute tools, retry, or persist.
|
||||
func GenerateAssistant(ctx context.Context, opts GenerateAssistantOptions) (_ AssistantOutcome, retErr error) {
|
||||
@@ -973,7 +979,7 @@ func processStepStream(
|
||||
var result stepResult
|
||||
|
||||
providerExecutedCalls := make(map[string]bool)
|
||||
activeTextContent := make(map[string]string)
|
||||
activeTextContent := make(map[string]textState)
|
||||
activeReasoningContent := make(map[string]reasoningState)
|
||||
// Track tool names by ID for input delta publishing.
|
||||
toolNames := make(map[string]string)
|
||||
@@ -982,19 +988,30 @@ func processStepStream(
|
||||
for part := range stream {
|
||||
switch part.Type {
|
||||
case fantasy.StreamPartTypeTextStart:
|
||||
activeTextContent[part.ID] = ""
|
||||
// OpenAI labels narration when the text starts, so every delta
|
||||
// can carry the label before the text ends.
|
||||
activeTextContent[part.ID] = textState{
|
||||
options: part.ProviderMetadata,
|
||||
narration: chatprompt.IsNarration(part.ProviderMetadata),
|
||||
}
|
||||
|
||||
case fantasy.StreamPartTypeTextDelta:
|
||||
if _, exists := activeTextContent[part.ID]; exists {
|
||||
activeTextContent[part.ID] += part.Delta
|
||||
textPart := codersdk.ChatMessageText(part.Delta)
|
||||
if active, exists := activeTextContent[part.ID]; exists {
|
||||
active.text += part.Delta
|
||||
activeTextContent[part.ID] = active
|
||||
textPart.Narration = active.narration
|
||||
}
|
||||
publishMessagePart(codersdk.ChatMessageRoleAssistant, codersdk.ChatMessageText(part.Delta))
|
||||
publishMessagePart(codersdk.ChatMessageRoleAssistant, textPart)
|
||||
|
||||
case fantasy.StreamPartTypeTextEnd:
|
||||
if text, exists := activeTextContent[part.ID]; exists {
|
||||
if active, exists := activeTextContent[part.ID]; exists {
|
||||
if len(part.ProviderMetadata) > 0 {
|
||||
active.options = part.ProviderMetadata
|
||||
}
|
||||
result.content = append(result.content, fantasy.TextContent{
|
||||
Text: text,
|
||||
ProviderMetadata: part.ProviderMetadata,
|
||||
Text: active.text,
|
||||
ProviderMetadata: active.options,
|
||||
})
|
||||
delete(activeTextContent, part.ID)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"charm.land/fantasy"
|
||||
fantasyanthropic "charm.land/fantasy/providers/anthropic"
|
||||
fantasyopenai "charm.land/fantasy/providers/openai"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
@@ -79,3 +80,46 @@ func TestProcessStepStreamPersistsRedactedThinkingOnEnd(t *testing.T) {
|
||||
require.NotNil(t, metadata)
|
||||
require.Equal(t, "redacted-payload", metadata.RedactedData)
|
||||
}
|
||||
|
||||
func TestProcessStepStreamLabelsNarration(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
phase := func(itemID, phase string) fantasy.ProviderMetadata {
|
||||
return fantasy.ProviderMetadata{
|
||||
fantasyopenai.Name: &fantasyopenai.ResponsesTextMetadata{ItemID: itemID, Phase: phase},
|
||||
}
|
||||
}
|
||||
stream := iter.Seq[fantasy.StreamPart](func(yield func(fantasy.StreamPart) bool) {
|
||||
// The narration's end carries no metadata, so the start's label
|
||||
// must persist.
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextStart, ID: "msg_1", ProviderMetadata: phase("msg_1", "commentary")})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextDelta, ID: "msg_1", Delta: "Reading"})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextDelta, ID: "msg_1", Delta: " the file."})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextEnd, ID: "msg_1", ProviderMetadata: fantasy.ProviderMetadata{}})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextStart, ID: "msg_2", ProviderMetadata: phase("msg_2", "final_answer")})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextDelta, ID: "msg_2", Delta: "It is flaky."})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeTextEnd, ID: "msg_2", ProviderMetadata: phase("msg_2", "final_answer")})
|
||||
yield(fantasy.StreamPart{Type: fantasy.StreamPartTypeFinish, FinishReason: fantasy.FinishReasonStop})
|
||||
})
|
||||
|
||||
var published []codersdk.ChatMessagePart
|
||||
result, err := processStepStream(stream, quartz.NewMock(t), func(_ codersdk.ChatMessageRole, part codersdk.ChatMessagePart) {
|
||||
published = append(published, part)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
narration := codersdk.ChatMessageText("Reading")
|
||||
narration.Narration = true
|
||||
rest := codersdk.ChatMessageText(" the file.")
|
||||
rest.Narration = true
|
||||
require.Equal(t, []codersdk.ChatMessagePart{
|
||||
narration,
|
||||
rest,
|
||||
codersdk.ChatMessageText("It is flaky."),
|
||||
}, published)
|
||||
|
||||
require.Equal(t, []fantasy.Content{
|
||||
fantasy.TextContent{Text: "Reading the file.", ProviderMetadata: phase("msg_1", "commentary")},
|
||||
fantasy.TextContent{Text: "It is flaky.", ProviderMetadata: phase("msg_2", "final_answer")},
|
||||
}, result.content)
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"charm.land/fantasy"
|
||||
fantasyopenai "charm.land/fantasy/providers/openai"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sqlc-dev/pqtype"
|
||||
@@ -651,12 +652,14 @@ func sdkPartFromContent(
|
||||
return codersdk.ChatMessagePart{
|
||||
Type: codersdk.ChatMessagePartTypeText,
|
||||
Text: value.Text,
|
||||
Narration: IsNarration(value.ProviderMetadata),
|
||||
ProviderMetadata: marshalProviderMetadata(value.ProviderMetadata),
|
||||
}
|
||||
case *fantasy.TextContent:
|
||||
return codersdk.ChatMessagePart{
|
||||
Type: codersdk.ChatMessagePartTypeText,
|
||||
Text: value.Text,
|
||||
Narration: IsNarration(value.ProviderMetadata),
|
||||
ProviderMetadata: marshalProviderMetadata(value.ProviderMetadata),
|
||||
}
|
||||
case fantasy.ReasoningContent:
|
||||
@@ -732,6 +735,17 @@ func sdkPartFromContent(
|
||||
}
|
||||
}
|
||||
|
||||
// IsNarration reports whether the provider labeled text as commentary on
|
||||
// the model's work rather than its answer.
|
||||
func IsNarration(metadata fantasy.ProviderMetadata) bool {
|
||||
for _, data := range metadata {
|
||||
if text, ok := data.(*fantasyopenai.ResponsesTextMetadata); ok && text != nil {
|
||||
return text.Phase == "commentary"
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// toolResultContentToPart converts a fantasy ToolResultContent into a
|
||||
// ChatMessagePart.
|
||||
func toolResultContentToPart(
|
||||
|
||||
@@ -158,6 +158,9 @@ type OpenAIChunkChoice struct {
|
||||
ReasoningDelta string `json:"reasoning_delta,omitempty"`
|
||||
ToolCalls []OpenAIToolCall `json:"tool_calls,omitempty"`
|
||||
FinishReason string `json:"finish_reason,omitempty"`
|
||||
// Phase labels the Responses API message item that the first delta
|
||||
// of an output index opens.
|
||||
Phase string `json:"phase,omitempty"`
|
||||
}
|
||||
|
||||
// OpenAIChunk represents a streaming chunk from OpenAI.
|
||||
@@ -520,6 +523,7 @@ func writeResponsesAPIStreaming(t testing.TB, w http.ResponseWriter, r *http.Req
|
||||
itemType string // "message" or "function_call"
|
||||
itemID string
|
||||
text string // accumulated text for message items
|
||||
phase string // phase for message items
|
||||
callID string // call_id for function_call items
|
||||
toolName string // function name for function_call items
|
||||
arguments string // accumulated arguments for function_call items
|
||||
@@ -742,7 +746,7 @@ func writeResponsesAPIStreaming(t testing.TB, w http.ResponseWriter, r *http.Req
|
||||
}
|
||||
if !writeEvent("response.output_item.done", map[string]interface{}{
|
||||
"output_index": outputIndex,
|
||||
"item": map[string]interface{}{
|
||||
"item": withMessagePhase(map[string]interface{}{
|
||||
"type": "message",
|
||||
"id": state.itemID,
|
||||
"role": "assistant",
|
||||
@@ -753,7 +757,7 @@ func writeResponsesAPIStreaming(t testing.TB, w http.ResponseWriter, r *http.Req
|
||||
"text": state.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, state.phase),
|
||||
}) {
|
||||
return
|
||||
}
|
||||
@@ -835,17 +839,18 @@ func writeResponsesAPIStreaming(t testing.TB, w http.ResponseWriter, r *http.Req
|
||||
state = &outputItemState{
|
||||
itemType: "message",
|
||||
itemID: fmt.Sprintf("msg_%s", uuid.New().String()[:8]),
|
||||
phase: choice.Phase,
|
||||
}
|
||||
outputs[outputIndex] = state
|
||||
if !writeEvent("response.output_item.added", map[string]interface{}{
|
||||
"output_index": outputIndex,
|
||||
"item": map[string]interface{}{
|
||||
"item": withMessagePhase(map[string]interface{}{
|
||||
"type": "message",
|
||||
"id": state.itemID,
|
||||
"role": "assistant",
|
||||
"status": "in_progress",
|
||||
"content": []interface{}{},
|
||||
},
|
||||
}, state.phase),
|
||||
}) {
|
||||
return
|
||||
}
|
||||
@@ -875,6 +880,13 @@ func writeResponsesAPIStreaming(t testing.TB, w http.ResponseWriter, r *http.Req
|
||||
}
|
||||
}
|
||||
|
||||
func withMessagePhase(item map[string]interface{}, phase string) map[string]interface{} {
|
||||
if phase != "" {
|
||||
item["phase"] = phase
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
func (s *openAIServer) writeChatCompletionsNonStreaming(w http.ResponseWriter, resp *OpenAICompletion) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbgen"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtestutil"
|
||||
dbpubsub "github.com/coder/coder/v2/coderd/database/pubsub"
|
||||
@@ -755,6 +756,89 @@ func TestOpenAIResponsesFullReplayPairsReasoningAndWebSearch(t *testing.T) {
|
||||
requirePromptItemReferenceOrder(t, followup.Prompt, reasoningID, webSearchID)
|
||||
}
|
||||
|
||||
func TestOpenAIResponsesNarrationKeepsPhase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, ps := dbtestutil.NewDB(t)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
var recorder responsesRequestRecorder
|
||||
openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse {
|
||||
if !req.Stream {
|
||||
return chattest.OpenAINonStreamingResponse("title")
|
||||
}
|
||||
if recorder.record(req) > 1 {
|
||||
return chattest.OpenAIStreamingResponse(chattest.OpenAITextChunks("follow-up answer")...)
|
||||
}
|
||||
return chattest.OpenAIStreamingResponse(
|
||||
chattest.OpenAIChunk{Choices: []chattest.OpenAIChunkChoice{{Index: 0, Delta: "Checking the docs.", Phase: "commentary"}}},
|
||||
chattest.OpenAIChunk{Choices: []chattest.OpenAIChunkChoice{{Index: 1, Delta: "The docs cover it.", Phase: "final_answer"}}},
|
||||
)
|
||||
})
|
||||
|
||||
user, org, _ := seedChatDependenciesWithProvider(t, db, "openai", openAIURL)
|
||||
model := insertOpenAIResponsesModelConfig(t, db, user.ID, true, false)
|
||||
factory := chattest.NewMockAIBridgeTransport(t, openAIURL)
|
||||
server := newOpenAIResponsesTestServer(t, db, ps, func(cfg *chatd.Config) {
|
||||
cfg.AIBridgeTransportFactory = chatAIGatewayTransportFactoryPointer(factory)
|
||||
})
|
||||
|
||||
chat, err := server.CreateChat(ctx, chatd.CreateOptions{
|
||||
OrganizationID: org.ID,
|
||||
OwnerID: user.ID,
|
||||
Title: uniqueResponsesTitle(t, "narration"),
|
||||
ModelConfigID: model.ID,
|
||||
InitialUserContent: []codersdk.ChatMessagePart{
|
||||
codersdk.ChatMessageText("do the docs cover this?"),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
waitForChatProcessed(ctx, t, db, chat.ID, server)
|
||||
requireResponsesChatWaiting(ctx, t, db, chat.ID)
|
||||
|
||||
messages, err := db.GetChatMessagesByChatID(ctx, database.GetChatMessagesByChatIDParams{ChatID: chat.ID})
|
||||
require.NoError(t, err)
|
||||
var assistant []codersdk.ChatMessagePart
|
||||
for _, message := range messages {
|
||||
if message.Role == database.ChatMessageRoleAssistant {
|
||||
assistant = append(assistant, db2sdk.ChatMessage(message).Content...)
|
||||
}
|
||||
}
|
||||
narration := codersdk.ChatMessageText("Checking the docs.")
|
||||
narration.Narration = true
|
||||
require.Equal(t, []codersdk.ChatMessagePart{
|
||||
narration,
|
||||
codersdk.ChatMessageText("The docs cover it."),
|
||||
}, assistant)
|
||||
|
||||
_, err = server.SendMessage(ctx, chatd.SendMessageOptions{
|
||||
ChatID: chat.ID,
|
||||
CreatedBy: user.ID,
|
||||
ModelConfigID: model.ID,
|
||||
Content: []codersdk.ChatMessagePart{
|
||||
codersdk.ChatMessageText("thanks"),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
waitForChatProcessed(ctx, t, db, chat.ID, server)
|
||||
requireResponsesChatWaiting(ctx, t, db, chat.ID)
|
||||
|
||||
requests := recorder.all()
|
||||
require.Len(t, requests, 2)
|
||||
var replayed [][2]any
|
||||
for _, item := range requests[1].Prompt {
|
||||
itemMap, ok := item.(map[string]interface{})
|
||||
if !ok || chattest.StringResponseField(itemMap, "role") != "assistant" {
|
||||
continue
|
||||
}
|
||||
replayed = append(replayed, [2]any{itemMap["content"], itemMap["phase"]})
|
||||
}
|
||||
require.Equal(t, [][2]any{
|
||||
{"Checking the docs.", "commentary"},
|
||||
{"The docs cover it.", "final_answer"},
|
||||
}, replayed)
|
||||
}
|
||||
|
||||
type recordedResponsesRequest struct {
|
||||
Prompt []interface{}
|
||||
Store *bool
|
||||
|
||||
+20
-4
@@ -27,11 +27,26 @@ const (
|
||||
AppFamilySSH AppFamilyName = "ssh"
|
||||
AppFamilyReconnectingPTY AppFamilyName = "reconnecting_pty"
|
||||
AppFamilyPortForwarding AppFamilyName = "port_forwarding"
|
||||
// AppFamilySFTP only comes from history the sftp_mins column recorded.
|
||||
AppFamilySFTP AppFamilyName = "sftp"
|
||||
AppFamilyUnknown AppFamilyName = "unknown"
|
||||
AppFamilySFTP AppFamilyName = "sftp"
|
||||
AppFamilyUnknown AppFamilyName = "unknown"
|
||||
)
|
||||
|
||||
// appFamilyDisplayNames names each family.
|
||||
var appFamilyDisplayNames = map[AppFamilyName]string{
|
||||
AppFamilyVSCode: "Visual Studio Code",
|
||||
AppFamilyJetBrains: "JetBrains",
|
||||
AppFamilySSH: "SSH",
|
||||
AppFamilyReconnectingPTY: "Web Terminal",
|
||||
AppFamilyPortForwarding: "Port Forwarding",
|
||||
AppFamilySFTP: "SFTP",
|
||||
AppFamilyUnknown: "Unknown",
|
||||
}
|
||||
|
||||
// DisplayName returns the family's human-readable name.
|
||||
func (f AppFamilyName) DisplayName() string {
|
||||
return appFamilyDisplayNames[f]
|
||||
}
|
||||
|
||||
// AppNameOverflow sums the app names past the per-report cap.
|
||||
const AppNameOverflow = "overflow"
|
||||
|
||||
@@ -90,7 +105,8 @@ var sessionApps = map[string]sessionApp{
|
||||
"dataspell": {AppFamilyJetBrains, "DataSpell", "/icon/dataspell.svg"},
|
||||
"mps": {AppFamilyJetBrains, "MPS", ""},
|
||||
"android_studio": {AppFamilyJetBrains, "Android Studio", "/icon/android-studio.svg"},
|
||||
// No agent reports sftp; the family covers the sftp_mins history.
|
||||
// Coder's own clients don't report sftp, but other clients can. The
|
||||
// family also holds usage from the old sftp_mins column.
|
||||
"sftp": {AppFamilySFTP, "SFTP", "/icon/terminal.svg"},
|
||||
// Zed speaks SSH, so it counts toward the SSH total.
|
||||
"zed": {AppFamilySSH, "Zed", "/icon/zed.svg"},
|
||||
|
||||
@@ -531,6 +531,10 @@ type ChatMessagePart struct {
|
||||
ProviderExecuted bool `json:"provider_executed,omitempty" variants:"tool-call?,tool-result?"`
|
||||
// HookRewritten indicates that a lifecycle hook replaced model-proposed tool input.
|
||||
HookRewritten bool `json:"hook_rewritten,omitempty" variants:"tool-call?"`
|
||||
// Narration marks assistant text that the model labeled as commentary
|
||||
// on its work rather than its answer. Only providers that label their
|
||||
// output set it.
|
||||
Narration bool `json:"narration,omitempty" variants:"text?"`
|
||||
// CreatedAt is the timestamp this part carries. The semantics
|
||||
// depend on the part type: for tool-call and tool-result parts
|
||||
// it is the time the call was emitted or the result was
|
||||
|
||||
@@ -200,15 +200,6 @@ const (
|
||||
TemplateAppsTypeApp TemplateAppsType = "app"
|
||||
)
|
||||
|
||||
// Enums define the display name of the builtin app reported.
|
||||
const (
|
||||
TemplateBuiltinAppDisplayNameVSCode string = "Visual Studio Code"
|
||||
TemplateBuiltinAppDisplayNameJetBrains string = "JetBrains"
|
||||
TemplateBuiltinAppDisplayNameWebTerminal string = "Web Terminal"
|
||||
TemplateBuiltinAppDisplayNameSSH string = "SSH"
|
||||
TemplateBuiltinAppDisplayNameSFTP string = "SFTP"
|
||||
)
|
||||
|
||||
// TemplateAppUsage shows the usage of an app for one or more templates.
|
||||
type TemplateAppUsage struct {
|
||||
TemplateIDs []uuid.UUID `json:"template_ids" format:"uuid"`
|
||||
|
||||
+46
-12
@@ -201,18 +201,52 @@ const (
|
||||
)
|
||||
|
||||
type WorkspaceAgentScript struct {
|
||||
ID uuid.UUID `json:"id" format:"uuid"`
|
||||
LogSourceID uuid.UUID `json:"log_source_id" format:"uuid"`
|
||||
LogPath string `json:"log_path"`
|
||||
Script string `json:"script"`
|
||||
Cron string `json:"cron"`
|
||||
RunOnStart bool `json:"run_on_start"`
|
||||
RunOnStop bool `json:"run_on_stop"`
|
||||
StartBlocksLogin bool `json:"start_blocks_login"`
|
||||
Timeout time.Duration `json:"timeout"`
|
||||
DisplayName string `json:"display_name"`
|
||||
ExitCode *int32 `json:"exit_code,omitempty"`
|
||||
Status *WorkspaceAgentScriptStatus `json:"status,omitempty"`
|
||||
ID uuid.UUID `json:"id" format:"uuid"`
|
||||
LogSourceID uuid.UUID `json:"log_source_id" format:"uuid"`
|
||||
LogPath string `json:"log_path"`
|
||||
Script string `json:"script"`
|
||||
Cron string `json:"cron"`
|
||||
RunOnStart bool `json:"run_on_start"`
|
||||
RunOnStop bool `json:"run_on_stop"`
|
||||
StartBlocksLogin bool `json:"start_blocks_login"`
|
||||
Timeout time.Duration `json:"timeout"`
|
||||
DisplayName string `json:"display_name"`
|
||||
// ResourceAddress is the full Terraform address of the coder_script
|
||||
// resource, for example "module.git_clone.coder_script.clone". It is
|
||||
// empty for scripts that are not coder_script resources.
|
||||
ResourceAddress string `json:"resource_address"`
|
||||
// Dependencies lists the scripts this one waits for, as the
|
||||
// provisioner resolved them. It is omitted when empty.
|
||||
Dependencies []WorkspaceAgentScriptDependency `json:"dependencies,omitempty"`
|
||||
ExitCode *int32 `json:"exit_code,omitempty"`
|
||||
Status *WorkspaceAgentScriptStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// WorkspaceAgentScriptDependencyRequirement is the outcome a prerequisite
|
||||
// must reach before the dependent script may run.
|
||||
type WorkspaceAgentScriptDependencyRequirement string
|
||||
|
||||
const (
|
||||
WorkspaceAgentScriptDependencyRequirementSuccess WorkspaceAgentScriptDependencyRequirement = "success"
|
||||
WorkspaceAgentScriptDependencyRequirementCompletion WorkspaceAgentScriptDependencyRequirement = "completion"
|
||||
)
|
||||
|
||||
// Valid reports whether the requirement is one of the two supported values.
|
||||
func (r WorkspaceAgentScriptDependencyRequirement) Valid() bool {
|
||||
switch r {
|
||||
case WorkspaceAgentScriptDependencyRequirementSuccess,
|
||||
WorkspaceAgentScriptDependencyRequirementCompletion:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// WorkspaceAgentScriptDependency names a prerequisite script and the
|
||||
// outcome it must reach.
|
||||
type WorkspaceAgentScriptDependency struct {
|
||||
PrerequisiteResourceAddress string `json:"prerequisite_resource_address"`
|
||||
Requirement WorkspaceAgentScriptDependencyRequirement `json:"requirement"`
|
||||
}
|
||||
|
||||
type WorkspaceAgentHealth struct {
|
||||
|
||||
@@ -263,7 +263,7 @@ The `coder_ai_gateway_cost_control_*` metrics are exported only by `coderd`.
|
||||
| `coderd_dbpurge_iteration_duration_seconds` | histogram | Duration of each dbpurge iteration in seconds. | `success` |
|
||||
| `coderd_dbpurge_records_purged_total` | counter | Total number of records purged by type. | `record_type` |
|
||||
| `coderd_experiments` | gauge | Indicates whether each experiment is enabled (1) or not (0) | `experiment` |
|
||||
| `coderd_insights_applications_usage_seconds` | gauge | The application usage per template. | `application_name` `organization_name` `slug` `template_name` |
|
||||
| `coderd_insights_applications_usage_seconds` | gauge | The application usage per template. Built-in apps are grouped by app family, such as Visual Studio Code, JetBrains, Web Terminal, or SSH, with an empty slug. A user-minute counts once per family. | `application_name` `organization_name` `slug` `template_name` |
|
||||
| `coderd_insights_parameters` | gauge | The parameter usage per template. | `organization_name` `parameter_name` `parameter_type` `parameter_value` `template_name` |
|
||||
| `coderd_insights_templates_active_users` | gauge | The number of active users of the template. | `organization_name` `template_name` |
|
||||
| `coderd_license_active_users` | gauge | The number of active users. | |
|
||||
|
||||
@@ -146,34 +146,34 @@ The CLI and dashboard gained smaller but meaningful workflow improvements:
|
||||
|
||||
The following changes introduced after 2.29 might break workflows, require manual updates, or change administrator expectations:
|
||||
|
||||
| Initial State (2.29 and before) | New State (2.30-2.34) | Change Required |
|
||||
|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Terraform modules are downloaded during each workspace start. | Terraform modules are cached and pinned per template version. | Publish a new template version when upstream module changes should apply. Test templates that relied on fresh module downloads. See [speed up templates](../../../tutorials/best-practices/speed-up-templates.md). |
|
||||
| Integrations may use experimental AI Bridge endpoints under `/api/experimental/aibridge/*`. | Experimental AI Bridge endpoints were removed after AI Gateway graduated to stable routes. | Update clients to use `/api/v2/aibridge/*` routes. Review API consumers again because `/api/v2/aibridge/interceptions` is now deprecated in favor of `/api/v2/aibridge/sessions`. See the [AI Gateway API reference](../../../reference/api/aigateway.md). |
|
||||
| Unknown external OAuth providers did not default to PKCE. | Unknown external OAuth providers now default to PKCE. | If a provider does not support PKCE, set `CODER_EXTERNAL_AUTH_<N>_PKCE_METHODS=none`. See [external authentication](../../../admin/external-auth.md). |
|
||||
| GitLab external auth required only the `write_repository` scope. | GitLab external auth now requires `write_repository` and `read_api` scopes by default. | Add the `read_api` scope to your GitLab OAuth application. Existing users must re-authenticate to obtain the new scope. If you set scopes explicitly via `CODER_EXTERNAL_AUTH_<N>_SCOPES`, add `read_api` there as well. See [external authentication](../../../admin/external-auth.md). |
|
||||
| `--secure-auth-cookie` defaulted independently from the access URL. | Secure auth cookies are enabled automatically when `CODER_ACCESS_URL` uses HTTPS. | Confirm reverse proxies send the correct scheme headers. To preserve old behavior, explicitly set `CODER_SECURE_AUTH_COOKIE=false`. |
|
||||
| SFTP and SCP connections always landed in `$HOME`. | SFTP and SCP now respect the workspace agent `dir` setting. | Update scripts that relied on implicit `$HOME` paths. Prefer explicit absolute paths for file transfers. |
|
||||
| `coder_agent` `dir` attribute accepted any path without warning. | `dir` is deprecated and emits a warning. Non-`$HOME`/`~` values also break [Coder Desktop file sync](../../../user-guides/desktop/desktop-connect-sync.md). | Set `dir` to `$HOME` or omit it on `coder_agent` resources. The attribute still works in 2.34 but will be removed in a future release. |
|
||||
| Pre-2.28 Tasks templates might still exist in older deployments. | The pre-2.28 Tasks template format is no longer supported as of 2.30. | Update Tasks templates to use `app_id` instead of the deprecated `sidebar_app` flow. |
|
||||
| Tasks is the primary AI coding workflow. | Coder Agents is the long-term replacement, and Tasks is supported through the 2.34 ESR window (into 2026). | Plan migration from the Tasks API to the Chats API and [Coder Agents](../../../ai-coder/agents/index.md). See [Migrating from the Tasks API to the Chats API](../../../ai-coder/agents/tasks-to-chats-migration.md). |
|
||||
| AI Gateway injected MCP tools can be used for tool exposure. | Injected MCP tools are deprecated. | Move new integrations toward Coder Agents MCP server configuration or the MCP server flow. See [AI Gateway MCP](../../../ai-coder/ai-gateway/mcp.md) and [MCP servers](../../../ai-coder/agents/platform-controls/mcp-servers.md). |
|
||||
| AI Bridge is opt-in via `CODER_AIBRIDGE_ENABLED` (default `false`). | The toggle is renamed to `CODER_AI_GATEWAY_ENABLED` and now defaults to `true`. | The in-memory AI Gateway now starts on every deployment. Set `CODER_AI_GATEWAY_ENABLED=false`, or the deprecated `CODER_AIBRIDGE_ENABLED` alias which still works, to keep the old behavior. |
|
||||
| AI Gateway providers are configured with `CODER_AIBRIDGE_PROVIDER_*` or `CODER_AI_GATEWAY_PROVIDER_*` env vars. | Provider configuration is stored in the database. Env vars seed the database once on first startup, then are deprecated. | After upgrade, visit `/ai/settings/providers` to verify seeded providers, then remove the env vars. Coderd fails to start if env vars drift from the seeded database row. See [AI Gateway providers](../../../ai-coder/ai-gateway/providers.md). |
|
||||
| Regular users can read their own AI Gateway interceptions. | Only owners and auditors can read AI Gateway interception data. | Update dashboards, scripts, or user workflows that expected self-service interception reads. This intentionally narrows the RBAC surface. |
|
||||
| `coder groups list -o json` returns the old command output shape. | `coder groups list -o json` returns a flat structure matching other list commands. | Update scripts that parse this command output. |
|
||||
| `coder tokens rm` deletes token records by default. | `coder tokens rm` expires tokens by default and keeps records for auditability. | Use `coder tokens rm --delete` only when the token record must be deleted. Update scripts that expect removed tokens to disappear from token history. |
|
||||
| Deprecated Prometheus metrics are still emitted. | Deprecated Prometheus metrics were removed. | Update dashboards and alerts that use `coderd_api_workspace_latest_build_total` or `coderd_oauth2_external_requests_rate_limit_total`. Use the replacement metrics without the `_total` suffix. |
|
||||
| Authenticated rate limits are effectively shared by client IP in some deployments. | Authenticated request rate limits are keyed by user. | Review monitoring and expectations for NATed users or shared proxies. Per-user limits now apply more consistently after API key precheck. |
|
||||
| `coder login` can run while `CODER_SESSION_TOKEN` is set. | `coder login` errors when `CODER_SESSION_TOKEN` is set. | Unset `CODER_SESSION_TOKEN` in interactive login flows. Keep using the environment variable for non-interactive automation. |
|
||||
| Workspace starts with new parameters can proceed without an explicit stop in some flows. | Workspace starts with new parameters stop the workspace before starting. | Expect downtime when applying new parameters. Update automation that assumes the workspace remains running. |
|
||||
| `mode=auto` workspace links can silently create workspaces with prefilled parameters. | Users must confirm workspace auto-creation before provisioning starts. | Update Open in Coder buttons, runbooks, or internal flows that expect one-click workspace creation without a consent dialog. |
|
||||
| Users with `--login-type none` are common for automation. | `--login-type none` is deprecated. | For Premium deployments, migrate automation to service accounts. For OSS deployments, use regular users with password, GitHub, or OIDC authentication. See [headless auth](../../../admin/users/headless-auth.md). |
|
||||
| Terminal commands can be executed from URL parameters without extra confirmation. | The dashboard requires confirmation before executing terminal commands from URLs. | Update runbooks or deep links that expected immediate terminal execution. This protects users from accidental command execution. |
|
||||
| Agent SSH port forwarding is always available when the agent allows SSH. | Reverse and local port forwarding can be disabled per agent. | Review templates and IDE workflows before enabling `--block-reverse-port-forwarding` or `--block-local-port-forwarding`. See [port forwarding](../../../admin/networking/port-forwarding.md). |
|
||||
| `PATCH /api/v2/templates/{template}` accepts value fields for metadata updates. | Template metadata update fields are optional pointer fields in the SDK, and 304 responses were removed. | Update SDK consumers and direct API clients that patch template metadata. Send only fields that should change, including false or zero values explicitly. |
|
||||
| External provisioner daemons use the 2.29 provisionerd protocol. | The provisionerd protocol changed for provisioner operations and file upload/download. | Update external provisioner daemons to the matching 2.34 protocol. The protocol reserves removed fields such as `stop_modules`, `exp_reuse_terraform_workspace`, and `user_secrets`, and adds `DownloadFile`. |
|
||||
| Helm chart health probes and observability bind addresses use older chart defaults. | Readiness and liveness probes have `enabled` toggles and more fields, and Prometheus/pprof addresses are overridable. | Review custom Helm values for probe behavior and observability bindings. Prefer restricting pprof to a local address when exposing diagnostics. |
|
||||
| Initial State (2.29 and before) | New State (2.30-2.34) | Change Required |
|
||||
|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Terraform modules are downloaded during each workspace start. | Terraform modules are cached and pinned per template version. | Publish a new template version when upstream module changes should apply. Test templates that relied on fresh module downloads. See [speed up templates](../../../tutorials/best-practices/speed-up-templates.md). |
|
||||
| Integrations may use experimental AI Bridge endpoints under `/api/experimental/aibridge/*`. | Experimental AI Bridge endpoints were removed after AI Gateway graduated to stable routes. | Update clients to use `/api/v2/aibridge/*` routes. Review API consumers again because `/api/v2/aibridge/interceptions` is now deprecated in favor of `/api/v2/aibridge/sessions`. See the [AI Gateway API reference](../../../reference/api/aigateway.md). |
|
||||
| Unknown external OAuth providers did not default to PKCE. | Unknown external OAuth providers now default to PKCE. | If a provider does not support PKCE, set `CODER_EXTERNAL_AUTH_<N>_PKCE_METHODS=none`. See [external authentication](../../../admin/external-auth.md). |
|
||||
| GitLab external auth required only the `write_repository` scope. | GitLab external auth now requires `write_repository` and `read_api` scopes by default. | Add the `read_api` scope to your GitLab OAuth application. Existing users must re-authenticate to obtain the new scope. If you set scopes explicitly via `CODER_EXTERNAL_AUTH_<N>_SCOPES`, add `read_api` there as well. See [external authentication](../../../admin/external-auth.md). |
|
||||
| `--secure-auth-cookie` defaulted independently from the access URL. | Secure auth cookies are enabled automatically when `CODER_ACCESS_URL` uses HTTPS. | Confirm reverse proxies send the correct scheme headers. To preserve old behavior, explicitly set `CODER_SECURE_AUTH_COOKIE=false`. |
|
||||
| SFTP and SCP connections always landed in `$HOME`. | SFTP and SCP now respect the workspace agent `dir` setting. | Update scripts that relied on implicit `$HOME` paths. Prefer explicit absolute paths for file transfers. |
|
||||
| `coder_agent` `dir` attribute accepted any path without warning. | `dir` is deprecated and emits a warning. Non-`$HOME`/`~` values also break [Coder Desktop file sync](../../../user-guides/desktop/desktop-connect-sync.md). **Update:** Coder Terraform provider 2.20.0 removed the deprecation and warning, and Coder Desktop file sync works with any `dir` as of macOS v0.8.4 and Windows v0.8.5. | Set `dir` to `$HOME` or omit it on `coder_agent` resources. The attribute still works in 2.34 but will be removed in a future release. **Update:** With provider 2.20.0 or later, no action is needed. You can keep `dir` set; update Coder Desktop if file sync fails. |
|
||||
| Pre-2.28 Tasks templates might still exist in older deployments. | The pre-2.28 Tasks template format is no longer supported as of 2.30. | Update Tasks templates to use `app_id` instead of the deprecated `sidebar_app` flow. |
|
||||
| Tasks is the primary AI coding workflow. | Coder Agents is the long-term replacement, and Tasks is supported through the 2.34 ESR window (into 2026). | Plan migration from the Tasks API to the Chats API and [Coder Agents](../../../ai-coder/agents/index.md). See [Migrating from the Tasks API to the Chats API](../../../ai-coder/agents/tasks-to-chats-migration.md). |
|
||||
| AI Gateway injected MCP tools can be used for tool exposure. | Injected MCP tools are deprecated. | Move new integrations toward Coder Agents MCP server configuration or the MCP server flow. See [AI Gateway MCP](../../../ai-coder/ai-gateway/mcp.md) and [MCP servers](../../../ai-coder/agents/platform-controls/mcp-servers.md). |
|
||||
| AI Bridge is opt-in via `CODER_AIBRIDGE_ENABLED` (default `false`). | The toggle is renamed to `CODER_AI_GATEWAY_ENABLED` and now defaults to `true`. | The in-memory AI Gateway now starts on every deployment. Set `CODER_AI_GATEWAY_ENABLED=false`, or the deprecated `CODER_AIBRIDGE_ENABLED` alias which still works, to keep the old behavior. |
|
||||
| AI Gateway providers are configured with `CODER_AIBRIDGE_PROVIDER_*` or `CODER_AI_GATEWAY_PROVIDER_*` env vars. | Provider configuration is stored in the database. Env vars seed the database once on first startup, then are deprecated. | After upgrade, visit `/ai/settings/providers` to verify seeded providers, then remove the env vars. Coderd fails to start if env vars drift from the seeded database row. See [AI Gateway providers](../../../ai-coder/ai-gateway/providers.md). |
|
||||
| Regular users can read their own AI Gateway interceptions. | Only owners and auditors can read AI Gateway interception data. | Update dashboards, scripts, or user workflows that expected self-service interception reads. This intentionally narrows the RBAC surface. |
|
||||
| `coder groups list -o json` returns the old command output shape. | `coder groups list -o json` returns a flat structure matching other list commands. | Update scripts that parse this command output. |
|
||||
| `coder tokens rm` deletes token records by default. | `coder tokens rm` expires tokens by default and keeps records for auditability. | Use `coder tokens rm --delete` only when the token record must be deleted. Update scripts that expect removed tokens to disappear from token history. |
|
||||
| Deprecated Prometheus metrics are still emitted. | Deprecated Prometheus metrics were removed. | Update dashboards and alerts that use `coderd_api_workspace_latest_build_total` or `coderd_oauth2_external_requests_rate_limit_total`. Use the replacement metrics without the `_total` suffix. |
|
||||
| Authenticated rate limits are effectively shared by client IP in some deployments. | Authenticated request rate limits are keyed by user. | Review monitoring and expectations for NATed users or shared proxies. Per-user limits now apply more consistently after API key precheck. |
|
||||
| `coder login` can run while `CODER_SESSION_TOKEN` is set. | `coder login` errors when `CODER_SESSION_TOKEN` is set. | Unset `CODER_SESSION_TOKEN` in interactive login flows. Keep using the environment variable for non-interactive automation. |
|
||||
| Workspace starts with new parameters can proceed without an explicit stop in some flows. | Workspace starts with new parameters stop the workspace before starting. | Expect downtime when applying new parameters. Update automation that assumes the workspace remains running. |
|
||||
| `mode=auto` workspace links can silently create workspaces with prefilled parameters. | Users must confirm workspace auto-creation before provisioning starts. | Update Open in Coder buttons, runbooks, or internal flows that expect one-click workspace creation without a consent dialog. |
|
||||
| Users with `--login-type none` are common for automation. | `--login-type none` is deprecated. | For Premium deployments, migrate automation to service accounts. For OSS deployments, use regular users with password, GitHub, or OIDC authentication. See [headless auth](../../../admin/users/headless-auth.md). |
|
||||
| Terminal commands can be executed from URL parameters without extra confirmation. | The dashboard requires confirmation before executing terminal commands from URLs. | Update runbooks or deep links that expected immediate terminal execution. This protects users from accidental command execution. |
|
||||
| Agent SSH port forwarding is always available when the agent allows SSH. | Reverse and local port forwarding can be disabled per agent. | Review templates and IDE workflows before enabling `--block-reverse-port-forwarding` or `--block-local-port-forwarding`. See [port forwarding](../../../admin/networking/port-forwarding.md). |
|
||||
| `PATCH /api/v2/templates/{template}` accepts value fields for metadata updates. | Template metadata update fields are optional pointer fields in the SDK, and 304 responses were removed. | Update SDK consumers and direct API clients that patch template metadata. Send only fields that should change, including false or zero values explicitly. |
|
||||
| External provisioner daemons use the 2.29 provisionerd protocol. | The provisionerd protocol changed for provisioner operations and file upload/download. | Update external provisioner daemons to the matching 2.34 protocol. The protocol reserves removed fields such as `stop_modules`, `exp_reuse_terraform_workspace`, and `user_secrets`, and adds `DownloadFile`. |
|
||||
| Helm chart health probes and observability bind addresses use older chart defaults. | Readiness and liveness probes have `enabled` toggles and more fields, and Prometheus/pprof addresses are overridable. | Review custom Helm values for probe behavior and observability bindings. Prefer restricting pprof to a local address when exposing diagnostics. |
|
||||
|
||||
<a id="upgrading"></a>
|
||||
|
||||
|
||||
Generated
+5
@@ -375,6 +375,11 @@
|
||||
"title": "Antigravity",
|
||||
"description": "Access your Coder workspace with the Antigravity agentic code editor over SSH.",
|
||||
"path": "./user-guides/workspace-access/antigravity.md"
|
||||
},
|
||||
{
|
||||
"title": "Claude Desktop",
|
||||
"description": "Let Claude Desktop access your Coder workspaces.",
|
||||
"path": "./user-guides/workspace-access/claude-desktop.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -40,3 +40,6 @@ children:
|
||||
- title: Antigravity
|
||||
description: Access your Coder workspace with the Antigravity agentic code editor over SSH.
|
||||
path: ./user-guides/workspace-access/antigravity.md
|
||||
- title: Claude Desktop
|
||||
description: Let Claude Desktop access your Coder workspaces.
|
||||
path: ./user-guides/workspace-access/claude-desktop.md
|
||||
Generated
+7
@@ -656,11 +656,18 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
|
||||
Generated
+342
-290
@@ -199,11 +199,18 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -455,11 +462,18 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild} \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -830,11 +844,18 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/res
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -884,121 +905,125 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/res
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------------------------|--------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» dependencies` | array | false | | Dependencies lists the scripts this one waits for, as the provisioner resolved them. It is omitted when empty. |
|
||||
| `»»»» prerequisite_resource_address` | string | false | | |
|
||||
| `»»»» requirement` | [codersdk.WorkspaceAgentScriptDependencyRequirement](schemas.md#codersdkworkspaceagentscriptdependencyrequirement) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» resource_address` | string | false | | Resource address is the full Terraform address of the coder_script resource, for example "module.git_clone.coder_script.clone". It is empty for scripts that are not coder_script resources. |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
@@ -1009,6 +1034,7 @@ Status Code **200**
|
||||
| `sharing_level` | `authenticated`, `organization`, `owner`, `public` |
|
||||
| `state` | `complete`, `failure`, `idle`, `working` |
|
||||
| `lifecycle_state` | `created`, `off`, `ready`, `shutdown_error`, `shutdown_timeout`, `shutting_down`, `start_error`, `start_timeout`, `starting` |
|
||||
| `requirement` | `completion`, `success` |
|
||||
| `status` | `connected`, `connecting`, `disconnected`, `exit_failure`, `ok`, `pipes_left_open`, `timed_out`, `timeout` |
|
||||
| `startup_script_behavior` | `blocking`, `non-blocking` |
|
||||
| `workspace_transition` | `delete`, `start`, `stop` |
|
||||
@@ -1207,11 +1233,18 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/sta
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -1574,11 +1607,18 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -1641,181 +1681,185 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|----------------------------------|--------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» build_number` | integer | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» deadline` | string(date-time) | false | | |
|
||||
| `» has_external_agent` | boolean | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» initiator_id` | string(uuid) | false | | |
|
||||
| `» initiator_name` | string | false | | |
|
||||
| `» job` | [codersdk.ProvisionerJob](schemas.md#codersdkprovisionerjob) | false | | |
|
||||
| `»» available_workers` | array | false | | |
|
||||
| `»» canceled_at` | string(date-time) | false | | |
|
||||
| `»» completed_at` | string(date-time) | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» error` | string | false | | |
|
||||
| `»» error_code` | [codersdk.JobErrorCode](schemas.md#codersdkjoberrorcode) | false | | |
|
||||
| `»» file_id` | string(uuid) | false | | |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» initiator_id` | string(uuid) | false | | |
|
||||
| `»» input` | [codersdk.ProvisionerJobInput](schemas.md#codersdkprovisionerjobinput) | false | | |
|
||||
| `»»» error` | string | false | | |
|
||||
| `»»» template_version_id` | string(uuid) | false | | |
|
||||
| `»»» workspace_build_id` | string(uuid) | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | [codersdk.ProvisionerJobMetadata](schemas.md#codersdkprovisionerjobmetadata) | false | | |
|
||||
| `»»» template_display_name` | string | false | | |
|
||||
| `»»» template_icon` | string | false | | |
|
||||
| `»»» template_id` | string(uuid) | false | | |
|
||||
| `»»» template_name` | string | false | | |
|
||||
| `»»» template_version_name` | string | false | | |
|
||||
| `»»» workspace_build_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» workspace_name` | string | false | | |
|
||||
| `»» organization_id` | string(uuid) | false | | |
|
||||
| `»» queue_position` | integer | false | | |
|
||||
| `»» queue_size` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» status` | [codersdk.ProvisionerJobStatus](schemas.md#codersdkprovisionerjobstatus) | false | | |
|
||||
| `»» tags` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» type` | [codersdk.ProvisionerJobType](schemas.md#codersdkprovisionerjobtype) | false | | |
|
||||
| `»» worker_id` | string(uuid) | false | | |
|
||||
| `»» worker_name` | string | false | | |
|
||||
| `» matched_provisioners` | [codersdk.MatchedProvisioners](schemas.md#codersdkmatchedprovisioners) | false | | |
|
||||
| `»» available` | integer | false | | Available is the number of provisioner daemons that are available to take jobs. This may be less than the count if some provisioners are busy or have been stopped. |
|
||||
| `»» count` | integer | false | | Count is the number of provisioner daemons that matched the given tags. If the count is 0, it means no provisioner daemons matched the requested tags. |
|
||||
| `»» most_recently_seen` | string(date-time) | false | | Most recently seen is the most recently seen time of the set of matched provisioners. If no provisioners matched, this field will be null. |
|
||||
| `» max_deadline` | string(date-time) | false | | |
|
||||
| `» reason` | [codersdk.BuildReason](schemas.md#codersdkbuildreason) | false | | |
|
||||
| `» resources` | array | false | | |
|
||||
| `»» agents` | array | false | | |
|
||||
| `»»» api_version` | string | false | | |
|
||||
| `»»» apps` | array | false | | |
|
||||
| `»»»» command` | string | false | | |
|
||||
| `»»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»»» group` | string | false | | |
|
||||
| `»»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»»» hidden` | boolean | false | | |
|
||||
| `»»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»»» id` | string(uuid) | false | | |
|
||||
| `»»»»» message` | string | false | | |
|
||||
| `»»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»»» architecture` | string | false | | |
|
||||
| `»»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» directory` | string | false | | |
|
||||
| `»»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»»» display_apps` | array | false | | |
|
||||
| `»»» environment_variables` | object | false | | |
|
||||
| `»»»» [any property]` | string | false | | |
|
||||
| `»»» expanded_directory` | string | false | | |
|
||||
| `»»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» instance_id` | string | false | | |
|
||||
| `»»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»»» latency_ms` | number | false | | |
|
||||
| `»»»»» preferred` | boolean | false | | |
|
||||
| `»»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»»» log_sources` | array | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» icon` | string | false | | |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»»» logs_length` | integer | false | | |
|
||||
| `»»» logs_overflowed` | boolean | false | | |
|
||||
| `»»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»»» display_name` | string | false | | |
|
||||
| `»»»»» interval` | integer | false | | |
|
||||
| `»»»»» key` | string | false | | |
|
||||
| `»»»»» script` | string | false | | |
|
||||
| `»»»»» timeout` | integer | false | | |
|
||||
| `»»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»»» error` | string | false | | |
|
||||
| `»»»»» value` | string | false | | |
|
||||
| `»»» name` | string | false | | |
|
||||
| `»»» operating_system` | string | false | | |
|
||||
| `»»» parent_id` | string(uuid) | false | | |
|
||||
| `»»» ready_at` | string(date-time) | false | | |
|
||||
| `»»» resource_id` | string(uuid) | false | | |
|
||||
| `»»» scripts` | array | false | | |
|
||||
| `»»»» cron` | string | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» exit_code` | integer | false | | |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» log_path` | string | false | | |
|
||||
| `»»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»»» run_on_start` | boolean | false | | |
|
||||
| `»»»» run_on_stop` | boolean | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» started_at` | string(date-time) | false | | |
|
||||
| `»»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»»» subsystems` | array | false | | |
|
||||
| `»»» troubleshooting_url` | string | false | | |
|
||||
| `»»» updated_at` | string(date-time) | false | | |
|
||||
| `»»» version` | string | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» daily_cost` | integer | false | | |
|
||||
| `»» hide` | boolean | false | | |
|
||||
| `»» icon` | string | false | | |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» job_id` | string(uuid) | false | | |
|
||||
| `»» metadata` | array | false | | |
|
||||
| `»»» key` | string | false | | |
|
||||
| `»»» sensitive` | boolean | false | | |
|
||||
| `»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» type` | string | false | | |
|
||||
| `»» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `» status` | [codersdk.WorkspaceStatus](schemas.md#codersdkworkspacestatus) | false | | |
|
||||
| `» template_version_id` | string(uuid) | false | | |
|
||||
| `» template_version_name` | string | false | | |
|
||||
| `» template_version_preset_id` | string(uuid) | false | | |
|
||||
| `» transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `» updated_at` | string(date-time) | false | | |
|
||||
| `» workspace_id` | string(uuid) | false | | |
|
||||
| `» workspace_name` | string | false | | |
|
||||
| `» workspace_owner_avatar_url` | string | false | | |
|
||||
| `» workspace_owner_id` | string(uuid) | false | | |
|
||||
| `» workspace_owner_name` | string | false | | Workspace owner name is the username of the owner of the workspace. |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» build_number` | integer | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» deadline` | string(date-time) | false | | |
|
||||
| `» has_external_agent` | boolean | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» initiator_id` | string(uuid) | false | | |
|
||||
| `» initiator_name` | string | false | | |
|
||||
| `» job` | [codersdk.ProvisionerJob](schemas.md#codersdkprovisionerjob) | false | | |
|
||||
| `»» available_workers` | array | false | | |
|
||||
| `»» canceled_at` | string(date-time) | false | | |
|
||||
| `»» completed_at` | string(date-time) | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» error` | string | false | | |
|
||||
| `»» error_code` | [codersdk.JobErrorCode](schemas.md#codersdkjoberrorcode) | false | | |
|
||||
| `»» file_id` | string(uuid) | false | | |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» initiator_id` | string(uuid) | false | | |
|
||||
| `»» input` | [codersdk.ProvisionerJobInput](schemas.md#codersdkprovisionerjobinput) | false | | |
|
||||
| `»»» error` | string | false | | |
|
||||
| `»»» template_version_id` | string(uuid) | false | | |
|
||||
| `»»» workspace_build_id` | string(uuid) | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | [codersdk.ProvisionerJobMetadata](schemas.md#codersdkprovisionerjobmetadata) | false | | |
|
||||
| `»»» template_display_name` | string | false | | |
|
||||
| `»»» template_icon` | string | false | | |
|
||||
| `»»» template_id` | string(uuid) | false | | |
|
||||
| `»»» template_name` | string | false | | |
|
||||
| `»»» template_version_name` | string | false | | |
|
||||
| `»»» workspace_build_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» workspace_name` | string | false | | |
|
||||
| `»» organization_id` | string(uuid) | false | | |
|
||||
| `»» queue_position` | integer | false | | |
|
||||
| `»» queue_size` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» status` | [codersdk.ProvisionerJobStatus](schemas.md#codersdkprovisionerjobstatus) | false | | |
|
||||
| `»» tags` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» type` | [codersdk.ProvisionerJobType](schemas.md#codersdkprovisionerjobtype) | false | | |
|
||||
| `»» worker_id` | string(uuid) | false | | |
|
||||
| `»» worker_name` | string | false | | |
|
||||
| `» matched_provisioners` | [codersdk.MatchedProvisioners](schemas.md#codersdkmatchedprovisioners) | false | | |
|
||||
| `»» available` | integer | false | | Available is the number of provisioner daemons that are available to take jobs. This may be less than the count if some provisioners are busy or have been stopped. |
|
||||
| `»» count` | integer | false | | Count is the number of provisioner daemons that matched the given tags. If the count is 0, it means no provisioner daemons matched the requested tags. |
|
||||
| `»» most_recently_seen` | string(date-time) | false | | Most recently seen is the most recently seen time of the set of matched provisioners. If no provisioners matched, this field will be null. |
|
||||
| `» max_deadline` | string(date-time) | false | | |
|
||||
| `» reason` | [codersdk.BuildReason](schemas.md#codersdkbuildreason) | false | | |
|
||||
| `» resources` | array | false | | |
|
||||
| `»» agents` | array | false | | |
|
||||
| `»»» api_version` | string | false | | |
|
||||
| `»»» apps` | array | false | | |
|
||||
| `»»»» command` | string | false | | |
|
||||
| `»»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»»» group` | string | false | | |
|
||||
| `»»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»»» hidden` | boolean | false | | |
|
||||
| `»»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»»» id` | string(uuid) | false | | |
|
||||
| `»»»»» message` | string | false | | |
|
||||
| `»»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»»» architecture` | string | false | | |
|
||||
| `»»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» directory` | string | false | | |
|
||||
| `»»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»»» display_apps` | array | false | | |
|
||||
| `»»» environment_variables` | object | false | | |
|
||||
| `»»»» [any property]` | string | false | | |
|
||||
| `»»» expanded_directory` | string | false | | |
|
||||
| `»»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» instance_id` | string | false | | |
|
||||
| `»»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»»» latency_ms` | number | false | | |
|
||||
| `»»»»» preferred` | boolean | false | | |
|
||||
| `»»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»»» log_sources` | array | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» icon` | string | false | | |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»»» logs_length` | integer | false | | |
|
||||
| `»»» logs_overflowed` | boolean | false | | |
|
||||
| `»»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»»» display_name` | string | false | | |
|
||||
| `»»»»» interval` | integer | false | | |
|
||||
| `»»»»» key` | string | false | | |
|
||||
| `»»»»» script` | string | false | | |
|
||||
| `»»»»» timeout` | integer | false | | |
|
||||
| `»»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»»» error` | string | false | | |
|
||||
| `»»»»» value` | string | false | | |
|
||||
| `»»» name` | string | false | | |
|
||||
| `»»» operating_system` | string | false | | |
|
||||
| `»»» parent_id` | string(uuid) | false | | |
|
||||
| `»»» ready_at` | string(date-time) | false | | |
|
||||
| `»»» resource_id` | string(uuid) | false | | |
|
||||
| `»»» scripts` | array | false | | |
|
||||
| `»»»» cron` | string | false | | |
|
||||
| `»»»» dependencies` | array | false | | Dependencies lists the scripts this one waits for, as the provisioner resolved them. It is omitted when empty. |
|
||||
| `»»»»» prerequisite_resource_address` | string | false | | |
|
||||
| `»»»»» requirement` | [codersdk.WorkspaceAgentScriptDependencyRequirement](schemas.md#codersdkworkspaceagentscriptdependencyrequirement) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» exit_code` | integer | false | | |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» log_path` | string | false | | |
|
||||
| `»»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»»» resource_address` | string | false | | Resource address is the full Terraform address of the coder_script resource, for example "module.git_clone.coder_script.clone". It is empty for scripts that are not coder_script resources. |
|
||||
| `»»»» run_on_start` | boolean | false | | |
|
||||
| `»»»» run_on_stop` | boolean | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» started_at` | string(date-time) | false | | |
|
||||
| `»»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»»» subsystems` | array | false | | |
|
||||
| `»»» troubleshooting_url` | string | false | | |
|
||||
| `»»» updated_at` | string(date-time) | false | | |
|
||||
| `»»» version` | string | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» daily_cost` | integer | false | | |
|
||||
| `»» hide` | boolean | false | | |
|
||||
| `»» icon` | string | false | | |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» job_id` | string(uuid) | false | | |
|
||||
| `»» metadata` | array | false | | |
|
||||
| `»»» key` | string | false | | |
|
||||
| `»»» sensitive` | boolean | false | | |
|
||||
| `»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» type` | string | false | | |
|
||||
| `»» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `» status` | [codersdk.WorkspaceStatus](schemas.md#codersdkworkspacestatus) | false | | |
|
||||
| `» template_version_id` | string(uuid) | false | | |
|
||||
| `» template_version_name` | string | false | | |
|
||||
| `» template_version_preset_id` | string(uuid) | false | | |
|
||||
| `» transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| `» updated_at` | string(date-time) | false | | |
|
||||
| `» workspace_id` | string(uuid) | false | | |
|
||||
| `» workspace_name` | string | false | | |
|
||||
| `» workspace_owner_avatar_url` | string | false | | |
|
||||
| `» workspace_owner_id` | string(uuid) | false | | |
|
||||
| `» workspace_owner_name` | string | false | | Workspace owner name is the username of the owner of the workspace. |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
@@ -1831,6 +1875,7 @@ Status Code **200**
|
||||
| `sharing_level` | `authenticated`, `organization`, `owner`, `public` |
|
||||
| `state` | `complete`, `failure`, `idle`, `working` |
|
||||
| `lifecycle_state` | `created`, `off`, `ready`, `shutdown_error`, `shutdown_timeout`, `shutting_down`, `start_error`, `start_timeout`, `starting` |
|
||||
| `requirement` | `completion`, `success` |
|
||||
| `startup_script_behavior` | `blocking`, `non-blocking` |
|
||||
| `workspace_transition` | `delete`, `start`, `stop` |
|
||||
| `transition` | `delete`, `start`, `stop` |
|
||||
@@ -2065,11 +2110,18 @@ curl -X POST http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
|
||||
Generated
+11
@@ -2898,6 +2898,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -2979,6 +2980,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/messages \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3134,6 +3136,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3214,6 +3217,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3295,6 +3299,7 @@ curl -X POST http://coder-server:8080/api/v2/chats/{chat}/messages \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3435,6 +3440,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3515,6 +3521,7 @@ curl -X PATCH http://coder-server:8080/api/v2/chats/{chat}/messages/{message} \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -4106,6 +4113,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -4185,6 +4193,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -4251,6 +4260,7 @@ curl -X GET http://coder-server:8080/api/v2/chats/{chat}/stream \
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -4357,6 +4367,7 @@ Status Code **200**
|
||||
| `»»» mcp_server_config_id` | string(uuid) | false | | |
|
||||
| `»»» media_type` | string | false | | |
|
||||
| `»»» name` | string | false | | |
|
||||
| `»»» narration` | boolean | false | | Narration marks assistant text that the model labeled as commentary on its work rather than its answer. Only providers that label their output set it. |
|
||||
| `»»» parsed_commands` | array | false | | Parsed commands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise. |
|
||||
| `»»» provider_executed` | boolean | false | | Provider executed indicates the tool call was executed by the provider (e.g. Anthropic computer use). |
|
||||
| `»»» provider_metadata` | array | false | | Provider metadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses. |
|
||||
|
||||
Generated
+98
-14
@@ -3233,6 +3233,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3328,6 +3329,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3388,6 +3390,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
| `mcp_server_config_id` | string | false | | |
|
||||
| `media_type` | string | false | | |
|
||||
| `name` | string | false | | |
|
||||
| `narration` | boolean | false | | Narration marks assistant text that the model labeled as commentary on its work rather than its answer. Only providers that label their output set it. |
|
||||
| `parsed_commands` | array of array | false | | Parsed commands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise. |
|
||||
| `provider_executed` | boolean | false | | Provider executed indicates the tool call was executed by the provider (e.g. Anthropic computer use). |
|
||||
| `provider_metadata` | array of integer | false | | Provider metadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses. |
|
||||
@@ -3502,6 +3505,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -3583,6 +3587,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -4964,6 +4969,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -5127,6 +5133,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -5206,6 +5213,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -5272,6 +5280,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -5387,6 +5396,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -6245,6 +6255,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -6325,6 +6336,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -6406,6 +6418,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -9331,6 +9344,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -9411,6 +9425,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
|
||||
"mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e",
|
||||
"media_type": "string",
|
||||
"name": "string",
|
||||
"narration": true,
|
||||
"parsed_commands": [
|
||||
[
|
||||
"string"
|
||||
@@ -18358,11 +18373,18 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -18652,11 +18674,18 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -19288,11 +19317,18 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
```json
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -19304,20 +19340,52 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|----------------------|----------------------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `cron` | string | false | | |
|
||||
| `display_name` | string | false | | |
|
||||
| `exit_code` | integer | false | | |
|
||||
| `id` | string | false | | |
|
||||
| `log_path` | string | false | | |
|
||||
| `log_source_id` | string | false | | |
|
||||
| `run_on_start` | boolean | false | | |
|
||||
| `run_on_stop` | boolean | false | | |
|
||||
| `script` | string | false | | |
|
||||
| `start_blocks_login` | boolean | false | | |
|
||||
| `status` | [codersdk.WorkspaceAgentScriptStatus](#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `timeout` | integer | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|----------------------|---------------------------------------------------------------------------------------------|----------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `cron` | string | false | | |
|
||||
| `dependencies` | array of [codersdk.WorkspaceAgentScriptDependency](#codersdkworkspaceagentscriptdependency) | false | | Dependencies lists the scripts this one waits for, as the provisioner resolved them. It is omitted when empty. |
|
||||
| `display_name` | string | false | | |
|
||||
| `exit_code` | integer | false | | |
|
||||
| `id` | string | false | | |
|
||||
| `log_path` | string | false | | |
|
||||
| `log_source_id` | string | false | | |
|
||||
| `resource_address` | string | false | | Resource address is the full Terraform address of the coder_script resource, for example "module.git_clone.coder_script.clone". It is empty for scripts that are not coder_script resources. |
|
||||
| `run_on_start` | boolean | false | | |
|
||||
| `run_on_stop` | boolean | false | | |
|
||||
| `script` | string | false | | |
|
||||
| `start_blocks_login` | boolean | false | | |
|
||||
| `status` | [codersdk.WorkspaceAgentScriptStatus](#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `timeout` | integer | false | | |
|
||||
|
||||
## codersdk.WorkspaceAgentScriptDependency
|
||||
|
||||
```json
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------------------------|----------------------------------------------------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `prerequisite_resource_address` | string | false | | |
|
||||
| `requirement` | [codersdk.WorkspaceAgentScriptDependencyRequirement](#codersdkworkspaceagentscriptdependencyrequirement) | false | | |
|
||||
|
||||
## codersdk.WorkspaceAgentScriptDependencyRequirement
|
||||
|
||||
```json
|
||||
"success"
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
| Value(s) |
|
||||
|-------------------------|
|
||||
| `completion`, `success` |
|
||||
|
||||
## codersdk.WorkspaceAgentScriptStatus
|
||||
|
||||
@@ -19689,11 +19757,18 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -20186,11 +20261,18 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -20538,11 +20620,13 @@ If the schedule is empty, the user will be updated to use the default schedule.|
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
|
||||
Generated
+254
-230
@@ -2550,11 +2550,18 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -2604,121 +2611,125 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------------------------|--------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» dependencies` | array | false | | Dependencies lists the scripts this one waits for, as the provisioner resolved them. It is omitted when empty. |
|
||||
| `»»»» prerequisite_resource_address` | string | false | | |
|
||||
| `»»»» requirement` | [codersdk.WorkspaceAgentScriptDependencyRequirement](schemas.md#codersdkworkspaceagentscriptdependencyrequirement) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» resource_address` | string | false | | Resource address is the full Terraform address of the coder_script resource, for example "module.git_clone.coder_script.clone". It is empty for scripts that are not coder_script resources. |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
@@ -2729,6 +2740,7 @@ Status Code **200**
|
||||
| `sharing_level` | `authenticated`, `organization`, `owner`, `public` |
|
||||
| `state` | `complete`, `failure`, `idle`, `working` |
|
||||
| `lifecycle_state` | `created`, `off`, `ready`, `shutdown_error`, `shutdown_timeout`, `shutting_down`, `start_error`, `start_timeout`, `starting` |
|
||||
| `requirement` | `completion`, `success` |
|
||||
| `status` | `connected`, `connecting`, `disconnected`, `exit_failure`, `ok`, `pipes_left_open`, `timed_out`, `timeout` |
|
||||
| `startup_script_behavior` | `blocking`, `non-blocking` |
|
||||
| `workspace_transition` | `delete`, `start`, `stop` |
|
||||
@@ -3245,11 +3257,18 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -3299,121 +3318,125 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|---------------------------------|--------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» agents` | array | false | | |
|
||||
| `»» api_version` | string | false | | |
|
||||
| `»» apps` | array | false | | |
|
||||
| `»»» command` | string | false | | |
|
||||
| `»»» display_name` | string | false | | Display name is a friendly name for the app. |
|
||||
| `»»» external` | boolean | false | | External specifies whether the URL should be opened externally on the client or not. |
|
||||
| `»»» group` | string | false | | |
|
||||
| `»»» health` | [codersdk.WorkspaceAppHealth](schemas.md#codersdkworkspaceapphealth) | false | | |
|
||||
| `»»» healthcheck` | [codersdk.Healthcheck](schemas.md#codersdkhealthcheck) | false | | Healthcheck specifies the configuration for checking app health. |
|
||||
| `»»»» interval` | integer | false | | Interval specifies the seconds between each health check. |
|
||||
| `»»»» threshold` | integer | false | | Threshold specifies the number of consecutive failed health checks before returning "unhealthy". |
|
||||
| `»»»» url` | string | false | | URL specifies the endpoint to check for the app health. |
|
||||
| `»»» hidden` | boolean | false | | |
|
||||
| `»»» icon` | string | false | | Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard. |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» open_in` | [codersdk.WorkspaceAppOpenIn](schemas.md#codersdkworkspaceappopenin) | false | | |
|
||||
| `»»» sharing_level` | [codersdk.WorkspaceAppSharingLevel](schemas.md#codersdkworkspaceappsharinglevel) | false | | |
|
||||
| `»»» slug` | string | false | | Slug is a unique identifier within the agent. |
|
||||
| `»»» statuses` | array | false | | Statuses is a list of statuses for the app. |
|
||||
| `»»»» agent_id` | string(uuid) | false | | |
|
||||
| `»»»» app_id` | string(uuid) | false | | |
|
||||
| `»»»» created_at` | string(date-time) | false | | |
|
||||
| `»»»» icon` | string | false | | Deprecated: This field is unused and will be removed in a future version. Icon is an external URL to an icon that will be rendered in the UI. |
|
||||
| `»»»» id` | string(uuid) | false | | |
|
||||
| `»»»» message` | string | false | | |
|
||||
| `»»»» needs_user_attention` | boolean | false | | Deprecated: This field is unused and will be removed in a future version. NeedsUserAttention specifies whether the status needs user attention. |
|
||||
| `»»»» state` | [codersdk.WorkspaceAppStatusState](schemas.md#codersdkworkspaceappstatusstate) | false | | |
|
||||
| `»»»» uri` | string | false | | Uri is the URI of the resource that the status is for. e.g. https://github.com/org/repo/pull/123 e.g. file:///path/to/file |
|
||||
| `»»»» workspace_id` | string(uuid) | false | | |
|
||||
| `»»» subdomain` | boolean | false | | Subdomain denotes whether the app should be accessed via a path on the `coder server` or via a hostname-based dev URL. If this is set to true and there is no app wildcard configured on the server, the app will not be accessible in the UI. |
|
||||
| `»»» subdomain_name` | string | false | | Subdomain name is the application domain exposed on the `coder server`. |
|
||||
| `»»» tooltip` | string | false | | Tooltip is an optional markdown supported field that is displayed when hovering over workspace apps in the UI. |
|
||||
| `»»» url` | string | false | | URL is the address being proxied to inside the workspace. If external is specified, this will be opened on the client. |
|
||||
| `»» architecture` | string | false | | |
|
||||
| `»» connection_timeout_seconds` | integer | false | | |
|
||||
| `»» created_at` | string(date-time) | false | | |
|
||||
| `»» directory` | string | false | | |
|
||||
| `»» disconnected_at` | string(date-time) | false | | |
|
||||
| `»» display_apps` | array | false | | |
|
||||
| `»» environment_variables` | object | false | | |
|
||||
| `»»» [any property]` | string | false | | |
|
||||
| `»» expanded_directory` | string | false | | |
|
||||
| `»» first_connected_at` | string(date-time) | false | | |
|
||||
| `»» health` | [codersdk.WorkspaceAgentHealth](schemas.md#codersdkworkspaceagenthealth) | false | | Health reports the health of the agent. |
|
||||
| `»»» healthy` | boolean | false | | Healthy is true if the agent is healthy. |
|
||||
| `»»» reason` | string | false | | Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true. |
|
||||
| `»» id` | string(uuid) | false | | |
|
||||
| `»» instance_id` | string | false | | |
|
||||
| `»» last_connected_at` | string(date-time) | false | | |
|
||||
| `»» latency` | object | false | | Latency is mapped by region name (e.g. "New York City", "Seattle"). |
|
||||
| `»»» [any property]` | [codersdk.DERPRegion](schemas.md#codersdkderpregion) | false | | |
|
||||
| `»»»» latency_ms` | number | false | | |
|
||||
| `»»»» preferred` | boolean | false | | |
|
||||
| `»» lifecycle_state` | [codersdk.WorkspaceAgentLifecycle](schemas.md#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| `»» log_sources` | array | false | | |
|
||||
| `»»» created_at` | string(date-time) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» icon` | string | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» workspace_agent_id` | string(uuid) | false | | |
|
||||
| `»» logs_length` | integer | false | | |
|
||||
| `»» logs_overflowed` | boolean | false | | |
|
||||
| `»» metadata` | array | false | | Metadata is only populated on the workspaces list endpoint when the request opts in with the include_agent_metadata search key, and it only carries the requested keys. The description's script is always empty here: it can be long, and list consumers want values. |
|
||||
| `»»» description` | [codersdk.WorkspaceAgentMetadataDescription](schemas.md#codersdkworkspaceagentmetadatadescription) | false | | |
|
||||
| `»»»» display_name` | string | false | | |
|
||||
| `»»»» interval` | integer | false | | |
|
||||
| `»»»» key` | string | false | | |
|
||||
| `»»»» script` | string | false | | |
|
||||
| `»»»» timeout` | integer | false | | |
|
||||
| `»»» result` | [codersdk.WorkspaceAgentMetadataResult](schemas.md#codersdkworkspaceagentmetadataresult) | false | | |
|
||||
| `»»»» age` | integer | false | | Age is the number of seconds since the metadata was collected. It is provided in addition to CollectedAt to protect against clock skew. |
|
||||
| `»»»» collected_at` | string(date-time) | false | | |
|
||||
| `»»»» error` | string | false | | |
|
||||
| `»»»» value` | string | false | | |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» parent_id` | string(uuid) | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» scripts` | array | false | | |
|
||||
| `»»» cron` | string | false | | |
|
||||
| `»»» dependencies` | array | false | | Dependencies lists the scripts this one waits for, as the provisioner resolved them. It is omitted when empty. |
|
||||
| `»»»» prerequisite_resource_address` | string | false | | |
|
||||
| `»»»» requirement` | [codersdk.WorkspaceAgentScriptDependencyRequirement](schemas.md#codersdkworkspaceagentscriptdependencyrequirement) | false | | |
|
||||
| `»»» display_name` | string | false | | |
|
||||
| `»»» exit_code` | integer | false | | |
|
||||
| `»»» id` | string(uuid) | false | | |
|
||||
| `»»» log_path` | string | false | | |
|
||||
| `»»» log_source_id` | string(uuid) | false | | |
|
||||
| `»»» resource_address` | string | false | | Resource address is the full Terraform address of the coder_script resource, for example "module.git_clone.coder_script.clone". It is empty for scripts that are not coder_script resources. |
|
||||
| `»»» run_on_start` | boolean | false | | |
|
||||
| `»»» run_on_stop` | boolean | false | | |
|
||||
| `»»» script` | string | false | | |
|
||||
| `»»» start_blocks_login` | boolean | false | | |
|
||||
| `»»» status` | [codersdk.WorkspaceAgentScriptStatus](schemas.md#codersdkworkspaceagentscriptstatus) | false | | |
|
||||
| `»»» timeout` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_script_behavior` | [codersdk.WorkspaceAgentStartupScriptBehavior](schemas.md#codersdkworkspaceagentstartupscriptbehavior) | false | | Startup script behavior is a legacy field that is deprecated in favor of the `coder_script` resource. It's only referenced by old clients. Deprecated: Remove in the future! |
|
||||
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
|
||||
| `»» subsystems` | array | false | | |
|
||||
| `»» troubleshooting_url` | string | false | | |
|
||||
| `»» updated_at` | string(date-time) | false | | |
|
||||
| `»» version` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» daily_cost` | integer | false | | |
|
||||
| `» hide` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» id` | string(uuid) | false | | |
|
||||
| `» job_id` | string(uuid) | false | | |
|
||||
| `» metadata` | array | false | | |
|
||||
| `»» key` | string | false | | |
|
||||
| `»» sensitive` | boolean | false | | |
|
||||
| `»» value` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | string | false | | |
|
||||
| `» workspace_transition` | [codersdk.WorkspaceTransition](schemas.md#codersdkworkspacetransition) | false | | |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
@@ -3424,6 +3447,7 @@ Status Code **200**
|
||||
| `sharing_level` | `authenticated`, `organization`, `owner`, `public` |
|
||||
| `state` | `complete`, `failure`, `idle`, `working` |
|
||||
| `lifecycle_state` | `created`, `off`, `ready`, `shutdown_error`, `shutdown_timeout`, `shutting_down`, `start_error`, `start_timeout`, `starting` |
|
||||
| `requirement` | `completion`, `success` |
|
||||
| `status` | `connected`, `connecting`, `disconnected`, `exit_failure`, `ok`, `pipes_left_open`, `timed_out`, `timeout` |
|
||||
| `startup_script_behavior` | `blocking`, `non-blocking` |
|
||||
| `workspace_transition` | `delete`, `start`, `stop` |
|
||||
|
||||
Generated
+37
@@ -254,11 +254,18 @@ of the template will be used.
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -630,11 +637,18 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -972,11 +986,18 @@ of the template will be used.
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -1264,11 +1285,13 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -1583,11 +1606,18 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
@@ -2211,11 +2241,18 @@ curl -X PUT http://coder-server:8080/api/v2/workspaces/{workspace}/dormant \
|
||||
"scripts": [
|
||||
{
|
||||
"cron": "string",
|
||||
"dependencies": [
|
||||
{
|
||||
"prerequisite_resource_address": "string",
|
||||
"requirement": "success"
|
||||
}
|
||||
],
|
||||
"display_name": "string",
|
||||
"exit_code": 0,
|
||||
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
|
||||
"log_path": "string",
|
||||
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
|
||||
"resource_address": "string",
|
||||
"run_on_start": true,
|
||||
"run_on_stop": true,
|
||||
"script": "string",
|
||||
|
||||
@@ -540,7 +540,7 @@ Refer to [Support bundle](../support/support-bundle.md).
|
||||
|
||||
### Supported editors and IDEs
|
||||
|
||||
The editors and IDEs that connect to Coder workspaces, including [VS Code](../user-guides/workspace-access/vscode.md), [code-server](../user-guides/workspace-access/code-server.md), [Cursor](../user-guides/workspace-access/cursor.md), [Devin Desktop](../user-guides/workspace-access/devin-desktop.md), [Antigravity](../user-guides/workspace-access/antigravity.md), [Zed](../user-guides/workspace-access/zed.md), and JetBrains IDEs through [Gateway](../user-guides/workspace-access/jetbrains/gateway.md) and [Toolbox](../user-guides/workspace-access/jetbrains/toolbox.md).
|
||||
The editors and IDEs that connect to Coder workspaces, including [VS Code](../user-guides/workspace-access/vscode.md), [code-server](../user-guides/workspace-access/code-server.md), [Cursor](../user-guides/workspace-access/cursor.md), [Devin Desktop](../user-guides/workspace-access/devin-desktop.md), [Antigravity](../user-guides/workspace-access/antigravity.md), [Claude Desktop](../user-guides/workspace-access/claude-desktop.md), [Zed](../user-guides/workspace-access/zed.md), and JetBrains IDEs through [Gateway](../user-guides/workspace-access/jetbrains/gateway.md) and [Toolbox](../user-guides/workspace-access/jetbrains/toolbox.md).
|
||||
|
||||
### Swagger
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ pages.
|
||||
<!-- RELEASE_CALENDAR_START -->
|
||||
| Release name | Release Date | Status | Latest Release |
|
||||
|--------------------------------------------------|--------------------|--------------------------|------------------------------------------------------------------|
|
||||
| [2.29](https://coder.com/changelog/coder-2-29) | December 02, 2025 | Extended Support Release | [v2.29.19](https://github.com/coder/coder/releases/tag/v2.29.19) |
|
||||
| [2.29](https://coder.com/changelog/coder-2-29) | December 02, 2025 | Extended Support Release | [v2.29.21](https://github.com/coder/coder/releases/tag/v2.29.21) |
|
||||
| [2.32](https://coder.com/changelog/coder-2-32) | April 14, 2026 | Not Supported | [v2.32.10](https://github.com/coder/coder/releases/tag/v2.32.10) |
|
||||
| [2.33](https://coder.com/changelog/coder-2-33) | May 05, 2026 | Not Supported | [v2.33.11](https://github.com/coder/coder/releases/tag/v2.33.11) |
|
||||
| [2.34](https://coder.com/changelog/coder-2-34) | June 02, 2026 | Extended Support Release | [v2.34.10](https://github.com/coder/coder/releases/tag/v2.34.10) |
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: Claude Desktop
|
||||
---
|
||||
|
||||
[Claude Desktop](https://claude.com/download) is Anthropic's desktop app for Claude.
|
||||
Claude Desktop can list your running Coder workspaces, so you can connect to them from the app.
|
||||
|
||||
> [!NOTE]
|
||||
> This integration is implemented by Claude Desktop, not by Coder.
|
||||
> Anthropic's documentation doesn't currently describe it, and the behavior can change between Claude Desktop versions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Claude Desktop](https://claude.com/download) installed on your local machine.
|
||||
- The [Coder CLI](../../install/cli.md) installed and on your `PATH`.
|
||||
- The Coder CLI authenticated with your deployment:
|
||||
|
||||
```sh
|
||||
coder login <deployment-url>
|
||||
```
|
||||
|
||||
- At least one running workspace.
|
||||
|
||||
## Set up Claude Desktop
|
||||
|
||||
1. Install the Coder CLI and confirm `coder version` works in your terminal.
|
||||
|
||||
1. Authenticate the CLI with your deployment:
|
||||
|
||||
```sh
|
||||
coder login <deployment-url>
|
||||
```
|
||||
|
||||
1. Restart Claude Desktop.
|
||||
Your running workspaces appear in Claude Desktop.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If your workspaces don't appear in Claude Desktop, check the following:
|
||||
|
||||
1. The Coder CLI is installed and on your `PATH`.
|
||||
Run `coder version`.
|
||||
1. You're logged in.
|
||||
Run `coder login <deployment-url>` if needed.
|
||||
1. The workspace is running.
|
||||
|
||||
## Next steps
|
||||
|
||||
Claude Desktop connects to workspaces you already have.
|
||||
To explore other ways to use Claude with Coder:
|
||||
|
||||
- [Agent Relay for Claude Code](../../ai-coder/agent-relay/claude-code.md):
|
||||
run Claude Code's cloud sessions inside self-hosted Coder workspaces.
|
||||
Unlike the Claude Desktop integration, Agent Relay orchestrates the workspaces itself.
|
||||
It creates a workspace from a template for each session and deletes it when the session ends, instead of using your existing workspaces.
|
||||
Visit the [Agent Relay overview](../../ai-coder/agent-relay/index.md) for how it works.
|
||||
- [Claude Code with AI Gateway](../../ai-coder/ai-gateway/clients/claude-code.md):
|
||||
route Claude Code running in a workspace through AI Gateway.
|
||||
@@ -142,7 +142,7 @@ You can develop in your Coder workspace remotely with
|
||||
[VS Code](https://code.visualstudio.com/download).
|
||||
We support connecting with the desktop client and VS Code in the browser with [code-server](#code-server).
|
||||
|
||||

|
||||

|
||||
|
||||
Read more details on [using VS Code in your workspace](./vscode.md).
|
||||
|
||||
@@ -165,6 +165,13 @@ Antigravity connects using the Coder extension.
|
||||
|
||||
Read more about [using Antigravity with your workspace](./antigravity.md).
|
||||
|
||||
## Claude Desktop
|
||||
|
||||
[Claude Desktop](https://claude.com/download) is Anthropic's desktop app for Claude.
|
||||
Once the Coder CLI is installed and logged in, your running workspaces appear in Claude Desktop.
|
||||
|
||||
Read more about [using Claude Desktop with your workspace](./claude-desktop.md).
|
||||
|
||||
## JetBrains IDEs
|
||||
|
||||
We support JetBrains IDEs using
|
||||
|
||||
@@ -16,7 +16,7 @@ VS Code desktop is a default app for workspaces.
|
||||
Select **VS Code Desktop** in the dashboard to one-click enter a workspace.
|
||||
This automatically installs the [Coder Remote](https://github.com/coder/vscode-coder) extension, authenticates with Coder, and connects to the workspace.
|
||||
|
||||

|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> The `VS Code Desktop` button can be hidden by enabling
|
||||
|
||||
@@ -436,7 +436,7 @@ coderd_dbpurge_records_purged_total{record_type=""} 0
|
||||
# HELP coderd_experiments Indicates whether each experiment is enabled (1) or not (0)
|
||||
# TYPE coderd_experiments gauge
|
||||
coderd_experiments{experiment=""} 0
|
||||
# HELP coderd_insights_applications_usage_seconds The application usage per template.
|
||||
# HELP coderd_insights_applications_usage_seconds The application usage per template. Built-in apps are grouped by app family, such as Visual Studio Code, JetBrains, Web Terminal, or SSH, with an empty slug. A user-minute counts once per family.
|
||||
# TYPE coderd_insights_applications_usage_seconds gauge
|
||||
coderd_insights_applications_usage_seconds{template_name="",application_name="",slug="",organization_name=""} 0
|
||||
# HELP coderd_insights_parameters The parameter usage per template.
|
||||
|
||||
Generated
+35
-30
@@ -3756,6 +3756,12 @@ export interface ChatSystemPromptResponse {
|
||||
export interface ChatTextPart {
|
||||
readonly type: "text";
|
||||
readonly text: string;
|
||||
/**
|
||||
* Narration marks assistant text that the model labeled as commentary
|
||||
* on its work rather than its answer. Only providers that label their
|
||||
* output set it.
|
||||
*/
|
||||
readonly narration?: boolean;
|
||||
}
|
||||
|
||||
// From codersdk/chats.go
|
||||
@@ -10137,36 +10143,6 @@ export const TemplateBuilderVariableTypes: TemplateBuilderVariableType[] = [
|
||||
"string",
|
||||
];
|
||||
|
||||
// From codersdk/insights.go
|
||||
/**
|
||||
* Enums define the display name of the builtin app reported.
|
||||
*/
|
||||
export const TemplateBuiltinAppDisplayNameJetBrains = "JetBrains";
|
||||
|
||||
// From codersdk/insights.go
|
||||
/**
|
||||
* Enums define the display name of the builtin app reported.
|
||||
*/
|
||||
export const TemplateBuiltinAppDisplayNameSFTP = "SFTP";
|
||||
|
||||
// From codersdk/insights.go
|
||||
/**
|
||||
* Enums define the display name of the builtin app reported.
|
||||
*/
|
||||
export const TemplateBuiltinAppDisplayNameSSH = "SSH";
|
||||
|
||||
// From codersdk/insights.go
|
||||
/**
|
||||
* Enums define the display name of the builtin app reported.
|
||||
*/
|
||||
export const TemplateBuiltinAppDisplayNameVSCode = "Visual Studio Code";
|
||||
|
||||
// From codersdk/insights.go
|
||||
/**
|
||||
* Enums define the display name of the builtin app reported.
|
||||
*/
|
||||
export const TemplateBuiltinAppDisplayNameWebTerminal = "Web Terminal";
|
||||
|
||||
// From codersdk/templates.go
|
||||
export interface TemplateExample {
|
||||
readonly id: string;
|
||||
@@ -12236,10 +12212,39 @@ export interface WorkspaceAgentScript {
|
||||
readonly start_blocks_login: boolean;
|
||||
readonly timeout: number;
|
||||
readonly display_name: string;
|
||||
/**
|
||||
* ResourceAddress is the full Terraform address of the coder_script
|
||||
* resource, for example "module.git_clone.coder_script.clone". It is
|
||||
* empty for scripts that are not coder_script resources.
|
||||
*/
|
||||
readonly resource_address: string;
|
||||
/**
|
||||
* Dependencies lists the scripts this one waits for, as the
|
||||
* provisioner resolved them. It is omitted when empty.
|
||||
*/
|
||||
readonly dependencies?: readonly WorkspaceAgentScriptDependency[];
|
||||
readonly exit_code?: number;
|
||||
readonly status?: WorkspaceAgentScriptStatus;
|
||||
}
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
/**
|
||||
* WorkspaceAgentScriptDependency names a prerequisite script and the
|
||||
* outcome it must reach.
|
||||
*/
|
||||
export interface WorkspaceAgentScriptDependency {
|
||||
readonly prerequisite_resource_address: string;
|
||||
readonly requirement: WorkspaceAgentScriptDependencyRequirement;
|
||||
}
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type WorkspaceAgentScriptDependencyRequirement =
|
||||
| "completion"
|
||||
| "success";
|
||||
|
||||
export const WorkspaceAgentScriptDependencyRequirements: WorkspaceAgentScriptDependencyRequirement[] =
|
||||
["completion", "success"];
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
export type WorkspaceAgentScriptStatus =
|
||||
| "exit_failure"
|
||||
|
||||
@@ -86,7 +86,7 @@ export const BreadcrumbSeparator: React.FC<
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"text-content-disabled [&>svg]:w-3.5 [&>svg]:h-3.5",
|
||||
"text-content-secondary [&>svg]:w-3.5 [&>svg]:h-3.5",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -54,7 +54,7 @@ export const TopbarDivider: React.FC<
|
||||
Omit<React.ComponentProps<"span">, "children">
|
||||
> = ({ className, ...props }) => {
|
||||
return (
|
||||
<span {...props} className={cn("text-border", className)}>
|
||||
<span {...props} className={cn("text-content-secondary", className)}>
|
||||
/
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { Toaster } from "./Toaster";
|
||||
import { toast } from "./toast";
|
||||
|
||||
const SONNER_DEFAULT_DURATION_MS = 4_000;
|
||||
|
||||
describe("toast", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers({ shouldAdvanceTime: true });
|
||||
render(<Toaster />);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
toast.dismiss();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("keeps error toasts visible until the user dismisses them", async () => {
|
||||
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
||||
toast.error('Failed to open "Cursor Desktop".', {
|
||||
description: "The app must be installed first.",
|
||||
});
|
||||
expect(
|
||||
await screen.findByText('Failed to open "Cursor Desktop".'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(SONNER_DEFAULT_DURATION_MS * 10);
|
||||
expect(
|
||||
screen.getByText('Failed to open "Cursor Desktop".'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByRole("button", { name: "Close toast" }));
|
||||
await vi.advanceTimersByTimeAsync(1_000);
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByText('Failed to open "Cursor Desktop".'),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the error toast of a rejected promise visible", async () => {
|
||||
toast.promise(Promise.reject(new Error("already a member")), {
|
||||
loading: "Adding member...",
|
||||
error: (err) => ({
|
||||
message: "Failed to add member.",
|
||||
description: err instanceof Error ? err.message : undefined,
|
||||
}),
|
||||
});
|
||||
expect(
|
||||
await screen.findByText("Failed to add member."),
|
||||
).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(SONNER_DEFAULT_DURATION_MS * 10);
|
||||
expect(screen.getByText("Failed to add member.")).toBeInTheDocument();
|
||||
expect(screen.getByText("already a member")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("still auto-dismisses success toasts", async () => {
|
||||
toast.success("Member added.");
|
||||
expect(await screen.findByText("Member added.")).toBeInTheDocument();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(SONNER_DEFAULT_DURATION_MS * 2);
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByText("Member added.")).not.toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import { isValidElement } from "react";
|
||||
import { type ExternalToast, toast as sonnerToast } from "sonner";
|
||||
|
||||
// Error toasts stay until the user dismisses them so everyone has enough time
|
||||
// to read and act on them (WCAG 2.2.1 Timing Adjustable). Other toast types
|
||||
// keep Sonner's timer.
|
||||
const persistentToast = {
|
||||
duration: Number.POSITIVE_INFINITY,
|
||||
} satisfies ExternalToast;
|
||||
|
||||
const error: typeof sonnerToast.error = (message, data) =>
|
||||
sonnerToast.error(message, { ...persistentToast, ...data });
|
||||
|
||||
// Sonner renders a rejected promise as an error toast without calling
|
||||
// toast.error, so the error result needs the persistent duration too.
|
||||
const promise: typeof sonnerToast.promise = (promiseToTrack, data) => {
|
||||
if (data?.error === undefined) {
|
||||
return sonnerToast.promise(promiseToTrack, data);
|
||||
}
|
||||
const errorResult = data.error;
|
||||
return sonnerToast.promise(promiseToTrack, {
|
||||
...data,
|
||||
error: async (err: unknown) => {
|
||||
const result =
|
||||
typeof errorResult === "function"
|
||||
? await errorResult(err)
|
||||
: errorResult;
|
||||
if (
|
||||
typeof result === "object" &&
|
||||
result !== null &&
|
||||
!isValidElement(result) &&
|
||||
"message" in result
|
||||
) {
|
||||
return { ...persistentToast, ...result };
|
||||
}
|
||||
return { ...persistentToast, message: result };
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const toast: typeof sonnerToast = Object.assign(
|
||||
(...args: Parameters<typeof sonnerToast>) => sonnerToast(...args),
|
||||
sonnerToast,
|
||||
{ error, promise },
|
||||
);
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createContext, useCallback, useContext } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { isApiError } from "#/api/errors";
|
||||
import { checkAuthorization } from "#/api/queries/authCheck";
|
||||
import {
|
||||
@@ -11,6 +10,7 @@ import {
|
||||
updateProfile as updateProfileOptions,
|
||||
} from "#/api/queries/users";
|
||||
import type { UpdateUserProfileRequest, User } from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useEmbeddedMetadata } from "#/hooks/useEmbeddedMetadata";
|
||||
import { type Permissions, permissionChecks } from "#/modules/permissions";
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
import { renderHook } from "@testing-library/react";
|
||||
import { act } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { createDeferred } from "#/testHelpers/deferred";
|
||||
import {
|
||||
COPY_FAILED_MESSAGE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
const CLIPBOARD_TIMEOUT_MS = 1_000;
|
||||
export const COPY_FAILED_MESSAGE = "Failed to copy text to clipboard";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { watchBuildLogsByBuildId } from "#/api/api";
|
||||
import type { ProvisionerJobLog } from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
export const useWorkspaceBuildLogs = (
|
||||
// buildId is optional because sometimes the build is not loaded yet
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { toast } from "sonner";
|
||||
import type {
|
||||
Workspace,
|
||||
WorkspaceAgent,
|
||||
WorkspaceApp,
|
||||
} from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
// This is a magic undocumented string that is replaced
|
||||
// with a brand-new session token from the backend.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type React from "react";
|
||||
import { useMutation } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { API } from "#/api/api";
|
||||
import { getErrorMessage } from "#/api/errors";
|
||||
import type {
|
||||
@@ -8,6 +7,7 @@ import type {
|
||||
WorkspaceAgent,
|
||||
WorkspaceApp,
|
||||
} from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useProxy } from "#/contexts/ProxyContext";
|
||||
import {
|
||||
getAppHref,
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { Avatar } from "#/components/Avatar/Avatar";
|
||||
import { Button } from "#/components/Button/Button";
|
||||
@@ -26,6 +25,7 @@ import {
|
||||
} from "#/components/DropdownMenu/DropdownMenu";
|
||||
import { ExternalImage } from "#/components/ExternalImage/ExternalImage";
|
||||
import { Latency } from "#/components/Latency/Latency";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import type { ProxyContextValue } from "#/contexts/ProxyContext";
|
||||
import { getLatencyColor } from "#/utils/latency";
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { RadioIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { Abbr } from "#/components/Abbr/Abbr";
|
||||
import { ChevronDownIcon } from "#/components/AnimatedIcons/ChevronDown";
|
||||
@@ -18,6 +17,7 @@ import {
|
||||
import { ExternalImage } from "#/components/ExternalImage/ExternalImage";
|
||||
import { Latency } from "#/components/Latency/Latency";
|
||||
import { Skeleton } from "#/components/Skeleton/Skeleton";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import type { ProxyContextValue } from "#/contexts/ProxyContext";
|
||||
import { useAuthenticated } from "#/hooks/useAuthenticated";
|
||||
import { getLatencyColor } from "#/utils/latency";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { saveAs } from "file-saver";
|
||||
import { DownloadIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail } from "#/api/errors";
|
||||
import type {
|
||||
GroupSyncSettings,
|
||||
@@ -9,6 +8,7 @@ import type {
|
||||
RoleSyncSettings,
|
||||
} from "#/api/typesGenerated";
|
||||
import { Button, type ButtonProps } from "#/components/Button/Button";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
type ExportableSyncSettings =
|
||||
| GroupSyncSettings
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useCallback, useEffect } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { watchInboxNotifications } from "#/api/api";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import type {
|
||||
ListInboxNotificationsResponse,
|
||||
UpdateInboxNotificationReadStatusResponse,
|
||||
} from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { InboxPopover } from "./InboxPopover";
|
||||
|
||||
const NOTIFICATIONS_QUERY_KEY = ["notifications"];
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { cn } from "cn";
|
||||
import { ContainerIcon, ExternalLinkIcon } from "lucide-react";
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { API } from "#/api/api";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import {
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
} from "#/components/Dialog/Dialog";
|
||||
import { Skeleton } from "#/components/Skeleton/Skeleton";
|
||||
import { Spinner } from "#/components/Spinner/Spinner";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { cn } from "cn";
|
||||
import dayjs from "dayjs";
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { watchAgentMetadata } from "#/api/api";
|
||||
import type {
|
||||
ServerSentEvent,
|
||||
@@ -9,6 +8,7 @@ import type {
|
||||
WorkspaceAgentMetadata,
|
||||
} from "#/api/typesGenerated";
|
||||
import { Skeleton } from "#/components/Skeleton/Skeleton";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { saveAs } from "file-saver";
|
||||
import { ChevronDownIcon, DownloadIcon, PackageIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail } from "#/api/errors";
|
||||
import { Button } from "#/components/Button/Button";
|
||||
import {
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "#/components/DropdownMenu/DropdownMenu";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
type DownloadableLogSet = {
|
||||
label: string;
|
||||
|
||||
@@ -2,9 +2,9 @@ import { renderHook, waitFor } from "@testing-library/react";
|
||||
import { HttpResponse, http } from "msw";
|
||||
import { act } from "react";
|
||||
import { QueryClientProvider } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import * as API from "#/api/api";
|
||||
import type { WorkspaceAgentListContainersResponse } from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import {
|
||||
MockWorkspaceAgent,
|
||||
MockWorkspaceAgentDevcontainer,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useEffect, useEffectEvent } from "react";
|
||||
import { useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { watchAgentContainers } from "#/api/api";
|
||||
import {
|
||||
workspaceAgentContainers,
|
||||
@@ -11,6 +10,7 @@ import type {
|
||||
WorkspaceAgentDevcontainer,
|
||||
WorkspaceAgentListContainersResponse,
|
||||
} from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
export function useAgentContainers(
|
||||
agent: WorkspaceAgent,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { renderHook, waitFor } from "@testing-library/react";
|
||||
import { act } from "react";
|
||||
import { toast } from "sonner";
|
||||
import type { MockInstance } from "vitest";
|
||||
import * as apiModule from "#/api/api";
|
||||
import type { WorkspaceAgentLog } from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { MockWorkspaceAgent } from "#/testHelpers/entities";
|
||||
import {
|
||||
createMockWebSocket,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { watchWorkspaceAgentLogs } from "#/api/api";
|
||||
import type { WorkspaceAgentLog } from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
type UseAgentLogsOptions = Readonly<{
|
||||
agentId: string;
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
ExponentialBackoff,
|
||||
type Websocket,
|
||||
@@ -28,6 +27,7 @@ import {
|
||||
ContextMenuItem,
|
||||
ContextMenuTrigger,
|
||||
} from "#/components/ContextMenu/ContextMenu";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useClipboard } from "#/hooks/useClipboard";
|
||||
import { isMac } from "#/utils/platform";
|
||||
import { terminalWebsocketUrl } from "#/utils/terminal";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import { roles } from "#/api/queries/roles";
|
||||
import {
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
import type { User } from "#/api/typesGenerated";
|
||||
import { ConfirmDialog } from "#/components/Dialog/ConfirmDialog/ConfirmDialog";
|
||||
import { DeleteDialog } from "#/components/Dialog/DeleteDialog/DeleteDialog";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { RoleSelectorDialog } from "#/modules/roles/RoleSelectorDialog";
|
||||
import { generateRandomBase64String } from "#/utils/random";
|
||||
import { ResetPasswordDialog } from "./ResetPasswordDialog";
|
||||
|
||||
@@ -3,7 +3,6 @@ import { saveAs } from "file-saver";
|
||||
import JSZip from "jszip";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useQueries, useQuery } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail } from "#/api/errors";
|
||||
import { agentLogs, buildLogs } from "#/api/queries/workspaces";
|
||||
import type { Workspace, WorkspaceAgent } from "#/api/typesGenerated";
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
type ConfirmDialogProps,
|
||||
} from "#/components/Dialog/ConfirmDialog/ConfirmDialog";
|
||||
import { Skeleton } from "#/components/Skeleton/Skeleton";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { getWorkspaceAgents } from "#/utils/workspace";
|
||||
|
||||
type DownloadLogsDialogProps = Pick<
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { Link as RouterLink } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { ParameterValidationError } from "#/api/api";
|
||||
import {
|
||||
type ApiError,
|
||||
@@ -33,6 +32,7 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "#/components/DropdownMenu/DropdownMenu";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { WorkspaceErrorDialog } from "../ErrorDialog/WorkspaceErrorDialog";
|
||||
import { UpdateBuildParametersDialog } from "../WorkspaceUpdateDialogs";
|
||||
import { ChangeWorkspaceVersionDialog } from "./ChangeWorkspaceVersionDialog";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CircleAlertIcon, RotateCcwIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import { templateVersion } from "#/api/queries/templates";
|
||||
import type { Workspace } from "#/api/typesGenerated";
|
||||
@@ -17,6 +16,7 @@ import {
|
||||
} from "#/components/HelpPopover/HelpPopover";
|
||||
import { Link } from "#/components/Link/Link";
|
||||
import { Skeleton } from "#/components/Skeleton/Skeleton";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { linkToTemplate, useLinks } from "#/modules/navigation";
|
||||
import {
|
||||
useWorkspaceUpdate,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
setWorkspaceGroupRole,
|
||||
setWorkspaceUserRole,
|
||||
@@ -13,6 +12,7 @@ import type {
|
||||
WorkspaceRole,
|
||||
WorkspaceUser,
|
||||
} from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
|
||||
/**
|
||||
* Encapsulates all data fetching and mutations for workspace sharing.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorMessage } from "#/api/errors";
|
||||
import {
|
||||
aiGatewayKeysList,
|
||||
@@ -9,6 +8,7 @@ import {
|
||||
} from "#/api/queries/aiGatewayKeys";
|
||||
import type { AIGatewayKey } from "#/api/typesGenerated";
|
||||
import { ConfirmDialog } from "#/components/Dialog/ConfirmDialog/ConfirmDialog";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useAuthenticated } from "#/hooks/useAuthenticated";
|
||||
import { useFeatureVisibility } from "#/modules/dashboard/useFeatureVisibility";
|
||||
import { RequirePermission } from "#/modules/permissions/RequirePermission";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useFormik } from "formik";
|
||||
import { useState } from "react";
|
||||
import TextareaAutosize from "react-textarea-autosize";
|
||||
import { toast } from "sonner";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { Alert, AlertDescription } from "#/components/Alert/Alert";
|
||||
import { ErrorAlert } from "#/components/Alert/ErrorAlert";
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
} from "#/components/SettingsHeader/SettingsHeader";
|
||||
import { Spinner } from "#/components/Spinner/Spinner";
|
||||
import { Switch } from "#/components/Switch/Switch";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { TextPreviewDialog } from "#/pages/AgentsPage/components/TextPreviewDialog";
|
||||
import { OrganizationSettingsSection } from "#/pages/AISettingsPage/components/OrganizationSettingsSection";
|
||||
import { SettingsSection } from "#/pages/AISettingsPage/components/SettingsSection";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import type { UseMutateFunction } from "react-query";
|
||||
import TextareaAutosize from "react-textarea-autosize";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorMessage } from "#/api/errors";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { Alert, AlertDescription } from "#/components/Alert/Alert";
|
||||
@@ -9,6 +8,7 @@ import { ErrorAlert } from "#/components/Alert/ErrorAlert";
|
||||
import { Button } from "#/components/Button/Button";
|
||||
import { Loader } from "#/components/Loader/Loader";
|
||||
import { Spinner } from "#/components/Spinner/Spinner";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { countInvisibleCharacters } from "#/utils/invisibleUnicode";
|
||||
|
||||
type OrganizationInstructionsSettingsProps = {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useEffect } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { useNavigate, useSearchParams } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorMessage } from "#/api/errors";
|
||||
import { createMCPServerConfig } from "#/api/queries/chats";
|
||||
import { organizationsPermissions } from "#/api/queries/organizations";
|
||||
import { ErrorAlert } from "#/components/Alert/ErrorAlert";
|
||||
import { Loader } from "#/components/Loader/Loader";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useAuthenticated } from "#/hooks/useAuthenticated";
|
||||
import { useDashboard } from "#/modules/dashboard/useDashboard";
|
||||
import { RequirePermission } from "#/modules/permissions/RequirePermission";
|
||||
|
||||
+1
-1
@@ -5,7 +5,6 @@ import {
|
||||
useParams,
|
||||
useSearchParams,
|
||||
} from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorMessage, isApiError } from "#/api/errors";
|
||||
import {
|
||||
deleteMCPServerConfig,
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
import { organizationsPermissions } from "#/api/queries/organizations";
|
||||
import { ErrorAlert } from "#/components/Alert/ErrorAlert";
|
||||
import { Loader } from "#/components/Loader/Loader";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { useAuthenticated } from "#/hooks/useAuthenticated";
|
||||
import { useDashboard } from "#/modules/dashboard/useDashboard";
|
||||
import { RequirePermission } from "#/modules/permissions/RequirePermission";
|
||||
|
||||
+2
-2
@@ -61,9 +61,9 @@ export const CollapsibleSection: React.FC<{
|
||||
>
|
||||
<CollapsibleTrigger className="flex w-full cursor-pointer items-start gap-2 border-0 bg-transparent p-0 text-left transition-colors hover:text-content-primary">
|
||||
{open ? (
|
||||
<ChevronDownIcon className="mt-0.5 size-4 shrink-0 text-content-primary" />
|
||||
<ChevronDownIcon className="mt-1 size-4 shrink-0 text-content-primary" />
|
||||
) : (
|
||||
<ChevronRightIcon className="mt-0.5 size-4 shrink-0 text-content-primary" />
|
||||
<ChevronRightIcon className="mt-1 size-4 shrink-0 text-content-primary" />
|
||||
)}
|
||||
<div>
|
||||
<h3 className="m-0 text-sm font-medium text-content-primary">
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
mcpServerConfigACL,
|
||||
updateMCPServerConfigACL,
|
||||
} from "#/api/queries/chats";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { getGroupSubtitle, isGroup } from "#/modules/groups";
|
||||
import {
|
||||
ResourceSharingDialog,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { useNavigate, useSearchParams } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import { chatModels, createChatModel } from "#/api/queries/chats";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import {
|
||||
canManageProviderModels,
|
||||
deriveProviderStates,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { isAxiosError } from "axios";
|
||||
import { useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { Navigate, useNavigate, useParams } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { getErrorDetail, getErrorMessage } from "#/api/errors";
|
||||
import {
|
||||
chatModel,
|
||||
@@ -11,6 +10,7 @@ import {
|
||||
updateChatModel,
|
||||
} from "#/api/queries/chats";
|
||||
import { Loader } from "#/components/Loader/Loader";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { deriveProviderStates } from "#/modules/aiModels/providerStates";
|
||||
import { pageTitle } from "#/utils/page";
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { toast } from "sonner";
|
||||
import { chatModelACL, updateChatModelACL } from "#/api/queries/chats";
|
||||
import type * as TypesGen from "#/api/typesGenerated";
|
||||
import { toast } from "#/components/Toaster/toast";
|
||||
import { getGroupSubtitle, isGroup } from "#/modules/groups";
|
||||
import {
|
||||
ResourceSharingDialog,
|
||||
|
||||
@@ -31,9 +31,11 @@ import {
|
||||
MockAzureProviderState,
|
||||
MockDisabledProviderState,
|
||||
MockGoogleProviderState,
|
||||
MockOpenAICompatProviderState,
|
||||
MockOpenAIProviderState,
|
||||
mockClaude,
|
||||
mockGPT5,
|
||||
mockOpenAICompatModel,
|
||||
mockProviderDisabledModel,
|
||||
} from "../testFixtures";
|
||||
import { ModelForm } from "./ModelForm";
|
||||
@@ -294,6 +296,18 @@ export const Edit: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
// openai-compat has no bundled icon, so the helper text under the provider
|
||||
// select is the only place the form shows the exact type used for pricing.
|
||||
export const ShowProviderType: Story = {
|
||||
args: {
|
||||
providerStates: [MockOpenAIProviderState, MockOpenAICompatProviderState],
|
||||
selectedProviderState: MockOpenAICompatProviderState,
|
||||
editingModel: mockOpenAICompatModel,
|
||||
onDeleteModel: fn(async () => undefined),
|
||||
onDuplicate: fn(),
|
||||
},
|
||||
};
|
||||
|
||||
export const ShareOnlyAccess: Story = {
|
||||
args: {
|
||||
editingModel: mockGPT5,
|
||||
|
||||
@@ -78,9 +78,9 @@ const CollapsibleSection: React.FC<{
|
||||
>
|
||||
<CollapsibleTrigger className="flex w-full cursor-pointer items-start gap-2 border-0 bg-transparent p-0 text-left transition-colors hover:text-content-primary">
|
||||
{open ? (
|
||||
<ChevronDownIcon className="mt-0.5 size-4 shrink-0 text-content-secondary" />
|
||||
<ChevronDownIcon className="mt-1 size-4 shrink-0 text-content-secondary" />
|
||||
) : (
|
||||
<ChevronRightIcon className="mt-0.5 size-4 shrink-0 text-content-secondary" />
|
||||
<ChevronRightIcon className="mt-1 size-4 shrink-0 text-content-secondary" />
|
||||
)}
|
||||
<div>
|
||||
<h3 className="m-0 text-sm font-medium text-content-primary">
|
||||
|
||||
Loaded 100 of 219 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user