Skip to content
23 changes: 23 additions & 0 deletions apps/sim/lib/api/contracts/mothership-build-notes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { z } from 'zod'

const target = z.object({
workspaceId: z.string().min(1).max(100).optional(),
workflowId: z
.string()
.trim()
.regex(/^[A-Za-z0-9_-]{1,100}$/, 'workflowId must be a workflow id')
.describe('The workflow the notes belong to.'),
})

/**
* A workflow's build notes: the agent's hidden scratchpad at build-notes/<workflowId>.md, with
* the graph Sim last recorded beside it at build-notes/<workflowId>.baseline.json.
*/
export const mothershipBuildNotesInputSchema = z.discriminatedUnion('action', [
target.extend({ action: z.literal('create') }).strict(),
target.extend({ action: z.literal('status') }).strict(),
target.extend({ action: z.literal('evaluate') }).strict(),
target.extend({ action: z.literal('apply') }).strict(),
target.extend({ action: z.literal('changes') }).strict(),
target.extend({ action: z.literal('rebase') }).strict(),
])
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ const examples = {
},
{ action: 'update', releaseId: 'release-1', expectedRevision: '2', version: '1.5.0' },
],
build_notes: [
{ action: 'create', workflowId: 'wf-1' },
{ action: 'status', workflowId: 'wf-1' },
{ action: 'evaluate', workflowId: 'wf-1' },
{ action: 'apply', workflowId: 'wf-1' },
{ action: 'changes', workflowId: 'wf-1' },
{ action: 'rebase', workflowId: 'wf-1' },
],
}

describe('management tool provider contract', () => {
Expand Down
9 changes: 9 additions & 0 deletions apps/sim/lib/api/contracts/mothership-management-tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from 'zod'
import { mothershipBuildNotesInputSchema } from '@/lib/api/contracts/mothership-build-notes'
import { mothershipChangelogInputSchema } from '@/lib/api/contracts/mothership-changelog'
import { mothershipDashboardsInputSchema } from '@/lib/api/contracts/mothership-dashboards'
import { mothershipTestsInputSchema } from '@/lib/api/contracts/mothership-tests'
Expand Down Expand Up @@ -36,6 +37,14 @@ export const managementToolContracts = [
'Publish and edit the selected workspace\u2019s changelog. publish takes a title, a markdown body, the changes (one line each, with the workflowId, deploymentVersionId, and chatId they came from when known), and bump: major, minor, or patch for how significant the release is, with a one-line bumpReason. The server computes the version from the workspace\u2019s highest one; never write a version number on publish. It returns the release with its revision and changelog/<id>.md, the body file: edit the body there with the file tools, for example to add impact charts once there is data. update changes the title, bumpReason, version label, or the whole change list, and requires expectedRevision from get, list, or publish so a concurrent edit is never overwritten. A deployment ships in one release: a deploymentVersionId already in another release is rejected. list pages newest first; get returns one release with its revision and its changelog/<id>.md path.',
inputSchema: mothershipChangelogInputSchema,
},
{
id: 'build_notes',
route: 'sim',
scope: 'all',
description:
'A workflow\u2019s build notes: the hidden scratchpad the agent drafts a build in before changing the graph. Nobody else sees or edits it; a later chat reads it to explain how the workflow was built. create writes build-notes/<workflowId>.md from a template and records the current graph as build-notes/<workflowId>.baseline.json; edit the notes with the file tools, never the baseline. evaluate dry-runs the notes\u2019 operations block and lists what still blocks a build: open placeholders, items marked [gather] or [ask], dry-run skips, input errors and lint. Once evaluate passes, apply builds from exactly that block, atomically; a workflows operations apply of a different batch, notes edited since, or a graph changed outside the agent is refused until the notes pass evaluation again. Each build spends the evaluation. status says whether notes exist, passed evaluation, and whether the workflow was saved since the baseline; changes lists what changed since the baseline; after reconciling the notes, rebase records the current graph as the new baseline.',
inputSchema: mothershipBuildNotesInputSchema,
},
{
id: 'workspaces',
route: 'sim',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/api/contracts/workspace-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const workspaceFileRecordSchema = z.object({
contentUpdatedAt: z.coerce.date().nullable().optional(),
revision: z.string().optional(),
storageContext: z.enum(['workspace', 'mothership']).optional(),
vfsNamespace: z.enum(['uploads', 'tests', 'changelog']).optional(),
vfsNamespace: z.enum(['uploads', 'tests', 'changelog', 'build-notes']).optional(),
share: shareRecordSchema.nullable().optional(),
})

Expand Down
Loading
Loading