@sequenceholdings/lattice
v0.1.4
Published
Lattice — declarative process graphs driven by a single Trigger.dev orchestrator task with per-node-kind subtasks
Readme
@sequenceholdings/lattice
SDK for defining Sequence Lattice processes — declarative process graphs of automation, agent, human, delay, and managed-function nodes, executed by the Sequence platform.
Lattice is a workflow-agnostic platform primitive. The SDK and runtime define generic graph and execution mechanisms; deployed process packages own business semantics. The runtime must not identify consumers or branch on their process IDs. See Platform primitive boundaries for the dependency and placement contract.
The main authoring entry is pure TypeScript: it provides the define* surface,
bundle hashing/serialization, event types, and typed errors. The
jsonata-runtime subpath is shared by Sequence's server and CLI tooling so
local simulation uses the same bounded evaluator as deployed runs. Execution
otherwise happens server-side on the Sequence platform; use
@sequenceholdings/studio-cli
(seq-studio) to lint, plan, and apply processes.
Install
pnpm add @sequenceholdings/latticeUsage
import {
defineProcess,
defineNativeAutomationNode,
defineAgentNode,
defineHumanNode,
defineDelayNode,
} from '@sequenceholdings/lattice'
export default defineProcess({
id: 'my-process',
entry: 'first_step',
nodes: {
first_step: defineNativeAutomationNode({
fn: async (input) => ({ payload: { ok: true } }),
edges: { done: { to: 'review' } },
}),
review: defineHumanNode({
title: 'Review the result',
edges: { approved: { to: null }, rejected: { to: 'first_step' } },
}),
},
})Subpath exports
import { defineProcess } from '@sequenceholdings/lattice/define'
import { computeBundleHash } from '@sequenceholdings/lattice/bundle'
import { EVENT_TYPE } from '@sequenceholdings/lattice/events'
import { InvalidEdgeIdError } from '@sequenceholdings/lattice/errors'Workflow
Scaffold a process repo and iterate with the CLI:
pnpm add -g @sequenceholdings/studio-cli
seq-studio process init my-processes
cd my-processes
seq-studio process lint # static graph checks (offline)
seq-studio process simulate <id> # local walk with stubbed runners (offline)
seq-studio process plan -e <env>
seq-studio process apply -e <env>Ordinary agent responses
Set outputMode: 'payload' on defineAgentNode to retain the complete extracted
response in payload.result, alongside payload.agent_run_id and
payload.agent_thread_id. Ordinary agents retain final text; structured-output
agents retain the extractor's parsed JSON. Blank responses fail and follow the
node's retry policy. This mode allows zero or one normal outgoing edge, selected
deterministically; on_reset_edge_id is excluded. Omit the option to retain the
existing structured-output routing contract.
allowedTools: ['search'] optionally restricts MCP tool names for the invocation
on both execution engines, including re-asks. Built-in tools retain their
existing policy. The array must contain at least one nonempty name; it does not
grant permissions. Neither option can be combined with workflowId.
Input mappers can read ctx.run.trigger_reason, the run's trigger metadata
object (or null), to distinguish scheduled or manually started work. The
field is optional for compatibility with older persisted contexts.
Declarative JSONata mappers
Use jsonata() when a mapper must remain declarative data rather than bundled
JavaScript:
import { defineAgentNode, jsonata } from '@sequenceholdings/lattice'
const summarize = defineAgentNode({
id: 'summarize',
title: 'Summarize',
// Pin production-sensitive processes; omit `version` to follow live config.
agent: { id: 'summary-agent', version: 7 },
input: jsonata('{ "loanId": entity.id, "memo": upstream.lookup.payload }'),
outgoing_edges: [],
})$ is the mapper input. Named runtime values are exposed as JSONata variables:
$branches for parallel joins, $child for subprocess output, and $info for
email templates. A managed-function output mapper receives the completed
invocation as $response; output: jsonata('$response.body') promotes a
function-returned { edge_id, payload, state } envelope into the node output.
Node and supervisor retry predicates receive
{ name, message } as $.
$addBusinessHours(isoString, seconds) is the only registered host function.
$eval is disabled.
For OpCo-authored processes, a JSONata advance_allowed result may name at
most 100 total user and group entries. The platform validates those principals
against the deployment directory before materializing the human step.
process lint parse-checks every expression locally. process simulate
evaluates the data-flow expressions that affect the local walk (input,
fan_out, join, and subprocess output) in the same memory-bounded,
deadline-aware worker used by the server. Runners stay stubbed, so simulation
does not have a managed-function response with which to evaluate its output
mapper, deliver email, or execute human due-date, assignment, artifact, or
retry behavior.
Applying processes to a Sequence environment requires platform authorization — see the studio-cli README.
License
Proprietary — © Sequence Holdings. All rights reserved. Published for use with the Sequence platform; no license is granted to copy, modify, or redistribute.
