Skip to content

Commit a0414b3

Browse files
authored
0.2.0 (#402)
* feat(oauth): add RedirectURI field to OAuth request structures * feat(oauth): update OAuthSchema validation * feat: add Context field to request and session structures * feat: add CredentialType field to Credentials and InvokeToolRequest structures * fix: handle unhandled default case in basic_type.go * feat: add support for build branches in build-push.yml
1 parent 33c023b commit a0414b3

File tree

9 files changed

+22
-8
lines changed

9 files changed

+22
-8
lines changed

.github/workflows/build-push.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- "main"
77
- "deploy/dev"
8+
- "build/**"
89
pull_request:
910
branches:
1011
- "main"
@@ -28,7 +29,7 @@ jobs:
2829
steps:
2930
- name: Checkout code
3031
uses: actions/checkout@v4
31-
32+
3233
- name: Set matrix
3334
id: set-matrix
3435
run: |

internal/core/dify_invocation/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ func (r *InvokeEncryptRequest) EncryptRequired(settings map[string]any) bool {
230230

231231
type InvokeToolRequest struct {
232232
BaseInvokeDifyRequest
233-
ToolType requests.ToolType `json:"tool_type" validate:"required,tool_type"`
233+
ToolType requests.ToolType `json:"tool_type" validate:"required,tool_type"`
234+
CredentialId string `json:"credential_id" validate:"omitempty"`
235+
CredentialType string `json:"credential_type" validate:"omitempty"`
234236
requests.InvokeToolSchema
235237
}
236238

internal/core/session_manager/session.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ type Session struct {
3535
Declaration *plugin_entities.PluginDeclaration `json:"declaration"`
3636

3737
// information about incoming request
38-
ConversationID *string `json:"conversation_id"`
39-
MessageID *string `json:"message_id"`
40-
AppID *string `json:"app_id"`
41-
EndpointID *string `json:"endpoint_id"`
38+
ConversationID *string `json:"conversation_id"`
39+
MessageID *string `json:"message_id"`
40+
AppID *string `json:"app_id"`
41+
EndpointID *string `json:"endpoint_id"`
42+
Context map[string]any `json:"context"`
4243
}
4344

4445
func sessionKey(id string) string {
@@ -59,6 +60,7 @@ type NewSessionPayload struct {
5960
MessageID *string `json:"message_id"`
6061
AppID *string `json:"app_id"`
6162
EndpointID *string `json:"endpoint_id"`
63+
Context map[string]any `json:"context"`
6264
}
6365

6466
func NewSession(payload NewSessionPayload) *Session {
@@ -76,6 +78,7 @@ func NewSession(payload NewSessionPayload) *Session {
7678
MessageID: payload.MessageID,
7779
AppID: payload.AppID,
7880
EndpointID: payload.EndpointID,
81+
Context: payload.Context,
7982
}
8083

8184
session_lock.Lock()
@@ -172,6 +175,7 @@ func (s *Session) Message(event PLUGIN_IN_STREAM_EVENT, data any) []byte {
172175
"message_id": s.MessageID,
173176
"app_id": s.AppID,
174177
"endpoint_id": s.EndpointID,
178+
"context": s.Context,
175179
"event": event,
176180
"data": data,
177181
})

internal/service/session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func createSession[T any](
4242
MessageID: r.MessageID,
4343
AppID: r.AppID,
4444
EndpointID: r.EndpointID,
45+
Context: r.Context,
4546
},
4647
)
4748

pkg/entities/plugin_entities/basic_type.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func isBasicType(fl validator.FieldLevel) bool {
3535
if fl.Field().IsNil() {
3636
return true
3737
}
38+
default:
39+
return false
3840
}
3941

4042
return false

pkg/entities/plugin_entities/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type InvokePluginRequest[T any] struct {
1818
MessageID *string `json:"message_id"`
1919
AppID *string `json:"app_id"`
2020
EndpointID *string `json:"endpoint_id"`
21+
Context map[string]any `json:"context"`
2122

2223
Data T `json:"data" validate:"required"`
2324
}

pkg/entities/plugin_entities/tool_declaration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func init() {
221221
type ToolProviderDeclaration struct {
222222
Identity ToolProviderIdentity `json:"identity" yaml:"identity" validate:"required"`
223223
CredentialsSchema []ProviderConfig `json:"credentials_schema" yaml:"credentials_schema" validate:"omitempty,dive"`
224-
OAuthSchema *OAuthSchema `json:"oauth_schema" yaml:"oauth_schema" validate:"omitempty,dive"`
224+
OAuthSchema *OAuthSchema `json:"oauth_schema" yaml:"oauth_schema" validate:"omitempty"`
225225
Tools []ToolDeclaration `json:"tools" yaml:"tools" validate:"required,dive"`
226226
ToolFiles []string `json:"-" yaml:"-"`
227227
}

pkg/entities/requests/model.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import (
77
)
88

99
type Credentials struct {
10-
Credentials map[string]any `json:"credentials" validate:"omitempty"`
10+
Credentials map[string]any `json:"credentials" validate:"omitempty"`
11+
CredentialType string `json:"credential_type" validate:"omitempty"`
1112
}
1213

1314
type BaseRequestInvokeModel struct {

pkg/entities/requests/oauth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package requests
22

33
type RequestOAuthGetAuthorizationURL struct {
44
Provider string `json:"provider" validate:"required"`
5+
RedirectURI string `json:"redirect_uri" validate:"required"`
56
SystemCredentials map[string]any `json:"system_credentials" validate:"omitempty"`
67
}
78

89
type RequestOAuthGetCredentials struct {
910
Provider string `json:"provider" validate:"required"`
11+
RedirectURI string `json:"redirect_uri" validate:"required"`
1012
SystemCredentials map[string]any `json:"system_credentials" validate:"omitempty"`
1113
RawHttpRequest string `json:"raw_http_request" validate:"required"` // hex encoded raw http request from the oauth provider
1214
}

0 commit comments

Comments
 (0)