### Example GET Request with Query Parameters Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md Provides examples of constructing GET requests using query parameters for filtering and pagination, and for retrieving specific task details including history. ```http GET /tasks?contextId=uuid&status=working&pageSize=50&pageToken=cursor ``` ```http GET /tasks/{id}?historyLength=10 ``` -------------------------------- ### Install LAFS Protocol Package Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/getting-started/quickstart.md Installs the LAFS protocol package using npm. This is a prerequisite for using the library in your Node.js project. ```bash npm install @cleocode/lafs-protocol ``` -------------------------------- ### Example Extension Activation Request and Response Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/extensions.md Provides concrete HTTP request and response examples demonstrating the activation of an extension using the `A2A-Extensions` header. ```APIDOC ### Example Request showing extension activation: ```http POST /agents/eightball HTTP/1.1 Host: example.com Content-Type: application/json A2A-Extensions: https://example.com/ext/konami-code/v1 Content-Length: 519 { "jsonrpc": "2.0", "method": "SendMessage", "id": "1", "params": { "message": { "messageId": "1", "role": "ROLE_USER", "parts": [{"text": "Oh magic 8-ball, will it rain today?"}] }, "metadata": { "https://example.com/ext/konami-code/v1/code": "motherlode" } } } ``` ### Corresponding response echoing activated extensions: ```http HTTP/1.1 200 OK Content-Type: application/json A2A-Extensions: https://example.com/ext/konami-code/v1 Content-Length: 338 { "jsonrpc": "2.0", "id": "1", "result": { "message": { "messageId": "2", "role": "ROLE_AGENT", "parts": [{"text": "That's a bingo!"}] } } } ``` ``` -------------------------------- ### LAFS Version Negotiation Request Example (HTTP) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/agent-discovery-v1.md Demonstrates a client sending a GET request to the tasks endpoint, specifying the desired LAFS protocol version via the 'X-LAFS-Version' header. The server responds with a 200 OK and the negotiated version. ```http GET /lafs/v1/tasks HTTP/1.1 Host: api.example.com X-LAFS-Version: 1.0.0 X-API-Key: secret_key_here Accept: application/json ``` -------------------------------- ### Basic Discovery Request and Response (HTTP) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/agent-discovery-v1.md Provides an example of a basic HTTP GET request to the discovery endpoint and a corresponding 200 OK response. The response includes essential discovery document information like service details, capabilities, endpoints, caching policies, and security settings. ```http GET /.well-known/lafs.json HTTP/1.1 Host: api.example.com Accept: application/json --- HTTP/1.1 200 OK Content-Type: application/json ETag: "v1-abc123" Cache-Control: max-age=3600, public Last-Modified: Mon, 16 Feb 2026 10:00:00 GMT Content-Length: 892 { "$schema": "https://lafs.dev/schemas/v1/discovery.schema.json", "lafs_version": "1.0.0", "service": { "name": "example-api", "version": "1.0.0" }, "capabilities": { "protocol": { "versions_supported": ["1.0.0"], "version_negotiation": "header" }, "features": { "mvi_levels": ["standard", "full"], "pagination_modes": ["cursor"], "strict_mode": true, "context_ledger": false, "field_selection": true, "expansion": false, "budgets": { "supported": false, "types": [] } } }, "endpoints": { "base_url": "https://api.example.com", "envelope_endpoint": "/lafs/v1" }, "caching": { "ttl_seconds": 3600, "etag": "v1-abc123", "immutable": false }, "security": { "discovery_public": true, "auth_required": true, "schemes": [ { "type": "apiKey", "description": "API key in X-API-Key header" } ] } } ``` -------------------------------- ### Run LAFS Conformance Checks via CLI Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/CONFORMANCE.md Provides examples of using the `lafs-conformance` command-line tool to check the conformance of LAFS envelopes and flags. It illustrates basic usage with envelope and flag files, as well as combined checks. ```bash lafs-conformance --envelope ./fixtures/valid-success-envelope.json lafs-conformance --flags ./fixtures/flags-valid.json lafs-conformance --envelope ./fixtures/valid-success-envelope.json --flags ./fixtures/flags-valid.json ``` -------------------------------- ### Install LAFS Protocol Python SDK Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/python/README.md Instructions for installing the LAFS Protocol Python SDK using pip, including installation from source. ```bash pip install lafs-protocol ``` ```bash cd python pip install -e . ``` -------------------------------- ### Streaming Task Execution Request Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md An example HTTP POST request for initiating a long-running task with streaming updates using the A2A protocol. The request includes a user message to start the process. ```http POST /message:stream HTTP/1.1 Host: agent.example.com Content-Type: application/a2a+json Authorization: Bearer token { "message": { "role": "ROLE_USER", "parts": [{"text": "Write a detailed report on climate change"}], "messageId": "msg-uuid" } } ``` -------------------------------- ### LAFS Discovery Minimal Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/agent-discovery-v1.md A minimal configuration example for the LAFS Discovery Schema, showcasing essential service details, protocol versions, basic features, and endpoint information. ```json { "$schema": "https://lafs.dev/schemas/v1/discovery.schema.json", "lafs_version": "1.0.0", "service": { "name": "task-service", "version": "2.3.1" }, "capabilities": { "protocol": { "versions_supported": ["1.0.0"], "version_negotiation": "header" }, "features": { "mvi_levels": ["minimal", "standard", "full"], "pagination_modes": ["cursor", "offset"], "strict_mode": true, "context_ledger": true, "field_selection": true, "expansion": true, "budgets": { "supported": true, "types": ["token"] } } }, "endpoints": { "base_url": "https://api.example.com", "envelope_endpoint": "/v1/lafs" }, "caching": { "ttl_seconds": 3600, "immutable": false } } ``` -------------------------------- ### Automate LAFS Conformance Checks in CI (Bash) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/CONFORMANCE.md Shows a common pattern for integrating LAFS conformance checks into a Continuous Integration (CI) pipeline using a bash script. This example iterates through all valid envelope JSON files in the `fixtures` directory and runs the `lafs-conformance` tool on each. ```bash for file in fixtures/valid-*.json; do lafs-conformance --envelope "$file" done ``` -------------------------------- ### JSON Example: Vendor Extension Object (_extensions) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/migrations/v0.3.0-to-v0.4.0.md Demonstrates the structure of the `_extensions` object, used for vendor-specific metadata outside the LAFS protocol scope. Keys should ideally use the 'x-' prefix. This field is optional and does not affect protocol-required behavior. ```json { "_extensions": { "x-myvendor-trace-id": "trace_abc123", "x-myvendor-region": "eu-west-1", "x-billing-cost-units": 15 } } ``` -------------------------------- ### LAFS Discovery Full Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/agent-discovery-v1.md A comprehensive example of the LAFS Discovery Schema, including detailed service information, extended capabilities, specific operation endpoints, caching details, and security schemes. ```json { "$schema": "https://lafs.dev/schemas/v1/discovery.schema.json", "lafs_version": "1.0.0", "service": { "name": "cleo-task-platform", "version": "3.0.0", "description": "Multi-agent task management platform with LAFS support", "provider": { "name": "CLEO Labs", "url": "https://cleo.dev" } }, "capabilities": { "protocol": { "versions_supported": ["1.0.0", "0.5.0"], "version_negotiation": "header" }, "features": { "mvi_levels": ["minimal", "standard", "full", "custom"], "pagination_modes": ["cursor", "offset", "none"], "strict_mode": true, "context_ledger": true, "field_selection": true, "expansion": true, "budgets": { "supported": true, "types": ["token", "time"] } } }, "endpoints": { "base_url": "https://tasks.cleo.dev", "envelope_endpoint": "/api/v1/envelope", "operations": { "tasks.list": "/api/v1/tasks", "tasks.get": "/api/v1/tasks/{id}", "tasks.create": "/api/v1/tasks", "tasks.update": "/api/v1/tasks/{id}", "tasks.delete": "/api/v1/tasks/{id}", "context.get": "/api/v1/context/{id}", "context.update": "/api/v1/context/{id}" }, "documentation_url": "https://docs.cleo.dev/lafs" }, "caching": { "ttl_seconds": 86400, "etag": "W/\"3.0.0-abc123\"", "immutable": true }, "security": { "discovery_public": true, "auth_required": true, "schemes": [ { "type": "apiKey", "description": "API key in X-API-Key header" }, { "type": "oauth2", "description": "OAuth 2.0 with client credentials flow" } ] }, "_extensions": { "x-cleo-rate-limit": "1000/hour", "x-cleo-support": "https://support.cleo.dev" } } ``` -------------------------------- ### Quick Start with LAFSClient Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/python/README.md Demonstrates basic usage of the LAFSClient to connect to an API, discover capabilities, make a simple call, and make a call with budget constraints. ```python from lafs_protocol import LAFSClient # Create client client = LAFSClient("https://api.example.com") # Discover capabilities discovery = client.discover() print(f"Service: {discovery.service['name']}") print(f"Supports budgets: {discovery.supports_budget()}") # Make API call response = client.call("tasks.list") print(response.result) # Call with budget constraints response = client.call_with_budget( "tasks.list", max_tokens=1000, max_items=10 ) ``` -------------------------------- ### Install LAFS Protocol Dependencies Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md Installs the core LAFS protocol package and optional dependencies for A2A integration and monitoring using npm. ```bash # Core package npm install @cleocode/lafs-protocol # For A2A integration npm install @a2a-js/sdk # For monitoring (optional) npm install prom-client ``` -------------------------------- ### Task Listing: Pagination Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md Illustrates how to use pagination tokens to retrieve subsequent pages of task results. This is essential for handling large numbers of tasks. ```http POST /tasks/list HTTP/1.1 Host: agent.example.com Content-Type: application/a2a+json Authorization: Bearer token { "contextId": "c295ea44-7543-4f78-b524-7a38915ad6e4", "pageSize": 10, "pageToken": "base64-encoded-cursor-token" } ``` ```http HTTP/1.1 200 OK Content-Type: application/a2a+json { "tasks": [ /* ... additional tasks */ ], "totalSize": 15, "pageSize": 10, "nextPageToken": "base64-encoded-next-cursor-token" } ``` -------------------------------- ### Example Agent Card with Extension (JSON) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/extensions.md This JSON example demonstrates an Agent Card that includes an extension. It shows how the 'extensions' array within 'capabilities' is populated with details like 'uri', 'description', 'required' status, and 'params'. ```json { "name": "Magic 8-ball", "description": "An agent that can tell your future... maybe.", "version": "0.1.0", "url": "https://example.com/agents/eightball", "capabilities": { "streaming": true, "extensions": [ { "uri": "https://example.com/ext/konami-code/v1", "description": "Provide cheat codes to unlock new fortunes", "required": false, "params": { "hints": [ "When your sims need extra cash fast", "You might deny it, but we've seen the evidence of those cows." ] } } ] }, "defaultInputModes": ["text/plain"], "defaultOutputModes": ["text/plain"], "skills": [ { "id": "fortune", "name": "Fortune teller", "description": "Seek advice from the mystical magic 8-ball", "tags": ["mystical", "untrustworthy"] } ] } ``` -------------------------------- ### HTTP GET Request for LAFS Context (Full Mode) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/context-projection-modes.md Example HTTP GET request to retrieve the full context of a workflow from the LAFS ledger. It includes authorization headers and specifies the desired response format. ```http GET /_lafs/context/workflow_abc?mode=full&limit=50 HTTP/1.1 Authorization: Bearer {token} Accept: application/json ``` -------------------------------- ### Field Selection Example (HTTP Request) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/context-query-v1.md An example HTTP GET request illustrating field selection in summary mode. This enables lightweight responses by specifying desired fields using the 'fields' parameter. ```http GET /_lafs/context/ctx_abc123?mode=summary&fields=version,checksum,updatedAt ``` -------------------------------- ### Token Budget Declaration (`_budget`) JSON Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/specification.md Provides a JSON example for the `_budget` request parameter, used by clients to declare resource constraints like `maxTokens`, `maxBytes`, and `maxItems`. These values must be positive integers. ```json { "_budget": { "maxTokens": 4000, "maxBytes": 32768, "maxItems": 100 } } ``` -------------------------------- ### Operation Filtering Example (HTTP Request) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/context-query-v1.md An example HTTP GET request demonstrating operation filtering in the LAFS protocol. This allows filtering ledger entries by their operation type, supporting OR logic, wildcards, and negation. ```http GET /_lafs/context/ctx_abc123?mode=delta&sinceVersion=40&filterByOperation=decision.record,constraint.add ``` -------------------------------- ### Task Listing: All working tasks across all contexts Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md Demonstrates how to retrieve a list of all tasks that are currently in a 'working' state, regardless of their context. This is useful for monitoring ongoing operations. ```http POST /tasks/list HTTP/1.1 Host: agent.example.com Content-Type: application/a2a+json Authorization: Bearer token { "status": "TASK_STATE_WORKING", "pageSize": 20 } ``` ```http HTTP/1.1 200 OK Content-Type: application/a2a+json { "tasks": [ { "id": "789abc-def0-1234-5678-9abcdef01234", "contextId": "another-context-id", "status": { "state": "TASK_STATE_WORKING", "message": { "role": "ROLE_AGENT", "parts": [ { "text": "Processing your document analysis..." } ], "messageId": "msg-status-update" }, "timestamp": "2024-03-15T10:20:00Z" } } ], "totalSize": 1, "pageSize": 20, "nextPageToken": "" } ``` -------------------------------- ### Parse LAFS Responses (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/getting-started/quickstart.md Illustrates how to parse a LAFS response using `parseLafsResponse`, including handling potential `LafsError` exceptions for detailed error reporting. ```typescript import { LafsError, parseLafsResponse } from "@cleocode/lafs-protocol"; try { const result = parseLafsResponse<{ message: string }>(envelope); console.log(result.message); } catch (error) { if (error instanceof LafsError) { console.error(error.code, error.message, error.retryable); } } ``` -------------------------------- ### HTTP Request with Extension Activation (HTTP) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/extensions.md This HTTP request example shows how a client activates an extension by including the 'A2A-Extensions' header with a comma-separated list of extension URIs. It also demonstrates passing extension-specific parameters in the request body's 'metadata' field. ```http POST /agents/eightball HTTP/1.1 Host: example.com Content-Type: application/json A2A-Extensions: https://example.com/ext/konami-code/v1 Content-Length: 519 { "jsonrpc": "2.0", "method": "SendMessage", "id": "1", "params": { "message": { "messageId": "1", "role": "ROLE_USER", "parts": [{"text": "Oh magic 8-ball, will it rain today?"}] }, "metadata": { "https://example.com/ext/konami-code/v1/code": "motherlode" } } } ``` -------------------------------- ### Wrap MCP Results with LAFS (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/getting-started/quickstart.md Provides a utility function `wrapMCPResult` to wrap MCP `CallToolResult` objects into a LAFS envelope, ensuring consistent output format. ```typescript import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { wrapMCPResult } from "@cleocode/lafs-protocol"; function toLafs(result: CallToolResult, toolName: string) { return wrapMCPResult(result, `tools/${toolName}`); } ``` -------------------------------- ### SDK Version Negotiation with Agent Card Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/whats-new-v1.md Demonstrates how an SDK can connect to an agent by negotiating the protocol version based on the Agent Card's supported interfaces. It finds the best matching interface from the agent's supported versions and creates a version-specific adapter. This pattern allows SDKs to maintain support for multiple protocol versions. ```typescript class A2AClient { async connect(agentCardUrl: string) { const card = await this.getAgentCard(agentCardUrl); // Find best matching interface const interface = card.supportedInterfaces.find(i => this.supportedVersions.includes(i.protocolVersion) ); if (!interface) { throw new Error("No compatible protocol version"); } // Use version-specific adapter return this.createAdapter(interface.protocolVersion, interface); } } ``` -------------------------------- ### OAuth 2.0 Flow Migration Example (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/whats-new-v1.md Demonstrates the migration from the deprecated Implicit OAuth Flow in v0.3.0 to the recommended Authorization Code Flow with PKCE in v1.0. This highlights the removal of 'implicitFlow' and the addition of 'pkceRequired' for enhanced security. ```typescript // v0.3.0 - Implicit Flow (now removed) { "implicitFlow": { "authorizationUrl": "https://auth.example.com/authorize", "scopes": {"read": "Read access"} } } ``` ```typescript // v1.0 - Use Authorization Code + PKCE instead { "authorizationCodeFlow": { "authorizationUrl": "https://auth.example.com/authorize", "tokenUrl": "https://auth.example.com/token", "pkceRequired": true, "scopes": {"read": "Read access"} } } ``` -------------------------------- ### LAFS Health Check Response Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md Illustrates the JSON response structure for the LAFS health check endpoint. It includes status, timestamp, version, details of internal checks, and service uptime. ```json { "status": "healthy", "timestamp": "2026-02-16T10:00:00Z", "version": "1.1.0", "checks": { "envelopeValidation": "ok", "tokenBudgets": "ok", "schemaValidation": "ok" }, "uptime": 3600 } ``` -------------------------------- ### Run LAFS Envelope Conformance Checks (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/getting-started/quickstart.md Shows how to run semantic conformance checks on a LAFS envelope using `runEnvelopeConformance`. It iterates through the report to log any failed checks. ```typescript import { runEnvelopeConformance } from "@cleocode/lafs-protocol"; const report = runEnvelopeConformance(envelope); if (!report.ok) { for (const check of report.checks) { if (!check.pass) { console.error(`${check.name}: ${check.detail ?? "failed"}`); } } } ``` -------------------------------- ### Dockerize LAFS Standalone REST API Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md Creates a Docker image for the LAFS standalone REST API. It installs production dependencies, copies application code, builds the project, and exposes the application port. ```dockerfile FROM node:20-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . RUN npm run build EXPOSE 3000 USER node CMD ["node", "dist/server.js"] ``` -------------------------------- ### Expose Prometheus Metrics Endpoint (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md This snippet demonstrates how to expose Prometheus metrics from the LAFS application at the '/metrics' endpoint. It uses the 'prom-client' library to register and serve metrics. Ensure 'prom-client' is installed as a dependency. ```typescript import { register } from 'prom-client'; // Add metrics endpoint app.get('/metrics', async (req, res) => { res.set('Content-Type', register.contentType); res.end(await register.metrics()); }); ``` -------------------------------- ### Create and Validate a LAFS Envelope (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/getting-started/quickstart.md Demonstrates how to create a new LAFS envelope with success status, result data, and metadata, and then validate its structure and content using the `createEnvelope` and `validateEnvelope` functions. ```typescript import { createEnvelope, validateEnvelope } from "@cleocode/lafs-protocol"; const envelope = createEnvelope({ success: true, result: { message: "Hello from LAFS", timestamp: new Date().toISOString(), }, meta: { operation: "hello.world", requestId: "req_001", transport: "http", }, }); const validation = validateEnvelope(envelope); console.log("valid", validation.valid, validation.errors); ``` -------------------------------- ### Run LAFS Conformance CLI with installed binary Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/sdk/cli.md These commands demonstrate how to run the installed lafs-conformance binary with different combinations of envelope and flags JSON inputs. At least one input is required. ```bash lafs-conformance --envelope ./envelope.json lafs-conformance --flags ./flags.json lafs-conformance --envelope ./envelope.json --flags ./flags.json ``` -------------------------------- ### Docker Compose for LAFS REST API Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md Defines a Docker Compose setup for the LAFS REST API service. It builds the image from the Dockerfile, maps ports, sets environment variables, and configures health checks and restart policies. ```yaml version: '3.8' services: lafs-api: build: . ports: - "3000:3000" environment: - NODE_ENV=production - PORT=3000 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s timeout: 10s retries: 3 restart: unless-stopped ``` -------------------------------- ### Python A2A Agent Extension Integration Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/extensions.md Demonstrates how to integrate A2A extensions into a Python agent using the 'a2a.server' library. This example highlights the ease of adding extension functionality with minimal code, promoting reusability and streamlined development. ```python --8<-- "https://raw.githubusercontent.com/a2aproject/a2a-samples/refs/heads/main/samples/python/agents/adk_expense_reimbursement/__main__.py" ``` -------------------------------- ### Example Send Message Request and Response Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md Illustrates the JSON structure for a 'send message' POST request and a successful HTTP 200 OK response. The request includes message details and accepted output modes, while the response contains task information. ```json POST /message:send Content-Type: application/json { "message": { "messageId": "uuid", "role": "ROLE_USER", "parts": [{"text": "Hello"}] }, "configuration": { "acceptedOutputModes": ["text/plain"] } } ``` ```json HTTP/1.1 200 OK Content-Type: application/json { "task": { "id": "task-uuid", "contextId": "context-uuid", "status": { "state": "TASK_STATE_COMPLETED" } } } ``` -------------------------------- ### Error Recovery: Query from Earliest Available Version (HTTP GET) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/designs/context-query-v1.md This is the recovery step after encountering a 'version too old' error. It involves re-querying the context delta starting from the earliest available version indicated in the error response. ```http GET /_lafs/context/workflow_abc?mode=delta&sinceVersion=95 ``` -------------------------------- ### Upload and Download Files for Analysis (HTTP) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/external/specification.md Illustrates how a client can upload a file (e.g., an image) for analysis and how the agent responds with a reference to the processed file. The request includes the raw file data, filename, and media type, while the response provides a URL to the artifact. ```http POST /message:send HTTP/1.1 Host: agent.example.com Content-Type: application/a2a+json Authorization: Bearer token { "message": { "role": "ROLE_USER", "parts": [ { "text": "Analyze this image and highlight any faces." }, { "raw": "iVBORw0KGgoAAAANSUhEUgAAAAUA..." "filename": "input_image.png", "mediaType": "image/png", } ], "messageId": "6dbc13b5-bd57-4c2b-b503-24e381b6c8d6" } } ``` ```http HTTP/1.1 200 OK Content-Type: application/a2a+json { "task": { "id": "43667960-d455-4453-b0cf-1bae4955270d", "contextId": "c295ea44-7543-4f78-b524-7a38915ad6e4", "status": { "state": "TASK_STATE_COMPLETED", "timestamp": "2024-03-15T12:05:00Z" }, "artifacts": [ { "artifactId": "9b6934dd-37e3-4eb1-8766-962efaab63a1", "name": "processed_image_with_faces.png", "parts": [ { "url": "https://storage.example.com/processed/task-bbb/output.png?token=xyz", "filename": "output.png", "mediaType": "image/png" } ] } ] } } ``` -------------------------------- ### LAFS Summary Context Query Request and Response Example Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/specs/context-projection-modes.md Illustrates an HTTP GET request for querying the LAFS context in summary mode, designed for quick state verification. The response contains essential metadata like version and checksum, without detailed entries. ```http GET /_lafs/context/workflow_abc?mode=summary HTTP/1.1 Authorization: Bearer {token} Accept: application/json ``` ```json { "_meta": { "specVersion": "1.0.0", "schemaVersion": "1.0.0", "timestamp": "2026-02-16T10:30:00Z", "operation": "context.query", "requestId": "req_ctx_003", "transport": "http", "strict": true, "mvi": "minimal", "contextVersion": 42 }, "success": true, "result": { "ledgerId": "workflow_abc", "mode": "summary", "version": 42, "checksum": "sha256:a1b2c3d4...", "entryCount": 42, "createdAt": "2026-02-16T09:00:00Z", "updatedAt": "2026-02-16T10:25:00Z", "isCompacted": false, "compactedAt": null }, "page": { "mode": "none" } } ``` -------------------------------- ### Configure CORS Middleware (TypeScript) Source: https://github.com/kryptobaseddev/lafs-protocol/blob/main/docs/deployment.md This code configures Cross-Origin Resource Sharing (CORS) for the Express application using the 'cors' middleware. It allows requests from origins specified in the ALLOWED_ORIGINS environment variable (or an empty array if not set), permits GET and POST methods, and specifies allowed headers. ```typescript import cors from 'cors'; app.use(cors({ origin: process.env.ALLOWED_ORIGINS?.split(',') || [], methods: ['GET', 'POST'], allowedHeaders: ['Content-Type', 'Authorization'] })); ```