Suwagcms.Sdk 0.7.0

dotnet add package Suwagcms.Sdk --version 0.7.0
                    
NuGet\Install-Package Suwagcms.Sdk -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Suwagcms.Sdk" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Suwagcms.Sdk" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Suwagcms.Sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Suwagcms.Sdk --version 0.7.0
                    
#r "nuget: Suwagcms.Sdk, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Suwagcms.Sdk@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Suwagcms.Sdk&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Suwagcms.Sdk&version=0.7.0
                    
Install as a Cake Tool

Suwagcms.Sdk

The SDK of a .NET bot (.NET 9 or later) built on Suwagcms.

dotnet add package Suwagcms.Sdk

It holds the definition format (Suwagcms.Sdk.Format, JSON schema in definition-format.schema.json), the validator (Suwagcms.Sdk.Validation) and the bot runtime (Suwagcms.Sdk.BotRuntime). Each has a namespace per concept under it, such as Suwagcms.Sdk.Format.Facts or Suwagcms.Sdk.BotRuntime.Versions.

The bot runtime

builder.Services.AddSuwagcmsBot("rzeczoznawca");   // the bot's own id; versions are kept in files under the content root
var app = builder.Build();
app.MapSuwagcmsBot();                              // GET /suwagcms/state, GET /suwagcms/declaration, PUT /suwagcms/versions/{number}, PUT /suwagcms/current, PUT /suwagcms/availability, POST /suwagcms/actions/test

The CMS pushes a version with PUT /suwagcms/versions/{number}: one JSON object with formatVersion, bot, number, digest (VersionDigest.Of) and the lists of the definition. The SDK validates it (DefinitionValidator at the Version stage), checks the bot id, the number and the digest, and loads it without a restart. A refusal is Problem Details with every mistake in mistakes (422 invalid, 409 the number holds another document, 503 the store failed) and changes nothing. Sending the same document again succeeds and changes nothing; a lower number not yet held is accepted and becomes current. PUT /suwagcms/current with { "number": 12, "digest": "…" } makes a version the bot already holds current without receiving it again, and is how the CMS goes back to one (or forward after a rollback). It checks the held document with today's validator and answers as above, safe to repeat: 409 version.notHeld (the CMS then sends the document), 409 version.conflict (another document under that number), 422 (no longer valid), 503 (the store failed). Without this route a bot can only take versions it does not hold. GET /suwagcms/state answers bot, current (null before the first version), held, inUse, storeError and availability. The shapes are in bot-runtime.schema.json, so a bot outside .NET can implement the same routes.

What the bot supports. State it in the setup, and the CMS asks for it with GET /suwagcms/declaration once the bot is running:

builder.Services.AddSuwagcmsBot("rzeczoznawca", declares: new BotCapabilities
{
    FormatVersion = BotDefinition.CurrentFormatVersion,
    Blocks = ["listen", "collect", "say", "assign", "action"],       // what your engine runs: there is no default
    CodeActions = [new CodeAction { Id = "lookupPolicy", Description = "Finds a policy" }],
    Persona = BotDeclaration.PersonaRequired,                        // optional: a version without a persona is then refused
});

The CMS then builds and pushes only versions that fit it. Without declares the route answers declaresNothing: true and nothing is checked against the bot, so a bot that is not ready to say still works. The answer's shape is in bot-runtime.schema.json. A bot outside .NET serves the same route and validates a definition through the CMS with POST /api/validate (suwagcms validate).

A procedure may hold whenInterrupted, keep or discard: what happens to it when another one is started on top of it. Procedure.IsDiscardedWhenInterrupted is false when it is left out; what keeping and discarding do is your engine's to carry out.

A say text may hold {name}, a fact name in braces written as the procedure's other blocks name a fact (dot-separated camelCase words; a local fact by its name in the procedure); braces around anything else are plain text. The validator checks that the procedure sees the fact, and your engine replaces the placeholder with the fact's value when it sends the text: what to send when the fact has no value is yours to decide, since the SDK cannot know.

Format 5 brought these placeholders and a step's OnUnavailable. A bot built on this SDK declares format 5 through BotDefinition.CurrentFormatVersion; one still declaring format 4 is refused every new version with declaration.formatVersion until it takes this SDK.

A version may hold a persona: personality, and scope with inScope, outOfScope and whenOutOfScope, each one text with its line breaks. GetAsync gives it as BotDefinition.Persona, null when the version has none; what the bot does with it is its own concern. PersonaRequired is satisfied by any text; BotDeclaration.PersonaComplete only by all four parts.

The bot's code uses IBotDefinitions:

  • CurrentNumber: the number a new conversation starts on (null before the first version); keep it with the conversation.
  • GetAsync(number): the definition of that version, also on an instance that was not pushed to.
  • GetArticlesAsync(number): every article of that version, ordered by id, each with its base's Language and IsOff as it stands now, for your own search index or an external one. Content and LlmGuide are as the version holds them, with cms:// links; the CMS builds no index and is never called.
  • OnCurrentChanged((number, cancellationToken) => …): tells your code each time this instance's current version changes, a rollback included, and once at start when there is one. Each piece of news runs on its own task, never holding up a push: a failure is logged, and a slow listener may overlap the next, so go by the number. Several instances each hear it. A version is current before you hear of it: nothing waits for your search.
  • OnAvailabilityChanged((number, cancellationToken) => …): tells your code each time what is off changes, with the message's number, and once at start when a set is held, the same way, so a search can drop an article at once.
  • IsOff(number, kind, id): whether a resource is turned off, for a conversation on that version. Off is a live setting outside versions: GetAsync still gives the resource, and what off means is your engine's to carry out; a step running a turned-off action has its OnUnavailable step to take, or its OnFailure step when OnUnavailable is null.
  • ReportInUseAsync(numbers): the versions your open conversations use, across all instances of the bot. Versions neither current nor reported are removed; until the first report nothing is. A push or a rollback removes the version it replaced unless your last report named it, so report a number before you save the first conversation on it. When a conversation expires is your decision.

What is off. The CMS sends PUT /suwagcms/availability with number and off, the whole set: each item has kind (Article, Procedure or Action), id, and for a former id of a renamed resource upToVersion, the last version it counts in. A lower number changes nothing and the same message twice changes nothing, so a late message cannot undo a newer one. The answer is the state, which reports the setting under availability; a refusal has the same shape as for a version (422, or 503 when the store failed).

Several instances. Pass a store they all reach: AddSuwagcmsBot(id, store) with your own IVersionStore (a table in the bot's database, say). The SDK writes versions, the current number, the reported numbers and what is off to it, the other instances read it every five seconds (pollInterval), and GET /suwagcms/state answers from it, so every instance says the same. Your store's WriteAvailabilityAsync must keep a message only if its number is not lower than the one held, in one step, since the instances have no lock in common, and ReadStateAsync must give it back. A change delivered to one instance reaches the others at their next poll, not sooner. The default FileVersionStore is for one instance; InMemoryVersionStore is for tests.

Running an HTTP action. Actions are defined in the CMS and reach the bot in a version; your engine decides when to run one, and HttpActionRunner makes the call the same way for every bot:

using var runner = new HttpActionRunner();
ActionOutcome outcome = await runner.RunAsync(action, new Dictionary<string, string> { ["address"] = "Polna 3, Suwałki" });

A {name} in the URL is filled in URL-encoded; the other parameters go as a query string for GET and DELETE and as one JSON object otherwise. Each result is the member of its name at the top level of the JSON answer; with no results declared any 2xx is a success. A parameter that does not fit, a secret not found, no connection, no answer within the action's timeoutSeconds (10 by default), an answer outside 2xx (redirects included) or results that do not fit give a failure with a Reason and no results, and there are no retries. A secret written {secret:CRM_TOKEN} is read from the variable SUWAGCMS_SECRET_CRM_TOKEN, so the bot's owner chooses what a definition can reach; pass your own findSecret to look elsewhere. A secret's value is masked in everything the outcome holds. A bot outside .NET does the same, by the same contract.

Trying an action. POST /suwagcms/actions/test takes { action, values }, runs the action with the same runner, writes nothing, and answers outcome (success or failure), results, reason, status, elapsedMs, answerStart and answerCut; the shapes are in bot-runtime.schema.json. A code action runs through the runCodeAction you pass to AddSuwagcmsBot; without one the answer says so.

The routes have no key yet. Anyone who can reach the bot can replace its definition or make it call any address with its secrets, and the bot id check only stops a mistyped address. Until the CMS has identity, expose /suwagcms/* to a trusted network only.

Without the runtime, the validator alone needs no database and no network:

IReadOnlyList<Mistake> mistakes = DefinitionValidator.ValidateJson(json, ValidationStage.Version);

A bot that handles definitions itself reads one with BotDefinition.Read(json), which uses the format's own options, and tests a value of a fact with FactValues.Accepts(fact, value) and words what it takes with FactValues.Valid(fact), so it keeps no second copy of a pattern's rules.

Pass a BotDeclaration as a third argument and the Version stage also reports what that bot cannot run; Save never looks at it.

It returns every mistake at once, each with a stable code and a fix; an empty list means the definition passes. The code is a MistakeCode, an enum of every code the validator, the bot runtime and the CMS give: compare with mistake.Code == MistakeCode.StepMissing. On the wire and in bot-runtime.schema.json each one is its dotted text, such as step.missing, which mistake.Code.Text() gives.

Moving from 0.6

The mistake codes became an enum. What a bot sends and receives is unchanged: every code keeps its dotted text.

  • MistakeCodes.X, a string constant, is now MistakeCode.X, and Mistake.Code is a MistakeCode. Replace MistakeCodes. with MistakeCode.; where a code was used as text (a log line, a message, a dictionary key), write mistake.Code.Text(), since an enum's ToString() gives its C# name (StepMissing), not step.missing.
  • MistakeCodes.FactEnumValueReserved is MistakeCode.FactEnumValueOther; its text is still fact.enum.valueReserved.
  • The codes the CMS gives on its own (such as resource.stale or save.unknownField) are members too, so a tool reading the CMS's answers can compare them the same way.
  • A refusal holding a code outside the enum no longer reads as a BotRefusal: a bot outside .NET sends only the codes bot-runtime.schema.json lists.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 63 11/21/2026
0.6.0 162 11/11/2026
0.5.0 160 11/8/2026
0.4.0 99 11/8/2026
0.3.0 124 11/7/2026
0.2.0 106 11/6/2026
0.1.0 104 11/6/2026