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.4.0.tar.gz (32.9 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.4.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: linkworld_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 32.9 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.4.0.tar.gz
Algorithm Hash digest
SHA256 428df99e2ddfe0cdccbb05c358b06c4894c472ef2460a2275d99b9a9713a452e
MD5 fe49809c4479333b6e04e434a85c8b26
BLAKE2b-256 3d2ca052fae87b0912723760a13182121567525f25fdef69ae4a64d46a8b8a0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: linkworld_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caec457e53bb3ddef95bb4b556c95ab674a909e8a0543920facc25f4b75d95e3
MD5 dfea9c2b1b909d9a81aae7c662838e62
BLAKE2b-256 9cf9a363c1f3b928d9b664d22cdc52514ba0b8caa695c9c22533a3a54e43912b

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