Skip to content

fix: update website SDK examples to use init() API#1243

Merged
rohitg00 merged 3 commits intomainfrom
fix/website-use-init-api
Mar 6, 2026
Merged

fix: update website SDK examples to use init() API#1243
rohitg00 merged 3 commits intomainfrom
fix/website-use-init-api

Conversation

@rohitg00
Copy link
Contributor

@rohitg00 rohitg00 commented Mar 6, 2026

Summary

  • Replace III() / III::new() + connect() with init() across all website code examples to match the new SDK API from c1bb119
  • Update Python imports: from iii import IIIfrom iii import init
  • Update Rust imports: use iii_sdk::IIIuse iii_sdk::{init, InitOptions}
  • Update Rust trigger registration to match current SDK surface
  • Add init( to DependencyVisualization architecture line detection

Files changed

  • website/components/Terminal.tsx — Python/Rust SDK examples
  • website/components/MachineView.tsx — Python/Rust SDK code blocks
  • website/components/sections/AgentReadySection.tsx — All Python/Rust examples (4 blocks)
  • website/components/sections/HelloWorldSection.tsx — Python/Rust code snippets
  • website/components/sections/EngineSection.tsx — Discovery code snippets
  • website/components/sections/DependencyVisualization.tsx — Code highlighting logic

Test plan

  • Verify website renders correctly with updated code examples
  • Check all code blocks display proper syntax highlighting
  • Confirm no remaining III() / III::new() / iii.connect() patterns in website

Summary by CodeRabbit

  • Documentation
    • Updated code examples and docs with a unified init-based SDK initialization for Python, Rust, and TypeScript
    • Function identifiers now use dot notation (e.g., "users.create" instead of "users::create")
    • API endpoint paths standardized to include leading slashes (e.g., "/users")
    • Removed explicit connect/await steps in samples; initialization is streamlined across languages

- Replace III()/III::new() + connect() with init() across all website code examples
- Update Python imports from `from iii import III` to `from iii import init`
- Update Rust imports from `use iii_sdk::III` to `use iii_sdk::{init, InitOptions}`
- Update Rust trigger API to match current SDK surface
- Add init() to DependencyVisualization architecture line detection
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Documentation and embedded code samples were updated to use the new init-based SDK initialization pattern and to rename function/trigger identifiers from colon-separated (e.g., "users::create") to dot-separated form (e.g., "users.create"); HTTP trigger paths were normalized to include a leading slash (e.g., "/users").

Changes

Cohort / File(s) Summary
Machine & Terminal Samples
website/components/MachineView.tsx, website/components/Terminal.tsx
Replaced old API IDs ("users::create") with dot form ("users.create"); updated trigger api_path from "users" to "/users"; boot/init samples changed to use init(...) instead of constructor + connect.
Sectioned Examples (HelloWorld / Engine / AgentReady)
website/components/sections/HelloWorldSection.tsx, website/components/sections/EngineSection.tsx, website/components/sections/AgentReadySection.tsx
Updated multi-language examples (TypeScript, Python, Rust) to use init/InitOptions pattern, removed separate connect step, and renamed many function IDs from namespace::namenamespace.name (multiple capability IDs updated).
Dependency Visualization Logic
website/components/sections/DependencyVisualization.tsx
Line-classification logic: added detection for init( as an architecture keyword so lines with init( are treated as architecture-level code for highlighting/categorization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Iii docs migration #1233: Modifies the same SDK initialization and identifier conventions (init/InitOptions, dot-separated function IDs, and HTTP path formatting) reflected in these documentation/code-sample changes.

Suggested reviewers

  • sergiofilhowz

Poem

🐰 From constructor to init I hop with glee,
Dots replace colons — tidy as can be.
Samples refreshed, the docs now hum,
A rabbit's cheer for the changes done! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: update website SDK examples to use init() API' directly describes the main change: updating website code examples to use the init() API instead of III/III::new + connect pattern.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/website-use-init-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
website/components/MachineView.tsx (1)

78-91: ⚠️ Potential issue | 🟡 Minor

Inconsistent function ID format and API path between TypeScript and Python/Rust examples.

The Python and Rust sections were updated to use users.create (dot separator) and "/users" (leading slash), but the TypeScript section still uses users::create (double-colon) and "users" (no slash). This creates inconsistency in the SDK documentation.

Suggested fix to align TypeScript with Python/Rust
 iii.registerFunction(
-  { id: "users::create" },
+  { id: "users.create" },
   async (input) => {
     const { logger } = getContext()
     logger.info("Creating user", { email: input.email })
     return { id: "123", email: input.email }
   }
 )

 iii.registerTrigger({
   type: "http",
-  function_id: "users::create",
-  config: { api_path: "users", http_method: "POST" }
+  function_id: "users.create",
+  config: { api_path: "/users", http_method: "POST" }
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/MachineView.tsx` around lines 78 - 91, The TypeScript
example uses an inconsistent function id and API path; update
iii.registerFunction to use id: "users.create" (dot separator) and update the
trigger config to use config.api_path: "/users" (leading slash) and ensure
function_id in iii.registerTrigger matches "users.create" so the TypeScript
snippet aligns with the Python/Rust examples; locate the usage via
iii.registerFunction and iii.registerTrigger and adjust the id, function_id, and
config.api_path values accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 90-98: The function ID used across language examples must be
consistent; update the TypeScript example that currently uses "agent::research"
to use "agent.research" so it matches the Python
(iii.register_function("agent.research", research_handler)) and Rust
(RegisterFunctionInput { id: "agent.research" ... }) examples; locate the
TypeScript tab containing the string "agent::research" and replace it with
"agent.research" to ensure all three tabs show the same function ID.
- Around line 292-293: The TypeScript sample's subscription name must match the
renamed Python worker; update the TS polyglot flow to use the dot-form function
IDs (e.g., "ml.onboarding" and "ml.recommend") to match the Python registrations
(iii.register_function("ml.onboarding", predict_handler) and
iii.register_function("ml.recommend", recommend_handler)), or alternatively
rename the Python registrations back to the double-colon form ("ml::onboarding",
"ml::recommend") so both sides use the same identifier; locate the TS
subscription code for the onboarding/recommend capability and make the
identifier consistent with the Python side.
- Around line 74-76: Add "import os" to the Python code examples that reference
os.environ.get so they don't raise NameError when copied; locate the snippets
using the symbols shown (python: `from iii import init, get_context` and `iii =
init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))`) in
AgentReadySection.tsx and prepend or include `import os` in those blocks so os
is defined.

In `@website/components/sections/HelloWorldSection.tsx`:
- Line 38: The registered worker names were changed to dot notation
("ml.predict" and "data.transform") but the trigger calls still use the old
double-colon form ("ml::predict" and "data::transform"); update the
trigger/invocation strings to match the registered names so all snippets use
"ml.predict" and "data.transform" consistently (search for occurrences of
"ml::predict" and "data::transform" and replace them with "ml.predict" and
"data.transform", ensuring the registered functions like predict and transform
remain referenced correctly).

In `@website/components/Terminal.tsx`:
- Around line 311-312: The Rust snippet logged in Terminal.tsx calls init and
InitOptions but omits the required import; update the snippet where
addLog("Rust:", "warning") and addLog('let iii = init("ws://127.0.0.1:49134",
InitOptions::default())?;', "success") are added to include the proper import
(matching other examples that import from iii_sdk) so the snippet is
copy-pasteable—add the appropriate use/import line for init and InitOptions
before the init call.

---

Outside diff comments:
In `@website/components/MachineView.tsx`:
- Around line 78-91: The TypeScript example uses an inconsistent function id and
API path; update iii.registerFunction to use id: "users.create" (dot separator)
and update the trigger config to use config.api_path: "/users" (leading slash)
and ensure function_id in iii.registerTrigger matches "users.create" so the
TypeScript snippet aligns with the Python/Rust examples; locate the usage via
iii.registerFunction and iii.registerTrigger and adjust the id, function_id, and
config.api_path values accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 993d15b3-914c-4264-a145-b1a975237e47

📥 Commits

Reviewing files that changed from the base of the PR and between 8e84661 and 990f434.

📒 Files selected for processing (6)
  • website/components/MachineView.tsx
  • website/components/Terminal.tsx
  • website/components/sections/AgentReadySection.tsx
  • website/components/sections/DependencyVisualization.tsx
  • website/components/sections/EngineSection.tsx
  • website/components/sections/HelloWorldSection.tsx

Comment on lines +74 to +76
python: `from iii import init, get_context

iii = III(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))
await iii.connect()
iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the file exists and get its line count
wc -l website/components/sections/AgentReadySection.tsx

Repository: MotiaDev/motia

Length of output: 112


🏁 Script executed:

#!/bin/bash
# Run the verification script provided in the review
python - <<'PY'
from pathlib import Path

text = Path("website/components/sections/AgentReadySection.tsx").read_text()
for idx, block in enumerate(text.split('python: `')[1:], 1):
    snippet = block.split('`', 1)[0]
    if 'os.environ.get("III_BRIDGE_URL"' in snippet:
        print(f"python snippet {idx}: import os present ->", 'import os' in snippet)
PY

Repository: MotiaDev/motia

Length of output: 147


🏁 Script executed:

#!/bin/bash
# Read lines 70-80 to see context around line 74-76
sed -n '70,80p' website/components/sections/AgentReadySection.tsx

Repository: MotiaDev/motia

Length of output: 319


🏁 Script executed:

#!/bin/bash
# Read lines 273-283 to see context around line 277-279
sed -n '273,283p' website/components/sections/AgentReadySection.tsx

Repository: MotiaDev/motia

Length of output: 380


Add import os to the updated Python snippets.

Both snippets at lines 74-76 and 277-279 call os.environ.get("III_BRIDGE_URL", ...) without importing os, causing a NameError when copied and executed.

Proposed fix
-      python: `from iii import init, get_context
+      python: `import os
+from iii import init, get_context
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python: `from iii import init, get_context
iii = III(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))
await iii.connect()
iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))
python: `import os
from iii import init, get_context
iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/sections/AgentReadySection.tsx` around lines 74 - 76, Add
"import os" to the Python code examples that reference os.environ.get so they
don't raise NameError when copied; locate the snippets using the symbols shown
(python: `from iii import init, get_context` and `iii =
init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))`) in
AgentReadySection.tsx and prepend or include `import os` in those blocks so os
is defined.

Comment on lines 311 to +312
addLog("Rust:", "warning");
addLog('let iii = III::new("ws://127.0.0.1:49134");', "success");
addLog("iii.connect().await?;", "success");
addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success");
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's read the relevant section of Terminal.tsx around lines 311-312
sed -n '305,320p' website/components/Terminal.tsx

Repository: MotiaDev/motia

Length of output: 712


🏁 Script executed:

# Also check the Python snippet mentioned around lines 308-309 for context
sed -n '300,330p' website/components/Terminal.tsx

Repository: MotiaDev/motia

Length of output: 1399


🏁 Script executed:

# Search for other Rust import examples in this file to see the pattern
rg -A 2 "use iii_sdk" website/components/Terminal.tsx

Repository: MotiaDev/motia

Length of output: 40


🏁 Script executed:

# Search for iii_sdk references in the entire codebase to understand the library structure
rg "iii_sdk" --type rust --type ts --type js

Repository: MotiaDev/motia

Length of output: 8836


🏁 Script executed:

# Check if there's documentation or examples of iii_sdk usage
fd -e md -e txt -e rs | head -20 | xargs grep -l "iii_sdk" 2>/dev/null || echo "No matches in docs"

Repository: MotiaDev/motia

Length of output: 292


🏁 Script executed:

# Look for package.json or Cargo.toml to understand project dependencies
fd -e "Cargo.toml|package.json" | head -5 | xargs cat

Repository: MotiaDev/motia

Length of output: 40


🌐 Web query:

iii_sdk Rust crate init InitOptions

💡 Result:

The iii-sdk Rust crate (iii_sdk) does not have an init module with an InitOptions type in the current upstream repo/docs. The primary “init” pattern is:

  • Create the client with III::new(ws_url) and then iii.connect().await? before registering/calling functions. [1]
  • If you meant OpenTelemetry initialization, the crate exposes telemetry::init_otel(config: OtelConfig) (called once at startup; subsequent calls are no-ops). OtelConfig is the options/config struct you customize (service name, engine WS URL, metrics/logs toggles, reconnection config, etc.). [2][3]

Sources: [1][2][3]


Add the missing Rust import to keep this snippet copy-pasteable.

The Rust snippet uses init and InitOptions without importing them, making the code non-functional. The Python example above includes from iii import init, and other examples throughout the codebase (AgentReadySection.tsx, HelloWorldSection.tsx, MachineView.tsx) consistently import from iii_sdk. This snippet needs the same treatment.

Suggested fix
        addLog("Rust:", "warning");
+       addLog("use iii_sdk::{init, InitOptions};", "success");
        addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
addLog("Rust:", "warning");
addLog('let iii = III::new("ws://127.0.0.1:49134");', "success");
addLog("iii.connect().await?;", "success");
addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success");
addLog("Rust:", "warning");
addLog("use iii_sdk::{init, InitOptions};", "success");
addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/Terminal.tsx` around lines 311 - 312, The Rust snippet
logged in Terminal.tsx calls init and InitOptions but omits the required import;
update the snippet where addLog("Rust:", "warning") and addLog('let iii =
init("ws://127.0.0.1:49134", InitOptions::default())?;', "success") are added to
include the proper import (matching other examples that import from iii_sdk) so
the snippet is copy-pasteable—add the appropriate use/import line for init and
InitOptions before the init call.

- Update TS function IDs from :: to . notation to match Python/Rust
- Add leading / to api_path in TS trigger configs
- Fixes cross-tab inconsistencies in AgentReadySection, HelloWorldSection, MachineView
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
website/components/sections/AgentReadySection.tsx (1)

58-69: ⚠️ Potential issue | 🟠 Major

Change response from const to let to allow reassignment in the loop.

Line 61 declares response as const, but line 69 reassigns it. This is a TypeScript error—const variables cannot be reassigned.

Suggested fix
-    const response = await callLLM(query, { tools })
+    let response = await callLLM(query, { tools })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/sections/AgentReadySection.tsx` around lines 58 - 69, The
variable response inside the iii.registerFunction handler is declared as const
but later reassigned in the while loop; change its declaration to let so it can
be updated. Locate the handler registered by iii.registerFunction (id
"agent.research") where response is assigned from callLLM(query, { tools }) and
update that declaration to let; keep the rest of the logic (the while
(response.toolCall) loop, calls to iii.trigger and subsequent callLLM)
unchanged.
♻️ Duplicate comments (1)
website/components/sections/AgentReadySection.tsx (1)

74-76: ⚠️ Potential issue | 🟠 Major

Import os before using os.environ in both Python snippets.

Lines 76 and 279 call os.environ.get(...), but neither snippet imports os, so both examples fail immediately with NameError.

Suggested fix
-      python: `from iii import init, get_context
+      python: `import os
+from iii import init, get_context
...
-      python: `from iii import init, get_context
+      python: `import os
+from iii import init, get_context

Also applies to: 277-279

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/sections/AgentReadySection.tsx` around lines 74 - 76, The
Python examples that call os.environ.get(...) are missing the os import and will
raise NameError; update both inline snippets in AgentReadySection.tsx (the
snippet starting with "python: `from iii import init, get_context" and the later
snippet around the second os.environ.get usage) to include an import os line
(i.e., add "import os" before using os.environ.get) so the examples run
correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 91-98: The Rust example fails to compile because
RegisterFunctionInput is used but not imported; update the import at the top of
the snippet (the use iii_sdk::{init, InitOptions, get_context}; line) to also
include RegisterFunctionInput so that the subsequent call to
iii.register_function(RegisterFunctionInput { ... }) is valid and the example
compiles.

---

Outside diff comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 58-69: The variable response inside the iii.registerFunction
handler is declared as const but later reassigned in the while loop; change its
declaration to let so it can be updated. Locate the handler registered by
iii.registerFunction (id "agent.research") where response is assigned from
callLLM(query, { tools }) and update that declaration to let; keep the rest of
the logic (the while (response.toolCall) loop, calls to iii.trigger and
subsequent callLLM) unchanged.

---

Duplicate comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 74-76: The Python examples that call os.environ.get(...) are
missing the os import and will raise NameError; update both inline snippets in
AgentReadySection.tsx (the snippet starting with "python: `from iii import init,
get_context" and the later snippet around the second os.environ.get usage) to
include an import os line (i.e., add "import os" before using os.environ.get) so
the examples run correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7acb935-4b42-47e6-9c62-0c8b62033fa2

📥 Commits

Reviewing files that changed from the base of the PR and between 990f434 and 7da02e5.

📒 Files selected for processing (3)
  • website/components/MachineView.tsx
  • website/components/sections/AgentReadySection.tsx
  • website/components/sections/HelloWorldSection.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/components/MachineView.tsx

Comment on lines +91 to +98
rust: `use iii_sdk::{init, InitOptions, get_context};

let iii = III::new("ws://localhost:49134");
iii.connect().await?;
let iii = init("ws://localhost:49134", InitOptions::default())?;
let logger = get_context().logger;
let tools = iii.list_functions().await?;

iii.register_function(
RegisterFunctionInput { id: "agent::research".into(), ..Default::default() },
RegisterFunctionInput { id: "agent.research".into(), ..Default::default() },
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n website/components/sections/AgentReadySection.tsx | sed -n '85,105p'

Repository: MotiaDev/motia

Length of output: 1160


Add RegisterFunctionInput to the Rust example's import statement.

Line 98 uses RegisterFunctionInput, but line 91 does not import it. As written, the sample code does not compile.

Suggested fix
-      rust: `use iii_sdk::{init, InitOptions, get_context};
+      rust: `use iii_sdk::{get_context, init, InitOptions, RegisterFunctionInput};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@website/components/sections/AgentReadySection.tsx` around lines 91 - 98, The
Rust example fails to compile because RegisterFunctionInput is used but not
imported; update the import at the top of the snippet (the use iii_sdk::{init,
InitOptions, get_context}; line) to also include RegisterFunctionInput so that
the subsequent call to iii.register_function(RegisterFunctionInput { ... }) is
valid and the example compiles.

@rohitg00 rohitg00 merged commit 1e4abce into main Mar 6, 2026
7 checks passed
@rohitg00 rohitg00 deleted the fix/website-use-init-api branch March 6, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants