Skip to main content

Build apps for the Linkworld Open App Platform

Project description

linkworld-sdk

Python SDK for building apps on the Linkworld Open App Platform.

Status: 0.x alpha. Phase 2 of the open-platform rollout. Decorator API is stable; production runtime (MCP-based dispatch) lands with platform Milestone 5. Until then, run apps in local mode to develop against the SDK, then deploy once the platform side is online.

Install

pip install linkworld-sdk

60-second tour

from linkworld_sdk import App

app = App.from_manifest("linkworld.app.yaml")

@app.on_inbound
async def handle(ctx, env):
    await ctx.tools.call(
        "email_send",
        to="ops@example.com",
        subject="Inbound!",
        body=f"From {env.user_id}: {env.message_text}",
    )

if __name__ == "__main__":
    app.run()

The matching manifest:

apiVersion: linkworld.ai/v2
app_id: my-app
version: 0.1.0
name: My App
required_scopes: [mail.send]
runtime:
  image: ghcr.io/your-org/my-app:0.1.0
lifecycle:
  on_inbound: true

Local development

LINKWORLD_LOCAL=1 python main.py

This starts a trigger HTTP server you can curl to simulate any platform event. Tools are mocked — ctx.tools.call(...) records the call and returns whatever you wired with MockTools.

See examples/hello-world/ for a runnable walkthrough.

Testing your app

import pytest
from linkworld_sdk.testing import TestClient
from my_app import app

@pytest.fixture
def client():
    return TestClient(app)

async def test_echo(client):
    client.tools.set_response("email_send", {"sent": True})
    await client.simulate_inbound(
        tenant_id="t1", user_id="u1", message_text="hello"
    )
    assert client.tools.calls[0][0] == "email_send"
    assert client.tools.calls[0][1]["body"] == "From u1: hello"

Decorator API

Decorator Receives When
@app.on_inbound (ctx, env) Tenant got an inbound message and opted into fan-out
@app.on_install (ctx) Tenant activated the app
@app.on_uninstall (ctx) Tenant deactivated the app
@app.on_user_added (ctx, user) New user joined the tenant
@app.on_schedule(name) (ctx) Cron entry from lifecycle.schedules[name] fires
@app.tool(name, ...) (ctx, **args) Custom tool exposed to tenant agents

Every handler receives a Context:

ctx.tenant_id        # UUID of the tenant
ctx.user_id          # UUID of the originating user, or None
ctx.app_id           # this app's slug
ctx.event_type       # 'inbound', 'schedule', 'install', etc.
ctx.tools            # ctx.tools.call("tool_name", **args)
ctx.secrets          # await ctx.secrets.get("KEY")
ctx.logger           # structlog-compatible logger

Manifest schema

The full schema lives at packages/sdk-spec/manifest-v2.schema.yaml. Validate locally with linkworld_sdk.load_manifest("linkworld.app.yaml").

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkworld_sdk-0.1.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linkworld_sdk-0.1.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file linkworld_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: linkworld_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for linkworld_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 355d89987fba41ad8202e56cce516795178355e9baa7f59a24651e43b71840ed
MD5 3348828b1e5c4daab1b639fdce306509
BLAKE2b-256 00bc4ce23fe2ab8f7162a00c228fdc7b1d5cfd1771abbde40008a1b461d3c2c2

See more details on using hashes here.

File details

Details for the file linkworld_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: linkworld_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for linkworld_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6982294002b8c6c7a38d529fd4956b26984033998d3e607372693b54a436ae46
MD5 e46392fc7d2403a667391ecea4e2ae51
BLAKE2b-256 63397305526b7d1f2d408a397b78aee41339c63ed56ae47e0e3e0e8dcb657d17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page