diff --git a/.claude/skills/add-connector/SKILL.md b/.claude/skills/add-connector/SKILL.md index d72c844022..19ea8623e5 100644 --- a/.claude/skills/add-connector/SKILL.md +++ b/.claude/skills/add-connector/SKILL.md @@ -17,10 +17,12 @@ First decide which kind you need. Connecting an existing connector to an agent i Dashboard: **Library › Connectors › New connector**. API: `POST /v1/agents/connectors` (`CustomConnectorRequest`: `id`, `name`, `endpoint`, `schemes`, optional `scopes`, -`client`, `category`, `description`). +`client`, `category`, `description`, `sync_hash`). - The id starts with `custom_`, for example `custom_crm`. Built-ins never use that prefix. - `endpoint` is the MCP server's https URL. +- `sync_hash` is the fingerprint of the file the CLI synced the connector from. The connector + returns it until a create without one, from the dashboard or the API, clears it. - `schemes` is how a connection signs in: `oauth2_code`, `bearer`, `api_key`, or `none`. - A public server that needs no credential takes `schemes: ["none"]`. Create the connection, then connect it with `PUT /v1/agents/connections/{id}/credentials` and the body diff --git a/.claude/skills/sdk/notes/2026-11-23-ai-3663.md b/.claude/skills/sdk/notes/2026-11-23-ai-3663.md new file mode 100644 index 0000000000..ad31e5c998 --- /dev/null +++ b/.claude/skills/sdk/notes/2026-11-23-ai-3663.md @@ -0,0 +1 @@ +Connectors and router configs carry a `sync_hash`, as agent configs do: `createConnector` (`CustomConnectorRequest.sync_hash`) and `createRouterConfig`/`updateRouterConfig` (`RouterConfigRequest.sync_hash`) take the fingerprint of the file a sync sent, and `Connector.sync_hash` and `RouterConfig.sync_hash` return it. Any write without one clears it; a router config replace with the stored hash and the same content writes nothing, and a connector sent again with the same definition and another hash keeps its revision and records the hash. Every generated client is regenerated in this change; no SDK computes or sends the hash yet. Other SDKs need to update: once the CLI's hash for a connector or router file is settled (AI-3664), a server SDK that syncs those files sends it the same way. diff --git a/acceleration/api/openapi.yaml b/acceleration/api/openapi.yaml index 02e352415b..16ff179018 100644 --- a/acceleration/api/openapi.yaml +++ b/acceleration/api/openapi.yaml @@ -3552,6 +3552,10 @@ components: setup: $ref: '#/components/schemas/ConnectorSetup' description: What a person does at the provider before the first consent, such as registering an OAuth client. Absent when the manifest says nothing. + sync_hash: + description: The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync. + readOnly: true + type: string required: - id - revision @@ -4692,6 +4696,12 @@ components: nullable: true type: array uniqueItems: true + sync_hash: + description: 'The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one.' + maxLength: 128 + pattern: ^[!-~]*$ + patternDescription: printable ASCII without a space + type: string required: - id - name @@ -8718,6 +8728,10 @@ components: $ref: '#/components/schemas/StsOptions' stt: $ref: '#/components/schemas/SttOptions' + sync_hash: + description: The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync. + readOnly: true + type: string tts: $ref: '#/components/schemas/TtsOptions' updated_at: @@ -8742,6 +8756,12 @@ components: $ref: '#/components/schemas/StsOptions' stt: $ref: '#/components/schemas/SttOptions' + sync_hash: + description: The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing. + maxLength: 128 + pattern: ^[!-~]*$ + patternDescription: printable ASCII without a space + type: string tts: $ref: '#/components/schemas/TtsOptions' required: diff --git a/acceleration/internal/api/connectors.go b/acceleration/internal/api/connectors.go index 9375c644eb..6aa8d024fb 100644 --- a/acceleration/internal/api/connectors.go +++ b/acceleration/internal/api/connectors.go @@ -51,6 +51,7 @@ type Connector struct { RedirectURI string `json:"redirect_uri,omitempty" readOnly:"true" format:"uri" doc:"The redirect URI an OAuth client registered for this connector has to list: where every consent of this deployment sends the browser back to, ROUTER_PUBLIC_URL followed by /v1/agents/connectors/oauth/callback. Only on a connector that connects with oauth2_code, and absent when ROUTER_PUBLIC_URL is not set, since no consent can start then."` Channel bool `json:"channel" readOnly:"true" doc:"The connector is an inbound channel: its manifest reads messages a provider delivers to the router, which agents answer. A block that reads only signals, such as Slack with a user token, is not one. A dashboard warns on it before a delete that would end those replies."` Sandbox *ConnectorSandbox `json:"sandbox,omitempty" readOnly:"true" doc:"How code in an agent's sandbox calls the provider's API with a connection's credential without holding it. Absent when the connector offers no such access."` + SyncHash string `json:"sync_hash,omitempty" readOnly:"true" doc:"The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync."` CreatedAt time.Time `json:"created_at" readOnly:"true" doc:"When this revision was stored."` } @@ -162,7 +163,10 @@ type ConnectorPage struct { // scopes is well over the longest list shipped, Slack's 29 (providers/slack.yaml), and is // not measured either. A scope is RFC 6749 section 3.3's scope-token, %x21 / %x23-5B / // %x5D-7E, so it can hold neither a space nor a quote. The schemes have no count: each must -// be a registered one and none may repeat, which bounds them. +// be a registered one and none may repeat, which bounds them. A sync hash is up to 128 +// characters, a SHA-512 hex digest, well over the 32 of the MD5 hex digest the CLI computes +// for an agent (Agentrc.Hash in GetStream/cli internal/agentrc/agentrc.go), and printable +// ASCII without a space, so it holds no NUL, which a Postgres text column refuses. type CustomConnectorRequest struct { ID string `json:"id" pattern:"^custom_[a-z][a-z0-9_]{0,56}$" patternDescription:"custom_ then a lowercase letter, then up to 56 lowercase letters, digits or underscores" doc:"Starts with custom_, which no built-in does, so a custom definition never stands in for one. Creating an id that exists stores the next revision, unless the newest already says the same."` Name string `json:"name" minLength:"1" maxLength:"120"` @@ -172,6 +176,7 @@ type CustomConnectorRequest struct { Schemes []string `json:"schemes" minItems:"1" doc:"How a connection may authenticate. Each must be a scheme this deployment has, except oauth2_client_credentials, which a custom connector cannot use: it needs a token endpoint a custom connector cannot set."` Scopes []string `json:"scopes,omitempty" maxItems:"100" uniqueItems:"true" pattern:"^[!#-\\[\\]-~]+$" patternDescription:"an RFC 6749 scope token" doc:"The scopes a consent asks for, each an RFC 6749 scope token."` Client *ConnectorClient `json:"client,omitempty"` + SyncHash string `json:"sync_hash,omitempty" maxLength:"128" pattern:"^[!-~]*$" patternDescription:"printable ASCII without a space" doc:"The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one."` } func (*CustomConnectorRequest) TransformSchema(_ huma.Registry, schema *huma.Schema) *huma.Schema { @@ -348,7 +353,7 @@ func (s *Server) createConnector(ctx context.Context, request *createConnectorRe return nil, invalidRequest(store.StreamSource + " is the source of the router's own events, which no connector may be named") } // Every refusal a caller can cause is above, so what the store refuses here is a bug. - definition, err := s.store.ConnectorDefinitions.Revise(ctx, customerID, manifest) + definition, err := s.store.ConnectorDefinitions.ReviseSynced(ctx, customerID, manifest, request.Body.SyncHash) if err != nil { return nil, err } @@ -495,6 +500,7 @@ func connectorOf(definition store.ConnectorDefinition, publicURL string) Connect AuthMethod: ConnectorClientAuthMethod(manifest.Client.AuthMethod), Alg: manifest.Client.Alg, }, + SyncHash: definition.SyncHash, CreatedAt: definition.CreatedAt, } } diff --git a/acceleration/internal/api/connectors_test.go b/acceleration/internal/api/connectors_test.go index 113784d546..06abcd77e4 100644 --- a/acceleration/internal/api/connectors_test.go +++ b/acceleration/internal/api/connectors_test.go @@ -415,6 +415,115 @@ func (s *ConnectorsSuite) TestSendingTheSameConnectorAgainChangesNothingAndAChan s.Equal("Renamed", s.get(id).Name) } +// AI-3663: the hash a sync sends is on the revision it stores, or on the newest when that +// already says the same, and on every read of the connector. +func (s *ConnectorsSuite) TestASyncedConnectorShowsItsHashOnEveryRead() { + id := s.customID() + created := s.create(s.synced(s.customConnector(id), "hash-one")) + s.Equal("hash-one", created.SyncHash) + + s.Equal("hash-one", s.get(id).SyncHash) + listed := s.list(id).Items + s.Require().Len(listed, 1) + s.Equal("hash-one", listed[0].SyncHash) +} + +func (s *ConnectorsSuite) TestSyncingTheSameFileAgainAddsNoRevision() { + id := s.customID() + created := s.create(s.synced(s.customConnector(id), "hash-one")) + + again := s.create(s.synced(s.customConnector(id), "hash-one")) + + s.Equal(created, again, "the revision already stored, as it was") +} + +func (s *ConnectorsSuite) TestTheSameDefinitionUnderAnotherHashRecordsTheHashOnTheSameRevision() { + id := s.customID() + s.create(s.synced(s.customConnector(id), "hash-one")) + + rehashed := s.create(s.synced(s.customConnector(id), "hash-two")) + + s.Equal(1, rehashed.Revision) + s.Equal("hash-two", s.get(id).SyncHash, "so the next sync of the same file finds it unchanged") +} + +// A client that copies the read connector into a create, edits it and keeps the hash the read +// carried writes a revision no sync wrote. +func (s *ConnectorsSuite) TestAnEditCarryingTheReadHashClearsIt() { + id := s.customID() + s.create(s.synced(s.customConnector(id), "hash-one")) + edited := s.synced(s.customConnector(id), s.get(id).SyncHash) + edited["name"] = "Renamed" + + revised := s.create(edited) + + s.Equal(2, revised.Revision) + s.Empty(revised.SyncHash) + s.Empty(s.get(id).SyncHash) +} + +// A dashboard or API create sends no hash, so the next sync of the file sees a hash it did not +// write, whether the definition changed or not. +func (s *ConnectorsSuite) TestACreateThatIsNoSyncClearsTheHash() { + id := s.customID() + s.create(s.synced(s.customConnector(id), "hash-one")) + + same := s.create(s.customConnector(id)) + s.Equal(1, same.Revision) + s.Empty(same.SyncHash) + s.Empty(s.get(id).SyncHash) + + s.create(s.synced(s.customConnector(id), "hash-one")) + changed := s.customConnector(id) + changed["name"] = "Renamed" + edited := s.create(changed) + s.Equal(2, edited.Revision) + s.Empty(s.get(id).SyncHash) + + resynced := s.create(s.synced(s.customConnector(id), "hash-one")) + s.Equal(3, resynced.Revision, "the file differs from the edit, so it is the next revision") + s.Equal("hash-one", s.get(id).SyncHash) +} + +// The base's behaviour, checked on 89e9e0c5c: no answer names a sync hash, on a built-in or +// on a connector created without one. +func (s *ConnectorsSuite) TestAConnectorNoSyncWroteShowsNoHash() { + id := s.customID() + var created map[string]any + s.Require().Equal(http.StatusOK, + s.serverClient.do(http.MethodPost, "/v1/agents/connectors", s.customConnector(id), &created)) + s.NotContains(created, "sync_hash") + for _, read := range []string{id, "github"} { + var answered map[string]any + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodGet, "/v1/agents/connectors/"+read, nil, &answered)) + s.NotContains(answered, "sync_hash", read) + } +} + +func (s *ConnectorsSuite) TestASyncHashThatIsNotPrintableASCIIOrTooLongIsRefused() { + longest := strings.Repeat("f", 128) + s.Equal(longest, s.create(s.synced(s.customConnector(s.customID()), longest)).SyncHash) + for name, hash := range map[string]string{ + "a space": "hash one", + "a NUL": "hash\x00", + "a non-ASCII": "hashé", + "129 of them": strings.Repeat("f", 129), + "a line break": "hash\n", + } { + s.Run(name, func() { + status, _ := s.serverClient.failure(http.MethodPost, "/v1/agents/connectors", + s.synced(s.customConnector(s.customID()), hash)) + s.Equal(http.StatusBadRequest, status) + }) + } +} + +// synced is body as a sync sends it, with hash. +func (s *ConnectorsSuite) synced(body map[string]any, hash string) map[string]any { + body["sync_hash"] = hash + return body +} + func (s *ConnectorsSuite) TestAnotherAppsCustomConnectorIsNeitherListedNorRead() { id := s.customID() s.create(s.customConnector(id)) @@ -444,6 +553,26 @@ func (s *ConnectorsSuite) TestAnotherAppMayUseTheSameCustomIdWithoutTouchingThis s.Equal(1, s.get(id).Revision) } +// Another app syncing the same custom id and definition, under its own hash and then under +// none, records each on its own revision only. +func (s *ConnectorsSuite) TestAnotherAppsSyncOfTheSameCustomIdLeavesThisOnesHash() { + id := s.customID() + s.create(s.synced(s.customConnector(id), "hash-ours")) + stranger := s.data.backendOfAnotherApp() + + var theirs, cleared Connector + s.Require().Equal(http.StatusOK, stranger.do(http.MethodPost, "/v1/agents/connectors", + s.synced(s.customConnector(id), "hash-theirs"), &theirs)) + s.Require().Equal(http.StatusOK, stranger.do(http.MethodPost, "/v1/agents/connectors", + s.customConnector(id), &cleared)) + + s.Equal("hash-theirs", theirs.SyncHash) + s.Empty(cleared.SyncHash) + ours := s.get(id) + s.Equal("hash-ours", ours.SyncHash) + s.Equal(1, ours.Revision) +} + func (s *ConnectorsSuite) TestTheListIsTheBuiltInsThenTheAppsOwnEachById() { second, first := "custom_b"+s.suffix(), "custom_a"+s.suffix() s.create(s.customConnector(second)) diff --git a/acceleration/internal/api/routerconfigs.go b/acceleration/internal/api/routerconfigs.go index caf896ad1f..5bd9758777 100644 --- a/acceleration/internal/api/routerconfigs.go +++ b/acceleration/internal/api/routerconfigs.go @@ -121,6 +121,18 @@ func (s *Server) updateRouterConfig(ctx context.Context, request *updateRouterCo } config := storedRouterConfig(*request.Body, customerID) + // A sync of the file last synced onto the config, which nothing has written since: every + // other write clears the hash. The content is compared too, so a body that differs under + // the same hash is written rather than dropped. + if config.SyncHash != "" && config.SyncHash == existing.SyncHash && + len(auditDiff(routerConfigOf(existing), routerConfigOf(config))) == 0 { + return &updateRouterConfigResponse{Body: routerConfigOf(existing)}, nil + } + // That body is no sync of the file the hash names, such as a read sent back edited, so + // the hash is not kept on content it does not describe. + if config.SyncHash == existing.SyncHash { + config.SyncHash = "" + } config.ID = existing.ID config.CreatedAt = existing.CreatedAt if err := s.store.RouterConfigs.Update(ctx, &config); err != nil { @@ -342,6 +354,7 @@ func storedRouterConfig(request RouterConfigRequest, customerID string) store.Ro LLM: llmOptionsOf(request.Llm), STS: stsOptionsOf(request.Sts), Search: searchOptionsOf(request.Search), + SyncHash: request.SyncHash, } config.STT.Keyterms = stt.CleanKeyterms(config.STT.Keyterms) return config @@ -357,6 +370,7 @@ func routerConfigOf(config store.RouterConfig) RouterConfig { Llm: llmOptionsFor(config.LLM), Sts: stsOptionsFor(config.STS), Search: searchOptionsFor(config.Search), + SyncHash: config.SyncHash, CreatedAt: config.CreatedAt, UpdatedAt: config.UpdatedAt, } @@ -549,4 +563,6 @@ type RouterConfigRequest struct { Sts *StsOptions `json:"sts,omitempty"` Stt *SttOptions `json:"stt,omitempty"` Tts *TtsOptions `json:"tts,omitempty"` + // The limits on a sync hash are CustomConnectorRequest's. + SyncHash string `json:"sync_hash,omitempty" maxLength:"128" pattern:"^[!-~]*$" patternDescription:"printable ASCII without a space" doc:"The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing."` } diff --git a/acceleration/internal/api/routerconfigs_test.go b/acceleration/internal/api/routerconfigs_test.go index 442f27344b..059f9e4100 100644 --- a/acceleration/internal/api/routerconfigs_test.go +++ b/acceleration/internal/api/routerconfigs_test.go @@ -4,6 +4,7 @@ package api import ( "net/http" + "strings" "testing" ) @@ -167,6 +168,147 @@ func (s *RouterConfigsSuite) TestOnlyTheAppsOwnBackendMayStoreARouterConfig() { }) } +// AI-3663: the hash of the file a sync wrote is on every read of the config. +func (s *RouterConfigsSuite) TestASyncedRouterConfigShowsItsHashOnEveryRead() { + created := s.createConfig(s.syncedClinic("hash-one")) + s.Equal("hash-one", created.SyncHash) + + s.Equal("hash-one", s.readConfig(created.Id).SyncHash) + var listed []RouterConfig + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodGet, "/v1/router/configs", nil, &listed)) + s.Require().Len(listed, 1) + s.Equal("hash-one", listed[0].SyncHash) +} + +func (s *RouterConfigsSuite) TestSyncingTheSameFileAgainWritesNothing() { + created := s.createConfig(s.syncedClinic("hash-one")) + // The create answers with the Go clock (ns on Linux); Postgres keeps µs. Compare with the stored row. + stored := s.readConfig(created.Id) + + replaced := s.replaceConfig(created.Id, s.syncedClinic("hash-one")) + + s.Equal("hash-one", replaced.SyncHash) + s.True(stored.UpdatedAt.Equal(replaced.UpdatedAt), "answered with the config as it was") + s.True(stored.UpdatedAt.Equal(s.readConfig(created.Id).UpdatedAt), "and nothing was written") +} + +func (s *RouterConfigsSuite) TestTheSameHashWithOtherContentIsStillWritten() { + created := s.createConfig(s.syncedClinic("hash-one")) + stored := s.readConfig(created.Id) + changed := s.syncedClinic("hash-one") + changed["stt"] = map[string]any{"target": "llm-flow"} + + s.replaceConfig(created.Id, changed) + + read := s.readConfig(created.Id) + s.Equal("llm-flow", value(read.Stt.Target), "a body the hash does not describe is not dropped") + s.True(read.UpdatedAt.After(stored.UpdatedAt)) + s.Empty(read.SyncHash, "nor kept under a hash that names another file") +} + +// A client that reads the config, edits it and sends the whole read back sends the hash too. +func (s *RouterConfigsSuite) TestAReadSentBackEditedClearsTheHash() { + created := s.createConfig(s.syncedClinic("hash-one")) + var read map[string]any + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodGet, "/v1/router/configs/"+created.Id, nil, &read)) + s.Require().Equal("hash-one", read["sync_hash"]) + read["stt"] = map[string]any{"target": "llm-flow"} + + s.replaceConfig(created.Id, read) + + after := s.readConfig(created.Id) + s.Equal("llm-flow", value(after.Stt.Target)) + s.Empty(after.SyncHash) +} + +func (s *RouterConfigsSuite) TestTheSameFileUnderAnotherHashRecordsTheNewHash() { + created := s.createConfig(s.syncedClinic("hash-one")) + + s.replaceConfig(created.Id, s.syncedClinic("hash-two")) + + s.Equal("hash-two", s.readConfig(created.Id).SyncHash) +} + +// A dashboard or API replace sends no hash, so the next sync of the file sees a hash it did +// not write, whether the edit changed the content or not. +func (s *RouterConfigsSuite) TestAReplaceThatIsNoSyncClearsTheHash() { + for name, edit := range map[string]map[string]any{ + "same content": {"name": "clinic", "stt": map[string]any{"target": "en-low-latency"}}, + "other content": {"name": "clinic", "stt": map[string]any{"target": "llm-flow"}}, + } { + s.Run(name, func() { + s.useApp(s.data.createApp()) + created := s.createConfig(s.syncedClinic("hash-one")) + + s.Empty(s.replaceConfig(created.Id, edit).SyncHash) + + s.Empty(s.readConfig(created.Id).SyncHash) + }) + } +} + +// The base's behaviour, checked on 89e9e0c5c: a replace without a hash is written each time, +// even with the same body, and no answer names a sync hash. +func (s *RouterConfigsSuite) TestAReplaceWithoutAHashIsWrittenEveryTime() { + body := map[string]any{"name": "clinic", "stt": map[string]any{"target": "en-low-latency"}} + var created map[string]any + s.Require().Equal(http.StatusCreated, s.serverClient.do(http.MethodPost, "/v1/router/configs", body, &created)) + s.NotContains(created, "sync_hash") + id := created["id"].(string) + + first := s.replaceConfig(id, body) + second := s.replaceConfig(id, body) + + s.True(second.UpdatedAt.After(first.UpdatedAt), "the second replace was written too") + var read map[string]any + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodGet, "/v1/router/configs/"+id, nil, &read)) + s.NotContains(read, "sync_hash") +} + +func (s *RouterConfigsSuite) TestASyncHashThatIsNotPrintableASCIIOrTooLongIsRefused() { + s.createConfig(s.syncedClinic(strings.Repeat("f", 128))) + for name, hash := range map[string]string{ + "a space": "hash one", + "a NUL": "hash\x00", + "a non-ASCII": "hashé", + "129 of them": strings.Repeat("f", 129), + "a line break": "hash\n", + } { + s.Run(name, func() { + s.useApp(s.data.createApp()) + stored := s.createConfig(s.syncedClinic("")) + + created := s.syncedClinic(hash) + created["name"] = "other" + status, _ := s.serverClient.failure(http.MethodPost, "/v1/router/configs", created) + s.Equal(http.StatusBadRequest, status, "a create") + status, _ = s.serverClient.failure(http.MethodPut, "/v1/router/configs/"+stored.Id, s.syncedClinic(hash)) + s.Equal(http.StatusBadRequest, status, "a replace") + }) + } +} + +// syncedClinic is a config as a sync sends it, with hash. +func (s *RouterConfigsSuite) syncedClinic(hash string) map[string]any { + body := map[string]any{"name": "clinic", "stt": map[string]any{"target": "en-low-latency"}} + if hash != "" { + body["sync_hash"] = hash + } + return body +} + +func (s *RouterConfigsSuite) replaceConfig(id string, body map[string]any) RouterConfig { + var replaced RouterConfig + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodPut, "/v1/router/configs/"+id, body, &replaced)) + return replaced +} + +func (s *RouterConfigsSuite) readConfig(id string) RouterConfig { + var read RouterConfig + s.Require().Equal(http.StatusOK, s.serverClient.do(http.MethodGet, "/v1/router/configs/"+id, nil, &read)) + return read +} + // createConfig stores a router config the router must accept. func (s *RouterConfigsSuite) createConfig(body map[string]any) RouterConfig { var created RouterConfig diff --git a/acceleration/internal/api/schemas.go b/acceleration/internal/api/schemas.go index c4c02461cd..7414c2932b 100644 --- a/acceleration/internal/api/schemas.go +++ b/acceleration/internal/api/schemas.go @@ -784,6 +784,7 @@ type RouterConfig struct { Sts *StsOptions `json:"sts,omitempty"` Stt *SttOptions `json:"stt,omitempty"` Tts *TtsOptions `json:"tts,omitempty"` + SyncHash string `json:"sync_hash,omitempty" readOnly:"true" doc:"The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync."` UpdatedAt time.Time `json:"updated_at"` } diff --git a/acceleration/internal/store/connector_definition.go b/acceleration/internal/store/connector_definition.go index 772c7f11f9..0c11987a0b 100644 --- a/acceleration/internal/store/connector_definition.go +++ b/acceleration/internal/store/connector_definition.go @@ -63,7 +63,11 @@ type ConnectorDefinition struct { Category string `bun:"category,notnull"` Description string `bun:"description,notnull"` Manifest core.Manifest `bun:"manifest,type:jsonb,notnull"` - CreatedAt time.Time `bun:"created_at,notnull"` + // SyncHash is a fingerprint of the file the CLI last synced onto this revision + // (20270201001200_connector_router_sync_hash.sql). Empty for a built-in, and for a revision + // that was never synced or was written since by anything that is not a sync. + SyncHash string `bun:"sync_hash,notnull"` + CreatedAt time.Time `bun:"created_at,notnull"` } // Validate refuses a revision the table's checks refuse: a custom id is a customer's and only a @@ -118,8 +122,15 @@ func (r *ConnectorDefinitions) Seed(ctx context.Context, fsys fs.FS) error { // Revise stores a customer's own definition as the next revision of its // id, or returns the latest revision when that already says the same. The manifest's own -// revision is replaced: the store numbers revisions. +// revision is replaced: the store numbers revisions. It is no sync, so the revision it returns +// carries no sync hash. func (r *ConnectorDefinitions) Revise(ctx context.Context, customerID string, manifest core.Manifest) (ConnectorDefinition, error) { + return r.ReviseSynced(ctx, customerID, manifest, "") +} + +// ReviseSynced is Revise for a write that carries the fingerprint of the file it came from, +// which the revision it returns then carries: empty for a write that is not a sync. +func (r *ConnectorDefinitions) ReviseSynced(ctx context.Context, customerID string, manifest core.Manifest, syncHash string) (ConnectorDefinition, error) { if customerID == BuiltinCustomer { return ConnectorDefinition{}, stack.Wrap(errors.New("store: customer id is required")) } @@ -127,7 +138,7 @@ func (r *ConnectorDefinitions) Revise(ctx context.Context, customerID string, ma if err := probe.Validate(); err != nil { return ConnectorDefinition{}, stack.Wrap(err) } - return r.saveRevision(ctx, customerID, manifest) + return r.saveRevision(ctx, customerID, manifest, syncHash) } // Get returns one revision of a definition the customer can see: a built-in @@ -267,14 +278,15 @@ func (r *ConnectorDefinitions) Select(ctx context.Context, customerID string, fi } // saveRevision stores a custom manifest as the next revision of its id under the customer, -// unless the latest revision already says the same, in which case that one is returned. A -// custom definition has one writer, the customer through the API, so the store numbers it. +// unless the latest revision already says the same, in which case that one is returned with +// syncHash recorded on it. A custom definition has one writer, the customer through the API, +// so the store numbers it. // // It runs under a transaction-scoped advisory lock on the customer and id, so two routers // starting at once, or two requests creating the same custom id, take turns: the second // finds the first's revision and either matches it or follows it. The primary key would // refuse a duplicate revision anyway; the lock is what turns that into a wait, not an error. -func (r *ConnectorDefinitions) saveRevision(ctx context.Context, customerID string, manifest core.Manifest) (ConnectorDefinition, error) { +func (r *ConnectorDefinitions) saveRevision(ctx context.Context, customerID string, manifest core.Manifest, syncHash string) (ConnectorDefinition, error) { var saved ConnectorDefinition err := r.store.global.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { if err := lockUntilCommit(ctx, tx, customerID+"/"+manifest.ID, definitionLockSeed); err != nil { @@ -294,9 +306,22 @@ func (r *ConnectorDefinitions) saveRevision(ctx context.Context, customerID stri } if same { saved = latest - return nil + if latest.SyncHash == syncHash { + return nil + } + // The same manifest, from a file of another fingerprint or from a write that is no + // sync: no new revision, but the hash is this write's, so the CLI's next sync of + // that file finds it unchanged, and one after an edit elsewhere does not. + saved.SyncHash = syncHash + _, err := tx.NewUpdate().Model(&saved).Column("sync_hash").WherePK().Exec(ctx) + return err } manifest.Revision = latest.Revision + 1 + // Another manifest under the latest's hash is no sync of the file that hash names, + // such as a read sent back edited, so the new revision carries none. + if syncHash == latest.SyncHash { + syncHash = "" + } } // Validated as it is stored, with the revision it is stored under. @@ -311,6 +336,7 @@ func (r *ConnectorDefinitions) saveRevision(ctx context.Context, customerID stri Category: manifest.Category, Description: manifest.Description, Manifest: manifest, + SyncHash: syncHash, CreatedAt: time.Now().UTC(), } if err := saved.Validate(); err != nil { diff --git a/acceleration/internal/store/connector_definition_test.go b/acceleration/internal/store/connector_definition_test.go index 58ab6375d9..c14d75088a 100644 --- a/acceleration/internal/store/connector_definition_test.go +++ b/acceleration/internal/store/connector_definition_test.go @@ -800,6 +800,66 @@ func (s *StoreSuite) TestCreatingACustomDefinitionAgainIsTheNextRevisionOnlyWhen s.Equal(2, changed.Revision) } +// AI-3663: a sync's hash is recorded on the revision it stores, or on the latest when that +// already says the same, and a write that is no sync leaves the latest with none. +func (s *StoreSuite) TestASyncedDefinitionCarriesItsHashUntilAWriteThatIsNoSync() { + custom := parsed(s.T(), strings.Replace(acmeManifest, "id: acme", "id: custom_crm", 1)) + changed := parsed(s.T(), strings.Replace(acmeChanged, "id: acme", "id: custom_crm", 1)) + + synced, err := s.store.ConnectorDefinitions.ReviseSynced(s.ctx, "acme", custom, "hash-one") + s.Require().NoError(err) + s.Equal(1, synced.Revision) + s.Equal("hash-one", synced.SyncHash) + s.Equal("hash-one", s.latestCustom("custom_crm").SyncHash, "the hash is stored, not only answered") + + before := s.definitionVersion("custom_crm", 1) + again, err := s.store.ConnectorDefinitions.ReviseSynced(s.ctx, "acme", custom, "hash-one") + s.Require().NoError(err) + s.Equal(1, again.Revision) + s.Equal("hash-one", again.SyncHash) + s.Equal(before, s.definitionVersion("custom_crm", 1), "the same file synced again writes nothing") + + rehashed, err := s.store.ConnectorDefinitions.ReviseSynced(s.ctx, "acme", custom, "hash-two") + s.Require().NoError(err) + s.Equal(1, rehashed.Revision, "the same manifest under another hash is no new revision") + s.Equal("hash-two", s.latestCustom("custom_crm").SyncHash) + + edited, err := s.store.ConnectorDefinitions.Revise(s.ctx, "acme", custom) + s.Require().NoError(err) + s.Equal(1, edited.Revision) + s.Empty(edited.SyncHash) + s.Empty(s.latestCustom("custom_crm").SyncHash, "a write that is no sync clears the hash") + + next, err := s.store.ConnectorDefinitions.ReviseSynced(s.ctx, "acme", changed, "hash-three") + s.Require().NoError(err) + s.Equal(2, next.Revision) + s.Equal("hash-three", s.latestCustom("custom_crm").SyncHash, "a new revision carries the sync's hash") + + unsynced, err := s.store.ConnectorDefinitions.Revise(s.ctx, "acme", custom) + s.Require().NoError(err) + s.Equal(3, unsynced.Revision) + s.Empty(s.latestCustom("custom_crm").SyncHash, "a new revision no sync wrote carries none") + first, err := s.store.ConnectorDefinitions.Get(s.ctx, "acme", "custom_crm", 1) + s.Require().NoError(err) + s.Empty(first.SyncHash, "an older revision keeps what it had") +} + +// latestCustom is acme's latest revision of its own definition id, read from the table. +func (s *StoreSuite) latestCustom(id string) ConnectorDefinition { + definition, err := s.store.ConnectorDefinitions.Latest(s.ctx, "acme", id) + s.Require().NoError(err) + return definition +} + +// definitionVersion is the xmin of one of acme's revisions, which changes with every write to it. +func (s *StoreSuite) definitionVersion(id string, revision int) string { + var xmin string + s.Require().NoError(s.store.global.QueryRowContext(s.ctx, + "SELECT xmin::text FROM connector_definitions WHERE customer_id = ? AND id = ? AND revision = ?", + "acme", id, revision).Scan(&xmin)) + return xmin +} + func (s *StoreSuite) TestACustomDefinitionIsOnlyItsOwnCustomers() { s.Require().NoError(s.store.ConnectorDefinitions.Seed(s.ctx, providers.FS)) _, err := s.store.ConnectorDefinitions.Revise(s.ctx, "acme", diff --git a/acceleration/internal/store/datamove.go b/acceleration/internal/store/datamove.go index 0c5790a38c..dff7498bb7 100644 --- a/acceleration/internal/store/datamove.go +++ b/acceleration/internal/store/datamove.go @@ -857,6 +857,10 @@ func (s *Store) importRow(ctx context.Context, db bun.IDB, customerID, table str columns := spec.written(shape) quoted := strings.Join(columns, ", ") picked := slices.Clone(columns) + if i := slices.Index(columns, "sync_hash"); i >= 0 { + // A row from a release before sync hashes carries none, and no sync wrote it here. + picked[i] = "COALESCE(r.sync_hash, '')" + } if i := slices.Index(columns, "usage_id"); spec.name == "requests" && i >= 0 { // The usage id is this deployment's, made from the one the row had where it was first // recorded, or from the source's id for a row from before usage ids. A usage id names a diff --git a/acceleration/internal/store/datamove_test.go b/acceleration/internal/store/datamove_test.go index 51334204ea..8f92bc34f6 100644 --- a/acceleration/internal/store/datamove_test.go +++ b/acceleration/internal/store/datamove_test.go @@ -2100,6 +2100,25 @@ func (s *DataMoveSuite) TestAReplayedRouterConfigChangeIsServedRightAfterIt() { s.Equal("slow", config.Name) } +// TestARouterConfigFromAReleaseBeforeSyncHashesImportsWithNone: an export from before +// sync_hash has no such key, and its row written over one synced here leaves no hash a sync +// did not write. +func (s *DataMoveSuite) TestARouterConfigFromAReleaseBeforeSyncHashesImportsWithNone() { + id := newID() + _, err := s.destination.GlobalDB().ExecContext(s.ctx, + "INSERT INTO router_configs (id, customer_id, name, sync_hash) VALUES (?, 'moved', ?, 'hash-one')", id, "synced-"+id[:8]) + s.Require().NoError(err) + row := `{"id": "` + id + `", "customer_id": "moved", "name": "old-` + id[:8] + `", "stt": {}, "tts": {}, "llm": {}, "sts": {}, "search": {}, + "created_at": "2026-11-01T00:00:00Z", "updated_at": "2026-11-01T00:00:00Z"}` + + s.Require().NoError(s.destination.ImportRow(s.ctx, "moved", "router_configs", json.RawMessage(row))) + + config, err := s.destination.RouterConfigs.Get(s.ctx, "moved", id) + s.Require().NoError(err) + s.Equal("old-"+id[:8], config.Name) + s.Empty(config.SyncHash) +} + func (s *DataMoveSuite) TestASkillMovedByAReplayLeavesItsOldConfig() { destination := s.cachedDestination() app := "moved-" + newID() @@ -2450,6 +2469,18 @@ func (s *DataMoveSuite) TestAChangeCarryingADefinitionTheAPIWouldRefuseIsRefused s.Zero(s.definitionsNamed(id)) } +// A change recorded by a release before sync hashes carries no sync_hash key. +func (s *DataMoveSuite) TestADefinitionChangeFromAReleaseBeforeSyncHashesApplies() { + id := "custom_" + newID() + manifest := strings.Replace(customAcme, "custom_acme", id, 1) + + err := s.destination.ApplyChanges(s.ctx, "moved", []DataChange{{Table: "connector_definitions", Op: ChangeInsert, + Payload: json.RawMessage(`{"id": "` + id + `", "revision": 1, "name": "Acme", "category": "", "description": "", "created_at": "2026-11-01T00:00:00Z", "manifest": ` + manifest + `}`)}}) + + s.Require().NoError(err) + s.Equal(1, s.definitionsNamed(id)) +} + // customAcme is a manifest the API stores for a custom connector custom_acme: an MCP server // taking a bearer token. const customAcme = `{"id": "custom_acme", "revision": 1, "name": "Acme", "endpoints": {"mcp": "https://mcp.acme.example/mcp"}, diff --git a/acceleration/internal/store/router_config.go b/acceleration/internal/store/router_config.go index e72d053683..1876c58106 100644 --- a/acceleration/internal/store/router_config.go +++ b/acceleration/internal/store/router_config.go @@ -38,6 +38,11 @@ type RouterConfig struct { CreatedAt time.Time `bun:"created_at,notnull"` UpdatedAt time.Time `bun:"updated_at,notnull"` DeletedAt *time.Time `bun:"deleted_at"` + // SyncHash is a fingerprint of the file the CLI last synced onto this config + // (20270201001200_connector_router_sync_hash.sql), as AgentConfig.SyncHash is for a + // directory. Empty if it was never synced, or was written since by anything that is not a + // sync. + SyncHash string `bun:"sync_hash,notnull"` } // Validate refuses a config the table would refuse. @@ -107,7 +112,7 @@ func (r *RouterConfigs) Update(ctx context.Context, config *RouterConfig) error return tx.NewUpdate().Model(config). With("was", was). TableExpr("was"). - Column("name", "stt", "tts", "llm", "sts", "search", "updated_at"). + Column("name", "stt", "tts", "llm", "sts", "search", "sync_hash", "updated_at"). Where("rc.id = ?", config.ID). Where("rc.customer_id = ?", config.CustomerID). Returning("was.name"). diff --git a/acceleration/migrations/global/20270201001200_connector_router_sync_hash.sql b/acceleration/migrations/global/20270201001200_connector_router_sync_hash.sql new file mode 100644 index 0000000000..5472b1fa65 --- /dev/null +++ b/acceleration/migrations/global/20270201001200_connector_router_sync_hash.sql @@ -0,0 +1,12 @@ +-- +goose Up +SET LOCAL lock_timeout = '5s'; + +-- A fingerprint of the file the CLI last synced onto the row, as agent_configs.sync_hash is for +-- an agent's directory: empty when the row was never synced, or was written since by anything +-- that is not a sync, so the CLI tells an unchanged file from an edit made elsewhere. +ALTER TABLE connector_definitions ADD COLUMN IF NOT EXISTS sync_hash TEXT NOT NULL DEFAULT ''; +ALTER TABLE router_configs ADD COLUMN IF NOT EXISTS sync_hash TEXT NOT NULL DEFAULT ''; + +-- +goose Down +ALTER TABLE router_configs DROP COLUMN IF EXISTS sync_hash; +ALTER TABLE connector_definitions DROP COLUMN IF EXISTS sync_hash; diff --git a/acceleration/schema/global.sql b/acceleration/schema/global.sql index ab9d20a3dc..98a5a67773 100644 --- a/acceleration/schema/global.sql +++ b/acceleration/schema/global.sql @@ -536,6 +536,7 @@ TABLE connector_definitions manifest jsonb NOT NULL name text NOT NULL revision integer NOT NULL + sync_hash text NOT NULL DEFAULT ''::text CONSTRAINT connector_definitions_custom_prefix CHECK (((customer_id = ''::text) <> starts_with(id, 'custom_'::text))) CONSTRAINT connector_definitions_pkey PRIMARY KEY (customer_id, id, revision) CONSTRAINT connector_definitions_revision_check CHECK ((revision >= 1)) @@ -1112,6 +1113,7 @@ TABLE router_configs search jsonb NOT NULL DEFAULT '{}'::jsonb sts jsonb NOT NULL DEFAULT '{}'::jsonb stt jsonb NOT NULL DEFAULT '{}'::jsonb + sync_hash text NOT NULL DEFAULT ''::text tts jsonb NOT NULL DEFAULT '{}'::jsonb updated_at timestamp with time zone NOT NULL DEFAULT now() CONSTRAINT router_configs_pkey PRIMARY KEY (id) diff --git a/plugins/stream/vision_agents/plugins/stream/_generated/models/connector.py b/plugins/stream/vision_agents/plugins/stream/_generated/models/connector.py index baf8e8bcb6..c63d714434 100644 --- a/plugins/stream/vision_agents/plugins/stream/_generated/models/connector.py +++ b/plugins/stream/vision_agents/plugins/stream/_generated/models/connector.py @@ -50,6 +50,8 @@ class Connector: sandbox (ConnectorSandbox | Unset): How code in an agent's sandbox reaches the provider's API with a connection's credential. setup (ConnectorSetup | Unset): What a person does at the provider before the first consent. + sync_hash (str | Unset): The fingerprint of the file the CLI last synced onto this connector. Absent on a built- + in, and on a connector that was never synced or was written since by anything that is not a sync. """ channel: bool @@ -67,6 +69,7 @@ class Connector: redirect_uri: str | Unset = UNSET sandbox: ConnectorSandbox | Unset = UNSET setup: ConnectorSetup | Unset = UNSET + sync_hash: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -122,6 +125,8 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.setup, Unset): setup = self.setup.to_dict() + sync_hash = self.sync_hash + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -148,6 +153,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["sandbox"] = sandbox if setup is not UNSET: field_dict["setup"] = setup + if sync_hash is not UNSET: + field_dict["sync_hash"] = sync_hash return field_dict @@ -245,6 +252,8 @@ def _parse_scopes(data: object) -> list[str] | None: else: setup = ConnectorSetup.from_dict(_setup) + sync_hash = d.pop("sync_hash", UNSET) + connector = cls( channel=channel, client=client, @@ -261,6 +270,7 @@ def _parse_scopes(data: object) -> list[str] | None: redirect_uri=redirect_uri, sandbox=sandbox, setup=setup, + sync_hash=sync_hash, ) connector.additional_properties = d diff --git a/plugins/stream/vision_agents/plugins/stream/_generated/models/custom_connector_request.py b/plugins/stream/vision_agents/plugins/stream/_generated/models/custom_connector_request.py index bf23e5b0a3..721127491a 100644 --- a/plugins/stream/vision_agents/plugins/stream/_generated/models/custom_connector_request.py +++ b/plugins/stream/vision_agents/plugins/stream/_generated/models/custom_connector_request.py @@ -33,6 +33,9 @@ class CustomConnectorRequest: authenticates at the token endpoint. description (str | Unset): scopes (list[str] | None | Unset): The scopes a consent asks for, each an RFC 6749 scope token. + sync_hash (str | Unset): The fingerprint of the file this definition was synced from, which the connector then + carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest + revision already says with another hash stores no new revision and records the hash on that one. """ endpoint: str @@ -43,6 +46,7 @@ class CustomConnectorRequest: client: ConnectorClient | Unset = UNSET description: str | Unset = UNSET scopes: list[str] | None | Unset = UNSET + sync_hash: str | Unset = UNSET def to_dict(self) -> dict[str, Any]: endpoint = self.endpoint @@ -75,6 +79,8 @@ def to_dict(self) -> dict[str, Any]: else: scopes = self.scopes + sync_hash = self.sync_hash + field_dict: dict[str, Any] = {} field_dict.update( @@ -93,6 +99,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["description"] = description if scopes is not UNSET: field_dict["scopes"] = scopes + if sync_hash is not UNSET: + field_dict["sync_hash"] = sync_hash return field_dict @@ -150,6 +158,8 @@ def _parse_scopes(data: object) -> list[str] | None | Unset: scopes = _parse_scopes(d.pop("scopes", UNSET)) + sync_hash = d.pop("sync_hash", UNSET) + custom_connector_request = cls( endpoint=endpoint, id=id, @@ -159,6 +169,7 @@ def _parse_scopes(data: object) -> list[str] | None | Unset: client=client, description=description, scopes=scopes, + sync_hash=sync_hash, ) return custom_connector_request diff --git a/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config.py b/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config.py index 7456c51403..d760fc2146 100644 --- a/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config.py +++ b/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config.py @@ -44,6 +44,8 @@ class RouterConfig: tts (TtsOptions | Unset): How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. + sync_hash (str | Unset): The fingerprint of the file the CLI last synced onto this config. Absent if it was + never synced, or was written since by anything that is not a sync. """ created_at: datetime.datetime @@ -55,6 +57,7 @@ class RouterConfig: sts: StsOptions | Unset = UNSET stt: SttOptions | Unset = UNSET tts: TtsOptions | Unset = UNSET + sync_hash: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -86,6 +89,8 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.tts, Unset): tts = self.tts.to_dict() + sync_hash = self.sync_hash + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -106,6 +111,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["stt"] = stt if tts is not UNSET: field_dict["tts"] = tts + if sync_hash is not UNSET: + field_dict["sync_hash"] = sync_hash return field_dict @@ -161,6 +168,8 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: else: tts = TtsOptions.from_dict(_tts) + sync_hash = d.pop("sync_hash", UNSET) + router_config = cls( created_at=created_at, id=id, @@ -171,6 +180,7 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: sts=sts, stt=stt, tts=tts, + sync_hash=sync_hash, ) router_config.additional_properties = d diff --git a/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config_request.py b/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config_request.py index 2204ff1b45..054ed79ec0 100644 --- a/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config_request.py +++ b/plugins/stream/vision_agents/plugins/stream/_generated/models/router_config_request.py @@ -40,6 +40,9 @@ class RouterConfigRequest: tts (TtsOptions | Unset): How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. + sync_hash (str | Unset): The fingerprint of the file this config was synced from, which the config then carries. + Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same + content writes nothing. """ name: str @@ -48,6 +51,7 @@ class RouterConfigRequest: sts: StsOptions | Unset = UNSET stt: SttOptions | Unset = UNSET tts: TtsOptions | Unset = UNSET + sync_hash: str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -73,6 +77,8 @@ def to_dict(self) -> dict[str, Any]: if not isinstance(self.tts, Unset): tts = self.tts.to_dict() + sync_hash = self.sync_hash + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -90,6 +96,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["stt"] = stt if tts is not UNSET: field_dict["tts"] = tts + if sync_hash is not UNSET: + field_dict["sync_hash"] = sync_hash return field_dict @@ -139,6 +147,8 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: else: tts = TtsOptions.from_dict(_tts) + sync_hash = d.pop("sync_hash", UNSET) + router_config_request = cls( name=name, llm=llm, @@ -146,6 +156,7 @@ def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: sts=sts, stt=stt, tts=tts, + sync_hash=sync_hash, ) router_config_request.additional_properties = d diff --git a/sdks/dotnet/src/GetStream.VisionAgents/Generated/Models.cs b/sdks/dotnet/src/GetStream.VisionAgents/Generated/Models.cs index 1b84fb7883..690522a745 100644 --- a/sdks/dotnet/src/GetStream.VisionAgents/Generated/Models.cs +++ b/sdks/dotnet/src/GetStream.VisionAgents/Generated/Models.cs @@ -5312,6 +5312,12 @@ public partial class Connector [System.Text.Json.Serialization.JsonPropertyName("setup")] public ConnectorSetup? Setup { get; set; } = default!; + /// + /// The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync. + /// + [System.Text.Json.Serialization.JsonPropertyName("sync_hash")] + public string? SyncHash { get; set; } = default!; + private System.Collections.Generic.IDictionary? _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] @@ -7050,6 +7056,12 @@ public partial class CustomConnectorRequest [System.Text.Json.Serialization.JsonPropertyName("scopes")] public System.Collections.Generic.List? Scopes { get; set; } = default!; + /// + /// The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one. + /// + [System.Text.Json.Serialization.JsonPropertyName("sync_hash")] + public string? SyncHash { get; set; } = default!; + } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.7.1.0 (NJsonSchema v11.6.1.0 (Newtonsoft.Json v13.0.0.0))")] @@ -12865,6 +12877,12 @@ public partial class RouterConfig [System.Text.Json.Serialization.JsonPropertyName("stt")] public SttOptions? Stt { get; set; } = default!; + /// + /// The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync. + /// + [System.Text.Json.Serialization.JsonPropertyName("sync_hash")] + public string? SyncHash { get; set; } = default!; + [System.Text.Json.Serialization.JsonPropertyName("tts")] public TtsOptions? Tts { get; set; } = default!; @@ -12904,6 +12922,12 @@ public partial class RouterConfigRequest [System.Text.Json.Serialization.JsonPropertyName("stt")] public SttOptions? Stt { get; set; } = default!; + /// + /// The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing. + /// + [System.Text.Json.Serialization.JsonPropertyName("sync_hash")] + public string? SyncHash { get; set; } = default!; + [System.Text.Json.Serialization.JsonPropertyName("tts")] public TtsOptions? Tts { get; set; } = default!; diff --git a/sdks/go/acceleration/generated.go b/sdks/go/acceleration/generated.go index 282cd0efcd..d14f2b832d 100644 --- a/sdks/go/acceleration/generated.go +++ b/sdks/go/acceleration/generated.go @@ -5766,6 +5766,9 @@ type Connector struct { // Setup What a person does at the provider before the first consent. Setup *ConnectorSetup `json:"setup,omitempty"` + + // SyncHash The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync. + SyncHash *string `json:"sync_hash,omitempty"` } // ConnectorAuditAction grant_created: a consent or a credentials write gave the connection a grant. grant_refreshed: the router renewed its credential. grant_revoked: the grant ended, because the provider refused or revoked it or the connection was deleted. token_export: the app's backend exported its access credential. proxy_call: a direct call went to the provider through the connection. tool_reapproved: the app's backend approved tools at the schema the provider lists now (POST .../tools/approve); tools names them. @@ -6507,6 +6510,9 @@ type CustomConnectorRequest struct { // Scopes The scopes a consent asks for, each an RFC 6749 scope token. Scopes *[]string `json:"scopes,omitempty"` + + // SyncHash The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one. + SyncHash *string `json:"sync_hash,omitempty"` } // CustomModel defines model for CustomModel. @@ -9102,6 +9108,9 @@ type RouterConfig struct { // Stt How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. Stt *SttOptions `json:"stt,omitempty"` + // SyncHash The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync. + SyncHash *string `json:"sync_hash,omitempty"` + // Tts How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. Tts *TtsOptions `json:"tts,omitempty"` UpdatedAt time.Time `json:"updated_at"` @@ -9124,6 +9133,9 @@ type RouterConfigRequest struct { // Stt How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. Stt *SttOptions `json:"stt,omitempty"` + // SyncHash The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing. + SyncHash *string `json:"sync_hash,omitempty"` + // Tts How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. Tts *TtsOptions `json:"tts,omitempty"` } diff --git a/sdks/js/src/generated/api.ts b/sdks/js/src/generated/api.ts index 6d87e6bb5f..6f1a8e1e28 100644 --- a/sdks/js/src/generated/api.ts +++ b/sdks/js/src/generated/api.ts @@ -6578,6 +6578,8 @@ export type components = { readonly scopes: readonly string[] | null; /** @description What a person does at the provider before the first consent, such as registering an OAuth client. Absent when the manifest says nothing. */ readonly setup?: components["schemas"]["ConnectorSetup"]; + /** @description The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync. */ + readonly sync_hash?: string; }; /** * @description grant_created: a consent or a credentials write gave the connection a grant. grant_refreshed: the router renewed its credential. grant_revoked: the grant ended, because the provider refused or revoked it or the connection was deleted. token_export: the app's backend exported its access credential. proxy_call: a direct call went to the provider through the connection. tool_reapproved: the app's backend approved tools at the schema the provider lists now (POST .../tools/approve); tools names them. @@ -7211,6 +7213,8 @@ export type components = { readonly schemes: readonly string[] | null; /** @description The scopes a consent asks for, each an RFC 6749 scope token. */ readonly scopes?: readonly string[] | null; + /** @description The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one. */ + readonly sync_hash?: string; }; readonly CustomModel: { readonly base_url: string; @@ -9586,6 +9590,8 @@ export type components = { readonly search?: components["schemas"]["SearchOptions"]; readonly sts?: components["schemas"]["StsOptions"]; readonly stt?: components["schemas"]["SttOptions"]; + /** @description The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync. */ + readonly sync_hash?: string; readonly tts?: components["schemas"]["TtsOptions"]; /** Format: date-time */ readonly updated_at: string; @@ -9597,6 +9603,8 @@ export type components = { readonly search?: components["schemas"]["SearchOptions"]; readonly sts?: components["schemas"]["StsOptions"]; readonly stt?: components["schemas"]["SttOptions"]; + /** @description The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing. */ + readonly sync_hash?: string; readonly tts?: components["schemas"]["TtsOptions"]; }; readonly Run: { diff --git a/sdks/php/src/Generated/Connector.php b/sdks/php/src/Generated/Connector.php index 9b3d943204..14181b2c90 100644 --- a/sdks/php/src/Generated/Connector.php +++ b/sdks/php/src/Generated/Connector.php @@ -45,6 +45,8 @@ public function __construct( public ?ConnectorSandbox $sandbox = null, // What a person does at the provider before the first consent, such as registering an OAuth client. Absent wh... public ?ConnectorSetup $setup = null, + // The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connect... + public ?string $syncHash = null, ) { } @@ -69,6 +71,7 @@ public static function fromArray(array $data): self redirectUri: array_key_exists('redirect_uri', $data) && $data['redirect_uri'] !== null ? Json::string($data, 'redirect_uri') : null, sandbox: array_key_exists('sandbox', $data) && $data['sandbox'] !== null ? ConnectorSandbox::fromArray(Json::object($data, 'sandbox')) : null, setup: array_key_exists('setup', $data) && $data['setup'] !== null ? ConnectorSetup::fromArray(Json::object($data, 'setup')) : null, + syncHash: array_key_exists('sync_hash', $data) && $data['sync_hash'] !== null ? Json::string($data, 'sync_hash') : null, ); } @@ -105,6 +108,9 @@ public function toArray(): array if ($this->setup !== null) { $out['setup'] = $this->setup->toArray(); } + if ($this->syncHash !== null) { + $out['sync_hash'] = $this->syncHash; + } return $out; } } diff --git a/sdks/php/src/Generated/CustomConnectorRequest.php b/sdks/php/src/Generated/CustomConnectorRequest.php index df5cac0e40..cc1d341044 100644 --- a/sdks/php/src/Generated/CustomConnectorRequest.php +++ b/sdks/php/src/Generated/CustomConnectorRequest.php @@ -29,6 +29,8 @@ public function __construct( // The scopes a consent asks for, each an RFC 6749 scope token. /** @var list|null */ public ?array $scopes = null, + // The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a... + public ?string $syncHash = null, ) { } @@ -46,6 +48,7 @@ public static function fromArray(array $data): self client: array_key_exists('client', $data) && $data['client'] !== null ? ConnectorClient::fromArray(Json::object($data, 'client')) : null, description: array_key_exists('description', $data) && $data['description'] !== null ? Json::string($data, 'description') : null, scopes: array_key_exists('scopes', $data) && $data['scopes'] !== null ? Json::strings($data, 'scopes') : null, + syncHash: array_key_exists('sync_hash', $data) && $data['sync_hash'] !== null ? Json::string($data, 'sync_hash') : null, ); } @@ -73,6 +76,9 @@ public function toArray(): array if ($this->scopes !== null) { $out['scopes'] = $this->scopes; } + if ($this->syncHash !== null) { + $out['sync_hash'] = $this->syncHash; + } return $out; } } diff --git a/sdks/php/src/Generated/RouterConfig.php b/sdks/php/src/Generated/RouterConfig.php index 1d5c199809..feb957926a 100644 --- a/sdks/php/src/Generated/RouterConfig.php +++ b/sdks/php/src/Generated/RouterConfig.php @@ -20,6 +20,8 @@ public function __construct( public ?StsOptions $sts = null, public ?SttOptions $stt = null, public ?TtsOptions $tts = null, + // The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was wri... + public ?string $syncHash = null, ) { } @@ -38,6 +40,7 @@ public static function fromArray(array $data): self sts: array_key_exists('sts', $data) && $data['sts'] !== null ? StsOptions::fromArray(Json::object($data, 'sts')) : null, stt: array_key_exists('stt', $data) && $data['stt'] !== null ? SttOptions::fromArray(Json::object($data, 'stt')) : null, tts: array_key_exists('tts', $data) && $data['tts'] !== null ? TtsOptions::fromArray(Json::object($data, 'tts')) : null, + syncHash: array_key_exists('sync_hash', $data) && $data['sync_hash'] !== null ? Json::string($data, 'sync_hash') : null, ); } @@ -68,6 +71,9 @@ public function toArray(): array if ($this->tts !== null) { $out['tts'] = $this->tts->toArray(); } + if ($this->syncHash !== null) { + $out['sync_hash'] = $this->syncHash; + } return $out; } } diff --git a/sdks/php/src/Generated/RouterConfigRequest.php b/sdks/php/src/Generated/RouterConfigRequest.php index 1a00249fab..10c99d0d11 100644 --- a/sdks/php/src/Generated/RouterConfigRequest.php +++ b/sdks/php/src/Generated/RouterConfigRequest.php @@ -18,6 +18,8 @@ public function __construct( public ?StsOptions $sts = null, public ?SttOptions $stt = null, public ?TtsOptions $tts = null, + // The fingerprint of the file this config was synced from, which the config then carries. Absent for a write... + public ?string $syncHash = null, ) { } @@ -33,6 +35,7 @@ public static function fromArray(array $data): self sts: array_key_exists('sts', $data) && $data['sts'] !== null ? StsOptions::fromArray(Json::object($data, 'sts')) : null, stt: array_key_exists('stt', $data) && $data['stt'] !== null ? SttOptions::fromArray(Json::object($data, 'stt')) : null, tts: array_key_exists('tts', $data) && $data['tts'] !== null ? TtsOptions::fromArray(Json::object($data, 'tts')) : null, + syncHash: array_key_exists('sync_hash', $data) && $data['sync_hash'] !== null ? Json::string($data, 'sync_hash') : null, ); } @@ -60,6 +63,9 @@ public function toArray(): array if ($this->tts !== null) { $out['tts'] = $this->tts->toArray(); } + if ($this->syncHash !== null) { + $out['sync_hash'] = $this->syncHash; + } return $out; } } diff --git a/sdks/ruby/lib/getstream/vision_agents/generated/spec.rb b/sdks/ruby/lib/getstream/vision_agents/generated/spec.rb index 2496d3a998..648bf48812 100644 --- a/sdks/ruby/lib/getstream/vision_agents/generated/spec.rb +++ b/sdks/ruby/lib/getstream/vision_agents/generated/spec.rb @@ -2288,7 +2288,7 @@ module Generated required: [].freeze, open: false }.freeze, "Connector" => { - properties: %w[category channel client created_at custom description id inputs name redirect_uri revision sandbox schemes scopes setup].freeze, + properties: %w[category channel client created_at custom description id inputs name redirect_uri revision sandbox schemes scopes setup sync_hash].freeze, required: %w[id revision name custom schemes inputs scopes client channel created_at].freeze, open: false }.freeze, "ConnectorAuditCredential" => { @@ -2432,7 +2432,7 @@ module Generated required: %w[items has_more].freeze, open: false }.freeze, "CustomConnectorRequest" => { - properties: %w[category client description endpoint id name schemes scopes].freeze, + properties: %w[category client description endpoint id name schemes scopes sync_hash].freeze, required: %w[id name endpoint schemes].freeze, open: false }.freeze, "CustomModel" => { @@ -2980,11 +2980,11 @@ module Generated required: %w[candidates description id title].freeze, open: false }.freeze, "RouterConfig" => { - properties: %w[created_at id llm name search sts stt tts updated_at].freeze, + properties: %w[created_at id llm name search sts stt sync_hash tts updated_at].freeze, required: %w[created_at id name updated_at].freeze, open: false }.freeze, "RouterConfigRequest" => { - properties: %w[llm name search sts stt tts].freeze, + properties: %w[llm name search sts stt sync_hash tts].freeze, required: %w[name].freeze, open: false }.freeze, "Run" => { diff --git a/sdks/rust/src/types.rs b/sdks/rust/src/types.rs index b90d80196e..835a36bdfb 100644 --- a/sdks/rust/src/types.rs +++ b/sdks/rust/src/types.rs @@ -4033,6 +4033,9 @@ pub struct Connector { ///What a person does at the provider before the first consent, such as registering an OAuth client. Absent when the manifest says nothing. #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub setup: ::std::option::Option, + ///The fingerprint of the file the CLI last synced onto this connector. Absent on a built-in, and on a connector that was never synced or was written since by anything that is not a sync. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub sync_hash: ::std::option::Option<::std::string::String>, } ///grant_created: a consent or a credentials write gave the connection a grant. grant_refreshed: the router renewed its credential. grant_revoked: the grant ended, because the provider refused or revoked it or the connection was deleted. token_export: the app's backend exported its access credential. proxy_call: a direct call went to the provider through the connection. tool_reapproved: the app's backend approved tools at the schema the provider lists now (POST .../tools/approve); tools names them. #[derive( @@ -5297,6 +5300,9 @@ pub struct CustomConnectorRequest { ///The scopes a consent asks for, each an RFC 6749 scope token. #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub scopes: ::std::option::Option<::std::vec::Vec<::std::string::String>>, + ///The fingerprint of the file this definition was synced from, which the connector then carries. Absent for a write that is no sync: the connector then carries none. Sending a definition the newest revision already says with another hash stores no new revision and records the hash on that one. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub sync_hash: ::std::option::Option<::std::string::String>, } ///`CustomModel` #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq, Default)] @@ -10463,6 +10469,9 @@ pub struct RouterConfig { pub sts: ::std::option::Option, #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub stt: ::std::option::Option, + ///The fingerprint of the file the CLI last synced onto this config. Absent if it was never synced, or was written since by anything that is not a sync. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub sync_hash: ::std::option::Option<::std::string::String>, #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub tts: ::std::option::Option, pub updated_at: ::std::string::String, @@ -10480,6 +10489,9 @@ pub struct RouterConfigRequest { pub sts: ::std::option::Option, #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub stt: ::std::option::Option, + ///The fingerprint of the file this config was synced from, which the config then carries. Absent for a write that is no sync, which clears it. A replace with the hash the config carries and the same content writes nothing. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub sync_hash: ::std::option::Option<::std::string::String>, #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub tts: ::std::option::Option, }