Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ sequenceDiagram

Hercules->>Aquila: Register datatypes
Aquila-->>Hercules: Validation result

Hercules->>Stream: ActionConfiguration Request<br>with (registered) datatypes

Hercules->>Aquila: Register function definitions
Aquila-->>Hercules: Validation result
Expand Down
5 changes: 3 additions & 2 deletions bin/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby '3.4.7'


gem 'tucana', '0.0.56'
gem 'grpc', '~> 1.67'
gem 'tucana', '0.0.56'
10 changes: 7 additions & 3 deletions bin/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
PATH
remote: ../../tucana/build/ruby
specs:
tucana (0.0.0)
grpc (~> 1.64)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -17,16 +23,14 @@ GEM
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
rake (13.3.1)
tucana (0.0.56)
grpc (~> 1.64)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
grpc (~> 1.67)
tucana (= 0.0.56)
tucana (= 0.0.0)!

RUBY VERSION
ruby 3.4.7p58
Expand Down
22 changes: 20 additions & 2 deletions bin/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ def add_runtime_functions(functions)
def add_action_config_definition(config)
@action_config_definitions << config
end

def register_config_definitions(token, config_definitions)
@action_config_definitions.each do |config|
next unless config[:auth_token] == token

config[:config_definitions] = config_definitions
puts "Registered config definitions for action: #{config[:action_identifier]} (v#{config[:version]})"
break
end
end
end

class FlowTypeTransferService < Tucana::Aquila::FlowTypeService::Service
Expand Down Expand Up @@ -93,7 +103,8 @@ def construct_parameters(func)
end

def transfer(requests, call)
puts "Got Auth token: #{call.metadata['authorization']}"
token = call.metadata['authorization']
puts "Got Auth token: #{token}"
Enumerator.new do |yielder|
Thread.new do
loop do
Expand Down Expand Up @@ -144,6 +155,7 @@ def transfer(requests, call)
end

requests.each do |req|
p req
unless req.result.nil?
puts "Received execution result for: #{req.result.execution_identifier}"
puts "Result value: #{req.result.result}"
Expand All @@ -157,14 +169,20 @@ def transfer(requests, call)
next
end

unless req.action_configuration.nil?
@state.register_config_definitions(token,
req.action_configuration.action_configurations)
end

next if req.logon.nil?

logon = req.logon

@state.add_action_config_definition({
auth_token: token,
action_identifier: logon.action_identifier,
version: logon.version,
config_definitions: logon.action_configurations,
config_definitions: [],
})

puts "Action logon received: #{logon.action_identifier} (v#{logon.version})"
Expand Down
58 changes: 7 additions & 51 deletions ts/examples/simple_example.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,29 @@
import { createSdk } from "../src/action_sdk.js";
import { Struct, Value } from "@code0-tech/tucana/pb/shared.struct_pb.js";
import { constructValue } from "@code0-tech/tucana/helpers/shared.struct_helper.js";
import { ActionProjectConfiguration } from "@code0-tech/tucana/pb/shared.action_configuration_pb.js";
import {randomUUID} from "node:crypto";

const sdk = createSdk({
token: "your_token_here",
token: randomUUID(),
actionUrl: "127.0.0.1:50051",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be named differently

actionId: "action_123",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this id come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its just an auth token currently just an random identifier for the test server

version: "0.0.0",
})

sdk.registerConfigDefinitions({
type: {
signature: "string",
identifier: "STRING",
version: "0.0.0",
rules: [],
name: [],
genericKeys: [],
alias: [],
displayMessage: [],
linkedDataTypeIdentifiers: [],
definitionSource: ""
},
name: [],
description: [],
type: "LIST<STRING>",
linkedDataTypeIdentifiers: ["STRING", "LIST"],
identifier: "config_discord_bot_token",
})
Comment on lines 13 to 17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be parsed in as the root sdk object


sdk.registerDataType({
identifier: "SOME_DATATYPE",
signature: "any",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its named type not signature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this naming in tucana then

name: [],
alias: [],
rules: [],
genericKeys: [],
displayMessage: [],
definitionSource: "",
linkedDataTypeIdentifiers: [],
version: "0.0.0",
})

sdk.registerFunctionDefinition(
{
signature: "(n: NUMBER) => NUMBER",
definitionSource: "",
linkedDataTypeIdentifiers: ["NUMBER"],
runtimeParameterDefinitions: [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its should be named simply parameters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tucana naming

{
Expand All @@ -55,46 +34,23 @@ sdk.registerFunctionDefinition(
defaultValue: constructValue(20),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just put in 20

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it

}
],
alias: [],
deprecationMessage: [],
description: [],
displayIcon: "",
displayMessage: [],
documentation: [],
name: [],
throwsError: false,
version: "0.0.0",
runtimeName: "fib",
},
async (params: Struct): Promise<Value> => {
console.log("Received parameters:", params);
let n = params.fields["n"];

(n: number): number => {
function fibonacci(num: number): number {
if (num <= 1) return num;
return fibonacci(num - 1) + fibonacci(num - 2);
}

if (n && n.kind.oneofKind === "numberValue") {
return constructValue(fibonacci(n.kind.numberValue));
}

return constructValue(fibonacci(1));
return fibonacci(n)
}
)

sdk.registerFlowType(
{
documentation: [],
description: [],
displayIcon: "",
displayMessage: [],
editable: false,
inputTypeIdentifier: "STRING",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be named inputType

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tucana

name: [],
alias: [],
identifier: "test_flow",
settings: [],
version: "0.0.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version is absolute here, because its the same as in sdk

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

}
)
Expand All @@ -119,4 +75,4 @@ function connectToSdk() {
connectToSdk();
}, 5000)
})
}
}
Loading