sfdc-agentforce-byoc-python-sdk 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. agentforce_byoc/__init__.py +26 -0
  2. agentforce_byoc/_http.py +142 -0
  3. agentforce_byoc/cli/__init__.py +8 -0
  4. agentforce_byoc/cli/commands.py +913 -0
  5. agentforce_byoc/cli/main.py +44 -0
  6. agentforce_byoc/client.py +224 -0
  7. agentforce_byoc/deploy_client.py +246 -0
  8. agentforce_byoc/gateway/__init__.py +26 -0
  9. agentforce_byoc/gateway/base.py +66 -0
  10. agentforce_byoc/gateway/mock_relay_client.py +54 -0
  11. agentforce_byoc/gateway/relay_client.py +394 -0
  12. agentforce_byoc/logging/__init__.py +20 -0
  13. agentforce_byoc/logging/formatter.py +96 -0
  14. agentforce_byoc/logging/logger.py +59 -0
  15. agentforce_byoc/runtime/__init__.py +21 -0
  16. agentforce_byoc/runtime/agentforce_runtime.py +47 -0
  17. agentforce_byoc/runtime/base.py +54 -0
  18. agentforce_byoc/runtime/mock_runtime.py +50 -0
  19. agentforce_byoc/schema_utils/__init__.py +35 -0
  20. agentforce_byoc/schema_utils/entry_func.py +48 -0
  21. agentforce_byoc/schema_utils/generator.py +694 -0
  22. agentforce_byoc/schema_utils/schema.py +79 -0
  23. agentforce_byoc/templates/__init__.py +4 -0
  24. agentforce_byoc/templates/agent/.dockerignore.template +51 -0
  25. agentforce_byoc/templates/agent/.gitignore.template +64 -0
  26. agentforce_byoc/templates/agent/.python-version.template +1 -0
  27. agentforce_byoc/templates/agent/Dockerfile.template +41 -0
  28. agentforce_byoc/templates/agent/Makefile.template +51 -0
  29. agentforce_byoc/templates/agent/README.md.template +358 -0
  30. agentforce_byoc/templates/agent/config.json.template +3 -0
  31. agentforce_byoc/templates/agent/entry_func.py.template +51 -0
  32. agentforce_byoc/templates/agent/main.py.template +149 -0
  33. agentforce_byoc/templates/agent/pyproject.toml.template +24 -0
  34. agentforce_byoc/templates/agent/schema.py.template +73 -0
  35. sfdc_agentforce_byoc_python_sdk-0.1.0.dist-info/METADATA +439 -0
  36. sfdc_agentforce_byoc_python_sdk-0.1.0.dist-info/RECORD +39 -0
  37. sfdc_agentforce_byoc_python_sdk-0.1.0.dist-info/WHEEL +4 -0
  38. sfdc_agentforce_byoc_python_sdk-0.1.0.dist-info/entry_points.txt +3 -0
  39. sfdc_agentforce_byoc_python_sdk-0.1.0.dist-info/licenses/LICENSE +206 -0
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2026, Salesforce, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """Base class for runtime providers."""
17
+
18
+ from abc import ABC, abstractmethod
19
+
20
+ from agentforce_byoc.gateway.base import BaseRelayGatewayClient
21
+
22
+
23
+ class BaseRuntimeProvider(ABC):
24
+ """
25
+ Abstract base class for runtime environment providers.
26
+
27
+ Each runtime provider encapsulates the configuration and gateway clients
28
+ for a specific execution environment (Agentforce runtime or local mock).
29
+ """
30
+
31
+ def __init__(self):
32
+ """Initialize runtime provider."""
33
+ self._relay_gateway_client: BaseRelayGatewayClient = None
34
+
35
+ @property
36
+ @abstractmethod
37
+ def name(self) -> str:
38
+ """Return the runtime provider name."""
39
+ pass
40
+
41
+ @property
42
+ def relay_gateway_client(self) -> BaseRelayGatewayClient:
43
+ """
44
+ Get the Relay gateway client for this runtime.
45
+
46
+ Returns:
47
+ Configured Relay gateway client instance
48
+
49
+ Raises:
50
+ RuntimeError: If the Relay gateway client is not configured
51
+ """
52
+ if self._relay_gateway_client is None:
53
+ raise RuntimeError(f"Relay gateway client not configured for runtime: {self.name}")
54
+ return self._relay_gateway_client
@@ -0,0 +1,50 @@
1
+ # Copyright (c) 2026, Salesforce, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """Mock runtime provider for local testing."""
17
+
18
+ from agentforce_byoc.gateway.mock_relay_client import MockRelayGatewayClient
19
+ from agentforce_byoc.runtime.base import BaseRuntimeProvider
20
+
21
+
22
+ class MockRuntimeProvider(BaseRuntimeProvider):
23
+ """
24
+ Mock runtime provider for local development outside the managed sandbox.
25
+
26
+ Wires up the :class:`MockRelayGatewayClient`, which behaves like the
27
+ Agentforce client but takes the org JWT from the SDK author (constructor
28
+ arg or the ``ORG_JWT_TOKEN`` env var).
29
+
30
+ Example:
31
+ This provider is selected when the AGENTFORCE_BYOC_MOCK env var is set:
32
+
33
+ >>> import os
34
+ >>> os.environ["AGENTFORCE_BYOC_MOCK"] = "1"
35
+ >>> from agentforce_byoc import get_client
36
+ >>> client = get_client()
37
+ >>> client.call_llm_generations(
38
+ ... parameter={"prompt": "What is AI?"},
39
+ ... )
40
+ """
41
+
42
+ def __init__(self):
43
+ """Initialize mock runtime provider."""
44
+ super().__init__()
45
+ self._relay_gateway_client = MockRelayGatewayClient()
46
+
47
+ @property
48
+ def name(self) -> str:
49
+ """Return runtime name."""
50
+ return "mock"
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2026, Salesforce, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """Schema utilities for Agentforce BYOC functions."""
17
+
18
+ from agentforce_byoc.schema_utils.entry_func import entry_func
19
+ from agentforce_byoc.schema_utils.generator import (
20
+ extract_entry_functions,
21
+ generate_openapi,
22
+ generate_schema,
23
+ generate_schema_yaml,
24
+ )
25
+ from agentforce_byoc.schema_utils.schema import requestSchema, responseSchema
26
+
27
+ __all__ = [
28
+ "entry_func",
29
+ "requestSchema",
30
+ "responseSchema",
31
+ "extract_entry_functions",
32
+ "generate_openapi",
33
+ "generate_schema",
34
+ "generate_schema_yaml",
35
+ ]
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2026, Salesforce, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from __future__ import annotations
17
+
18
+ import functools
19
+ from typing import Any, Callable, TypeVar
20
+
21
+ F = TypeVar("F", bound=Callable[..., Any])
22
+
23
+
24
+ def entry_func(fn: F) -> F:
25
+ """Mark a function as the BYOC entry point.
26
+
27
+ The ``@entry_func`` decorator identifies a function whose signature
28
+ will be extracted by ``generate_byoc_schema.py`` to produce an
29
+ OpenAPI specification. At runtime the decorator is a pass-through —
30
+ it returns the original function unchanged.
31
+
32
+ All parameters of the decorated function **must** have type
33
+ annotations; the schema generator will reject untyped parameters.
34
+
35
+ Example::
36
+
37
+ from agentforce_byoc.schema_utils.entry_func import entry_func
38
+
39
+ @entry_func
40
+ def add(a: int, b: int = 0) -> int:
41
+ return a + b
42
+ """
43
+
44
+ @functools.wraps(fn)
45
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
46
+ return fn(*args, **kwargs)
47
+
48
+ return wrapper # type: ignore[return-value]