Skip to content

Commit 1d39d95

Browse files
authored
agent-first-config: local agent config during component creation (#2840)
* agent-first-config: local agent config during component creation * wip * add tests * update * add diffing
1 parent 9fbddc4 commit 1d39d95

File tree

98 files changed

+1603
-470
lines changed

Some content is hidden

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

98 files changed

+1603
-470
lines changed

cli/golem-cli/src/bridge_gen/rust/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ fn rust_counter_agent() -> GeneratedPackage {
130130
mode: AgentMode::Durable,
131131
http_mount: None,
132132
snapshotting: Snapshotting::Disabled(Empty {}),
133+
config: Vec::new(),
133134
};
134135

135136
GeneratedPackage::new(agent_type)

cli/golem-cli/src/bridge_gen/typescript/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ fn ts_counter_agent() -> GeneratedPackage {
203203
mode: AgentMode::Durable,
204204
http_mount: None,
205205
snapshotting: Snapshotting::Disabled(Empty {}),
206+
config: Vec::new(),
206207
};
207208

208209
GeneratedPackage::new(agent_type)

cli/golem-cli/src/command_handler/app/deploy_diff.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ fn normalized_diff_deployment(
742742
wasm_hash: component.wasm_hash,
743743
files_by_path: component.files_by_path.clone(),
744744
plugins_by_grant_id: component.plugins_by_grant_id.clone(),
745+
local_agent_config_ordered_by_agent_and_key: component
746+
.local_agent_config_ordered_by_agent_and_key
747+
.clone(),
745748
}
746749
.into(),
747750
None => component.hash().into(),

cli/golem-cli/src/command_handler/component/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,8 @@ impl ComponentCommandHandler {
10261026
wasm_hash: component_binary_hash.into(),
10271027
files_by_path,
10281028
plugins_by_grant_id,
1029+
// FIXME: agent-config
1030+
local_agent_config_ordered_by_agent_and_key: Vec::new(),
10291031
})
10301032
}
10311033

@@ -1072,6 +1074,8 @@ impl ComponentCommandHandler {
10721074
.unwrap_or_default(),
10731075
env: component_stager.env(),
10741076
config_vars: component_stager.config_vars(),
1077+
// FIXME: agent-config
1078+
local_agent_config: Vec::new(),
10751079
agent_types,
10761080
plugins: component_stager.plugins(),
10771081
},
@@ -1166,6 +1170,8 @@ impl ComponentCommandHandler {
11661170
removed_files: changed_files.removed.clone(),
11671171
new_file_options: changed_files.merged_file_options(),
11681172
config_vars: component_stager.config_vars_if_changed(),
1173+
// FIXME: local-agent-config
1174+
local_agent_config: None,
11691175
env: component_stager.env_if_changed(),
11701176
agent_types,
11711177
plugin_updates: component_stager.plugins_if_changed(),

cli/golem-cli/src/model/agent/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub fn single_agent_wrapper_types() -> Vec<AgentType> {
101101
mode: AgentMode::Durable,
102102
http_mount: None,
103103
snapshotting: Snapshotting::Disabled(Empty {}),
104+
config: Vec::new(),
104105
}]
105106
}
106107

@@ -172,6 +173,7 @@ pub fn multi_agent_wrapper_2_types() -> Vec<AgentType> {
172173
mode: AgentMode::Durable,
173174
http_mount: None,
174175
snapshotting: Snapshotting::Disabled(Empty {}),
176+
config: Vec::new(),
175177
},
176178
AgentType {
177179
type_name: golem_common::model::agent::AgentTypeName("agent2".to_string()),
@@ -232,6 +234,7 @@ pub fn multi_agent_wrapper_2_types() -> Vec<AgentType> {
232234
mode: AgentMode::Durable,
233235
http_mount: None,
234236
snapshotting: Snapshotting::Disabled(Empty {}),
237+
config: Vec::new(),
235238
},
236239
];
237240

cli/golem-cli/test-data/goldenfiles/extracted-agent-types/code_first_snippets_rust.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
{
3+
"config": [],
34
"constructor": {
45
"description": "",
56
"inputSchema": {
@@ -6202,6 +6203,7 @@
62026203
"typeName": "BarAgent"
62036204
},
62046205
{
6206+
"config": [],
62056207
"constructor": {
62066208
"description": "",
62076209
"inputSchema": {
@@ -12452,6 +12454,7 @@
1245212454
"typeName": "FooAgent"
1245312455
},
1245412456
{
12457+
"config": [],
1245512458
"constructor": {
1245612459
"description": "",
1245712460
"inputSchema": {

cli/golem-cli/test-data/goldenfiles/extracted-agent-types/code_first_snippets_ts.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
{
3+
"config": [],
34
"constructor": {
45
"description": "TS Code First BarAgent",
56
"inputSchema": {
@@ -5013,6 +5014,7 @@
50135014
"typeName": "BarAgent"
50145015
},
50155016
{
5017+
"config": [],
50165018
"constructor": {
50175019
"description": "TS Code First FooAgent",
50185020
"inputSchema": {

golem-api-grpc/proto/golem/component/agent.proto

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ message AgentType {
4949
AgentMode mode = 6;
5050
optional HttpMountDetails http_mount = 7;
5151
optional Snapshotting snapshotting = 8;
52+
repeated ConfigKeyValueType config = 9;
5253
}
5354

5455
message BinaryDescriptor {
@@ -350,3 +351,23 @@ message LoadSnapshotInvocation {
350351
message ProcessOplogEntriesInvocation {
351352
golem.worker.IdempotencyKey idempotency_key = 1;
352353
}
354+
355+
message ConfigKeyValueType {
356+
repeated string key = 1;
357+
ConfigValueType value = 2;
358+
}
359+
360+
message ConfigValueType {
361+
oneof kind {
362+
Local local = 1;
363+
Shared shared = 2;
364+
}
365+
366+
message Local {
367+
wasm.rpc.Type value = 1;
368+
}
369+
370+
message Shared {
371+
wasm.rpc.Type value = 2;
372+
}
373+
}

golem-api-grpc/proto/golem/component/component.proto

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ import "golem/component/component_files.proto";
1010
import "golem/component/component_metadata.proto";
1111
import "golem/component/plugin.proto";
1212
import "golem/component/component_id.proto";
13+
import "wasm/rpc/value_and_type.proto";
1314
import "golem/auth/environment_role.proto";
1415
import "google/protobuf/timestamp.proto";
1516

17+
message LocalAgentConfigEntry {
18+
string agent = 1;
19+
repeated string key = 2;
20+
wasm.rpc.ValueAndType value = 3;
21+
}
22+
1623
message Component {
1724
ComponentId component_id = 1;
1825
uint64 revision = 2;
@@ -29,7 +36,10 @@ message Component {
2936
map<string, string> original_env = 13;
3037
map<string, string> config_vars = 14;
3138
map<string, string> original_config_vars = 15;
32-
golem.common.Hash wasm_hash = 16;
33-
golem.common.ApplicationId application_id = 17;
34-
golem.common.Hash hash = 18;
39+
repeated LocalAgentConfigEntry local_agent_config = 16;
40+
golem.common.Hash wasm_hash = 17;
41+
golem.common.ApplicationId application_id = 18;
42+
golem.common.Hash hash = 19;
43+
string transformed_object_store_key = 20;
44+
string object_store_key = 21;
3545
}

golem-common/src/base_model/agent.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,15 @@ pub struct AgentType {
382382
pub mode: AgentMode,
383383
pub http_mount: Option<HttpMountDetails>,
384384
pub snapshotting: Snapshotting,
385+
pub config: Vec<ConfigKeyValueType>,
385386
}
386387

387388
impl AgentType {
388389
pub fn normalized(mut self) -> Self {
389390
self.methods.sort_by(|a, b| a.name.cmp(&b.name));
390391
self.dependencies
391392
.sort_by(|a, b| a.type_name.cmp(&b.type_name));
393+
self.config.sort_by(|a, b| a.key.cmp(&b.key));
392394

393395
Self {
394396
type_name: self.type_name,
@@ -403,6 +405,7 @@ impl AgentType {
403405
mode: self.mode,
404406
http_mount: self.http_mount,
405407
snapshotting: self.snapshotting,
408+
config: self.config,
406409
}
407410
}
408411

@@ -1112,6 +1115,58 @@ pub struct SnapshottingEveryNInvocation {
11121115
pub count: u16,
11131116
}
11141117

1118+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1119+
#[cfg_attr(
1120+
feature = "full",
1121+
derive(desert_rust::BinaryCodec, poem_openapi::Object, IntoValue, FromValue)
1122+
)]
1123+
#[cfg_attr(feature = "full", desert(evolution()))]
1124+
#[cfg_attr(feature = "full", oai(rename_all = "camelCase"))]
1125+
#[serde(rename_all = "camelCase")]
1126+
pub struct ConfigKeyValueType {
1127+
pub key: Vec<String>,
1128+
pub value: ConfigValueType,
1129+
}
1130+
1131+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1132+
#[cfg_attr(
1133+
feature = "full",
1134+
derive(desert_rust::BinaryCodec, poem_openapi::Union, IntoValue, FromValue)
1135+
)]
1136+
#[cfg_attr(feature = "full", oai(discriminator_name = "type", one_of = true))]
1137+
#[serde(tag = "type")]
1138+
#[cfg_attr(feature = "full", desert(evolution()))]
1139+
pub enum ConfigValueType {
1140+
Local(ConfigValueTypeLocal),
1141+
Shared(ConfigValueTypeShared),
1142+
}
1143+
1144+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1145+
#[cfg_attr(
1146+
feature = "full",
1147+
derive(desert_rust::BinaryCodec, poem_openapi::Object, IntoValue, FromValue)
1148+
)]
1149+
#[cfg_attr(feature = "full", oai(rename_all = "camelCase"))]
1150+
#[serde(rename_all = "camelCase")]
1151+
#[cfg_attr(feature = "full", desert(transparent))]
1152+
#[cfg_attr(feature = "full", wit_transparent)]
1153+
pub struct ConfigValueTypeLocal {
1154+
pub value: AnalysedType,
1155+
}
1156+
1157+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1158+
#[cfg_attr(
1159+
feature = "full",
1160+
derive(desert_rust::BinaryCodec, poem_openapi::Object, IntoValue, FromValue)
1161+
)]
1162+
#[cfg_attr(feature = "full", oai(rename_all = "camelCase"))]
1163+
#[serde(rename_all = "camelCase")]
1164+
#[cfg_attr(feature = "full", desert(transparent))]
1165+
#[cfg_attr(feature = "full", wit_transparent)]
1166+
pub struct ConfigValueTypeShared {
1167+
pub value: AnalysedType,
1168+
}
1169+
11151170
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, IntoValue, FromValue)]
11161171
#[cfg_attr(
11171172
feature = "full",

0 commit comments

Comments
 (0)