Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71638c2

Browse files
committed
Merge branch 'main' ofhttps://github.com/coder/coder into bq/fix-show-error-when-chat-unhelathy
2 parents984e5cc +a78790c commit71638c2

File tree

107 files changed

+7374
-1077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+7374
-1077
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
required:true
1313
default:"traiage"
1414
type:string
15+
template_preset:
16+
description:"Template preset to use"
17+
required:true
18+
default:"Default"
19+
type:string
1520
prefix:
1621
description:"Prefix for workspace name"
1722
required:false
@@ -68,67 +73,62 @@ jobs:
6873
coder whoami
6974
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
7075
71-
-name:Create Coder workspace
72-
id:create-workspace
76+
# TODO(Cian): this is a good use-case for 'recipes'
77+
-name:Create Coder task
78+
id:create-task
7379
env:
74-
PREFIX:${{ inputs.prefix }}
7580
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
81+
GITHUB_TOKEN:${{ github.token }}
82+
ISSUE_URL:${{ inputs.issue_url }}
83+
PREFIX:${{ inputs.prefix }}
7684
RUN_ID:${{ github.run_id }}
7785
TEMPLATE_PARAMETERS:${{ secrets.TRAIAGE_TEMPLATE_PARAMETERS }}
86+
TEMPLATE_PRESET:${{ inputs.template_preset }}
87+
# TODO: replace with coder exp task command
88+
APP_SLUG:ccw
7889
run:|
79-
export WORKSPACE_NAME="${PREFIX}-${CONTEXT_KEY}-${RUN_ID}"
80-
echo "Creating workspace: $WORKSPACE_NAME"
81-
./scripts/traiage.sh create
82-
echo "workspace_name=$WORKSPACE_NAME" >> "${GITHUB_OUTPUT}"
83-
echo "WORKSPACE_NAME=${WORKSPACE_NAME}" >> "${GITHUB_ENV}"
84-
85-
-name:Send prompt to AI agent inside workspace
86-
id:prepare-prompt
87-
env:
88-
WORKSPACE_NAME:${{ steps.create-workspace.outputs.workspace_name }}
89-
ISSUE_URL:${{ inputs.issue_url }}
90-
GITHUB_TOKEN:${{ github.token }}
91-
run:|
92-
PROMPT_FILE=$(mktemp)
93-
trap 'rm -f "${PROMPT_FILE}"' EXIT
94-
9590
# Fetch issue description using `gh` CLI
9691
issue_description=$(gh issue view "${ISSUE_URL}")
9792
9893
# Write a prompt to PROMPT_FILE
99-
cat > "${PROMPT_FILE}" <<EOF
94+
PROMPT=$(cat <<EOF
10095
Analyze the below GitHub issue description, understand the root cause, and make appropriate changes to resolve the issue.
10196
10297
ISSUE URL: ${ISSUE_URL}
10398
ISSUE DESCRIPTION BELOW:
10499
105100
${issue_description}
106101
EOF
102+
)
103+
export PROMPT
107104
108-
echo "WORKSPACE_NAME: ${WORKSPACE_NAME}"
109-
# This command will run the prompt inside the workspace
110-
# and exit once the agent has completed the task.
111-
PROMPT=$(cat "${PROMPT_FILE}") ./scripts/traiage.sh prompt
105+
export TASK_NAME="${PREFIX}-${CONTEXT_KEY}-${RUN_ID}"
106+
echo "Creating task: $TASK_NAME"
107+
./scripts/traiage.sh create
108+
./scripts/traiage.sh wait
109+
echo "TASK_NAME=${TASK_NAME}" >> "${GITHUB_OUTPUT}"
110+
echo "TASK_NAME=${TASK_NAME}" >> "${GITHUB_ENV}"
112111
113112
-name:Create and upload archive
114113
id:create-archive
115114
env:
116115
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
117116
run:|
118-
echo "Creating archive for workspace: $WORKSPACE_NAME"
117+
echo "Creating archive for workspace: $TASK_NAME"
119118
./scripts/traiage.sh archive
120-
echo "archive_url=${BUCKET_PREFIX%%/}/$WORKSPACE_NAME.tar.gz" >> "${GITHUB_OUTPUT}"
119+
echo "archive_url=${BUCKET_PREFIX%%/}/$TASK_NAME.tar.gz" >> "${GITHUB_OUTPUT}"
121120
122121
-name:Generate a summary of the changes and post a comment on GitHub.
123122
id:generate-summary
124123
env:
125124
ARCHIVE_URL:${{ steps.create-archive.outputs.archive_url }}
125+
APP_SLUG:ccw
126126
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
127127
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
128128
GITHUB_TOKEN:${{ github.token }}
129129
GITHUB_REPOSITORY:${{ github.repository }}
130130
ISSUE_URL:${{ inputs.issue_url }}
131-
WORKSPACE_NAME:${{ steps.create-workspace.outputs.workspace_name }}
131+
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}
132132
run:|
133133
SUMMARY_FILE=$(mktemp)
134134
trap 'rm -f "${SUMMARY_FILE}"' EXIT
@@ -137,15 +137,15 @@ jobs:
137137
echo "## TrAIage Results"
138138
echo "- **Issue URL:** ${ISSUE_URL}"
139139
echo "- **Context Key:** ${CONTEXT_KEY}"
140-
echo "- **Workspace:** ${WORKSPACE_NAME}"
140+
echo "- **Workspace:** ${TASK_NAME}"
141141
echo "- **Archive URL:** ${ARCHIVE_URL}"
142142
echo
143143
echo "${AUTO_SUMMARY}"
144144
echo
145145
echo "To fetch the output to your own workspace:"
146146
echo
147147
echo '```bash'
148-
echo "BUCKET_PREFIX=${BUCKET_PREFIX}WORKSPACE_NAME=${WORKSPACE_NAME} ./scripts/traiage.sh resume"
148+
echo "BUCKET_PREFIX=${BUCKET_PREFIX}TASK_NAME=${TASK_NAME} ./scripts/traiage.sh resume"
149149
echo '```'
150150
echo
151151
} >> "${SUMMARY_FILE}"
@@ -157,8 +157,8 @@ jobs:
157157
fi
158158
cat "${SUMMARY_FILE}" >> "${GITHUB_STEP_SUMMARY}"
159159
160-
-name:Cleanupworkspace
161-
if:steps.create-workspace.outputs.workspace_name != '' && steps.create-archive.outputs.archive_url != ''
160+
-name:Cleanuptask
161+
if:steps.create-task.outputs.TASK_NAME != '' && steps.create-archive.outputs.archive_url != ''
162162
run:|
163-
echo "Cleaning upworkspace: $WORKSPACE_NAME"
163+
echo "Cleaning uptask: $TASK_NAME"
164164
./scripts/traiage.sh delete ||true

‎.github/workflows/typos.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[default]
22
extend-ignore-identifiers-re = ["gho_.*"]
3+
extend-ignore-re = ["(#|//)\\s*spellchecker:ignore-next-line\\n.*"]
34

45
[default.extend-identifiers]
56
alog ="alog"

‎Makefile‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ endif
561561

562562
# Note: we don't run zizmor in the lint target because it takes a while. CI
563563
# runs it explicitly.
564-
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/actions/actionlint
564+
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/actions/actionlint lint/check-scopes
565565
.PHONY: lint
566566

567567
lint/site-icons:
@@ -614,6 +614,11 @@ lint/actions/zizmor:
614614
.
615615
.PHONY: lint/actions/zizmor
616616

617+
# Verify api_key_scope enum contains all RBAC <resource>:<action> values.
618+
lint/check-scopes: coderd/database/dump.sql
619+
go run ./scripts/check-scopes
620+
.PHONY: lint/check-scopes
621+
617622
# All files generated by the database should be added here, and this can be used
618623
# as a target for jobs that need to run after the database is generated.
619624
DB_GEN_FILES :=\
@@ -630,17 +635,22 @@ TAILNETTEST_MOCKS := \
630635
tailnet/tailnettest/workspaceupdatesprovidermock.go\
631636
tailnet/tailnettest/subscriptionmock.go
632637

638+
AIBRIDGED_MOCKS :=\
639+
enterprise/x/aibridged/aibridgedmock/clientmock.go\
640+
enterprise/x/aibridged/aibridgedmock/poolmock.go
641+
633642
GEN_FILES :=\
634643
tailnet/proto/tailnet.pb.go\
635644
agent/proto/agent.pb.go\
636645
provisionersdk/proto/provisioner.pb.go\
637646
provisionerd/proto/provisionerd.pb.go\
638647
vpn/vpn.pb.go\
639-
aibridged/proto/aibridged.pb.go\
648+
enterprise/x/aibridged/proto/aibridged.pb.go\
640649
$(DB_GEN_FILES)\
641650
$(SITE_GEN_FILES)\
642651
coderd/rbac/object_gen.go\
643652
codersdk/rbacresources_gen.go\
653+
coderd/rbac/scopes_constants_gen.go\
644654
docs/admin/integrations/prometheus.md\
645655
docs/reference/cli/index.md\
646656
docs/admin/security/audit-logs.md\
@@ -654,7 +664,8 @@ GEN_FILES := \
654664
agent/agentcontainers/acmock/acmock.go\
655665
agent/agentcontainers/dcspec/dcspec_gen.go\
656666
coderd/httpmw/loggermw/loggermock/loggermock.go\
657-
codersdk/workspacesdk/agentconnmock/agentconnmock.go
667+
codersdk/workspacesdk/agentconnmock/agentconnmock.go\
668+
$(AIBRIDGED_MOCKS)
658669

659670
# all gen targets should be added here and to gen/mark-fresh
660671
gen: gen/db gen/golden-files$(GEN_FILES)
@@ -684,12 +695,13 @@ gen/mark-fresh:
684695
provisionersdk/proto/provisioner.pb.go\
685696
provisionerd/proto/provisionerd.pb.go\
686697
vpn/vpn.pb.go\
687-
aibridged/proto/aibridged.pb.go\
698+
enterprise/x/aibridged/proto/aibridged.pb.go\
688699
coderd/database/dump.sql\
689700
$(DB_GEN_FILES)\
690701
site/src/api/typesGenerated.ts\
691702
coderd/rbac/object_gen.go\
692703
codersdk/rbacresources_gen.go\
704+
coderd/rbac/scopes_constants_gen.go\
693705
site/src/api/rbacresourcesGenerated.ts\
694706
site/src/api/countriesGenerated.ts\
695707
docs/admin/integrations/prometheus.md\
@@ -706,6 +718,7 @@ gen/mark-fresh:
706718
agent/agentcontainers/dcspec/dcspec_gen.go\
707719
coderd/httpmw/loggermw/loggermock/loggermock.go\
708720
codersdk/workspacesdk/agentconnmock/agentconnmock.go\
721+
$(AIBRIDGED_MOCKS)\
709722
"
710723

711724
for file in $$files; do
@@ -753,6 +766,10 @@ codersdk/workspacesdk/agentconnmock/agentconnmock.go: codersdk/workspacesdk/agen
753766
go generate ./codersdk/workspacesdk/agentconnmock/
754767
touch"$@"
755768

769+
$(AIBRIDGED_MOCKS): enterprise/x/aibridged/client.go enterprise/x/aibridged/pool.go
770+
go generate ./enterprise/x/aibridged/aibridgedmock/
771+
touch"$@"
772+
756773
agent/agentcontainers/dcspec/dcspec_gen.go:\
757774
node_modules/.installed\
758775
agent/agentcontainers/dcspec/devContainer.base.schema.json\
@@ -803,13 +820,13 @@ vpn/vpn.pb.go: vpn/vpn.proto
803820
--go_opt=paths=source_relative\
804821
./vpn/vpn.proto
805822

806-
aibridged/proto/aibridged.pb.go: aibridged/proto/aibridged.proto
823+
enterprise/x/aibridged/proto/aibridged.pb.go:enterprise/x/aibridged/proto/aibridged.proto
807824
protoc\
808825
--go_out=.\
809826
--go_opt=paths=source_relative\
810827
--go-drpc_out=.\
811828
--go-drpc_opt=paths=source_relative\
812-
./aibridged/proto/aibridged.proto
829+
./enterprise/x/aibridged/proto/aibridged.proto
813830

814831
site/src/api/typesGenerated.ts: site/node_modules/.installed$(wildcard scripts/apitypings/*)$(shell find ./codersdk$(FIND_EXCLUSIONS) -type f -name '*.go')
815832
# -C sets the directory for the go run command
@@ -837,6 +854,15 @@ coderd/rbac/object_gen.go: scripts/typegen/rbacobject.gotmpl scripts/typegen/mai
837854
rmdir -v"$$tempdir"
838855
touch"$@"
839856

857+
coderd/rbac/scopes_constants_gen.go: scripts/typegen/scopenames.gotmpl scripts/typegen/main.go coderd/rbac/policy/policy.go
858+
# Generate typed low-level ScopeName constants from RBACPermissions
859+
# Write to a temp file first to avoid truncating the package during build
860+
# since the generator imports the rbac package.
861+
tempfile=$(shell mktemp /tmp/scopes_constants_gen.XXXXXX)
862+
go run ./scripts/typegen/main.go rbac scopenames>"$$tempfile"
863+
mv -v"$$tempfile" coderd/rbac/scopes_constants_gen.go
864+
touch"$@"
865+
840866
codersdk/rbacresources_gen.go: scripts/typegen/codersdk.gotmpl scripts/typegen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go
841867
# Do no overwrite codersdk/rbacresources_gen.go directly, as it would make the file empty, breaking
842868
# the `codersdk` package and any parallel build targets.

‎cli/exp_task.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func (r *RootCmd) tasksCommand() *serpent.Command {
1717
r.taskCreate(),
1818
r.taskStatus(),
1919
r.taskDelete(),
20+
r.taskSend(),
2021
},
2122
}
2223
returncmd

‎cli/exp_task_send.go‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package cli
2+
3+
import (
4+
"io"
5+
6+
"github.com/google/uuid"
7+
"golang.org/x/xerrors"
8+
9+
"github.com/coder/coder/v2/codersdk"
10+
"github.com/coder/serpent"
11+
)
12+
13+
func (r*RootCmd)taskSend()*serpent.Command {
14+
varstdinbool
15+
16+
cmd:=&serpent.Command{
17+
Use:"send <task> [<input> | --stdin]",
18+
Short:"Send input to a task",
19+
Middleware:serpent.RequireRangeArgs(1,2),
20+
Options: serpent.OptionSet{
21+
{
22+
Name:"stdin",
23+
Flag:"stdin",
24+
Description:"Reads the input from stdin.",
25+
Value:serpent.BoolOf(&stdin),
26+
},
27+
},
28+
Handler:func(inv*serpent.Invocation)error {
29+
client,err:=r.InitClient(inv)
30+
iferr!=nil {
31+
returnerr
32+
}
33+
34+
var (
35+
ctx=inv.Context()
36+
exp=codersdk.NewExperimentalClient(client)
37+
task=inv.Args[0]
38+
39+
taskInputstring
40+
taskID uuid.UUID
41+
)
42+
43+
ifstdin {
44+
bytes,err:=io.ReadAll(inv.Stdin)
45+
iferr!=nil {
46+
returnxerrors.Errorf("reading stdio: %w",err)
47+
}
48+
49+
taskInput=string(bytes)
50+
}else {
51+
iflen(inv.Args)!=2 {
52+
returnxerrors.Errorf("expected an input for the task")
53+
}
54+
55+
taskInput=inv.Args[1]
56+
}
57+
58+
ifid,err:=uuid.Parse(task);err==nil {
59+
taskID=id
60+
}else {
61+
ws,err:=namedWorkspace(ctx,client,task)
62+
iferr!=nil {
63+
returnxerrors.Errorf("resolve task: %w",err)
64+
}
65+
66+
taskID=ws.ID
67+
}
68+
69+
iferr=exp.TaskSend(ctx,codersdk.Me,taskID, codersdk.TaskSendRequest{Input:taskInput});err!=nil {
70+
returnxerrors.Errorf("send input to task: %w",err)
71+
}
72+
73+
returnnil
74+
},
75+
}
76+
77+
returncmd
78+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp