@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
67 lines • 2.49 kB
JavaScript
/**
* JSON schema of {@link JobWidgetSpec}, carried by the forced `respond` tool the author model calls.
* Deliberately bare (shapes and enums, no prose): the system prompt documents every property, and
* the schema is billed as input on every request. Semantic checks live in `validateJobWidgetSpec`.
* Nothing is required at the top: a `skip` answer declines to draw a widget.
* Ported from oh-my-pi 9df0457b31 (MIT, Copyright Can Boluk et al.).
*/
import { JOB_WIDGET_AGGS } from "./spec-types.js";
import { JOB_WIDGET_TONES } from "./view-types.js";
const STRING = { type: "string" };
const NUMBER = { type: "number" };
const BETTER = { enum: ["higher", "lower"] };
const VALUE_REF_SCHEMA = {
type: "object",
required: ["field", "agg"],
properties: {
field: STRING,
agg: { enum: JOB_WIDGET_AGGS },
label: STRING,
key: STRING,
unit: STRING,
digits: { type: "integer" },
better: BETTER,
},
};
export const JOB_WIDGET_SPEC_SCHEMA = {
type: "object",
properties: {
skip: STRING,
title: STRING,
rules: {
type: "array",
items: {
type: "object",
required: ["from", "match"],
properties: { from: STRING, match: STRING, key: STRING, text: STRING, count: STRING, scale: NUMBER },
},
},
blocks: {
type: "array",
items: {
type: "object",
required: ["kind"],
properties: {
kind: { enum: ["spark", "bars", "meter", "stat", "grid", "text"] },
field: STRING,
label: STRING,
key: STRING,
// Optional on purpose: the validator reads an absent bars or meter `agg` as "last".
agg: { enum: JOB_WIDGET_AGGS },
unit: STRING,
better: BETTER,
target: NUMBER,
targetLabel: STRING,
min: NUMBER,
max: NUMBER,
total: { anyOf: [NUMBER, VALUE_REF_SCHEMA] },
items: { type: "array", items: VALUE_REF_SCHEMA },
tones: { type: "object", additionalProperties: { enum: JOB_WIDGET_TONES } },
},
},
},
headline: VALUE_REF_SCHEMA,
stage: STRING,
},
};
//# sourceMappingURL=spec-schema.js.map