bridge: roll tool for the player, glm 5.3 example config
This commit is contained in:
@@ -263,8 +263,9 @@ pedantic, whatever housekeeping needs. The two prompts are independent.
|
|||||||
|
|
||||||
**Substrate:** `tool/bridge.mjs` is the thin bridge — a player session with
|
**Substrate:** `tool/bridge.mjs` is the thin bridge — a player session with
|
||||||
native tools, no UI. It assembles the bundle from the run's files (views
|
native tools, no UI. It assembles the bundle from the run's files (views
|
||||||
refreshed), offers the player tools (status always; records only when the
|
refreshed), offers the player tools (status and a coin-flip roll always;
|
||||||
run's gate allows — the tool list is the capability surface), executes
|
records only when the run's gate allows — the tool list is the capability
|
||||||
|
surface), executes
|
||||||
model tool calls against the clerk, logs the full exchange to
|
model tool calls against the clerk, logs the full exchange to
|
||||||
`runs/<story>/sessions/<stamp>.jsonl` (the housekeeping transcript), and
|
`runs/<story>/sessions/<stamp>.jsonl` (the housekeeping transcript), and
|
||||||
elides old tool results to stubs in the live context (use-and-discard).
|
elides old tool results to stubs in the live context (use-and-discard).
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"baseUrl": "https://api.openai.com/v1",
|
"baseUrl": "https://open.bigmodel.cn/api/paas/v4",
|
||||||
"model": "gpt-4o",
|
"model": "glm-5.3",
|
||||||
"apiKeyEnv": "RP_API_KEY"
|
"apiKeyEnv": "ZHIPU_API_KEY"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
# Status
|
# Status
|
||||||
|
|
||||||
- **mood:** testing the bridge
|
(nothing set — fresh start)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ CREATE TABLE IF NOT EXISTS events (
|
|||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS events_window ON events (window);
|
CREATE INDEX IF NOT EXISTS events_window ON events (window);
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
INSERT INTO status VALUES ('mood','','testing the bridge','2026-11-11');
|
|
||||||
INSERT INTO events VALUES (1,'pc','status','s:mood','mock turn');
|
INSERT INTO events VALUES (1,'pc','status','s:mood','mock turn');
|
||||||
|
INSERT INTO events VALUES (2,'pc','status','s:mood','excursion declared');
|
||||||
|
INSERT INTO events VALUES (3,'pc','status','s:mood','field dropped');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
@@ -51,4 +51,6 @@ CREATE TABLE IF NOT EXISTS events (
|
|||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS events_window ON events (window);
|
CREATE INDEX IF NOT EXISTS events_window ON events (window);
|
||||||
BEGIN TRANSACTION;
|
BEGIN TRANSACTION;
|
||||||
|
INSERT INTO events VALUES (1,'pc','status','s:mood','excursion declared');
|
||||||
|
INSERT INTO events VALUES (2,'pc','status','s:mood','field dropped');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
+25
-9
@@ -67,6 +67,11 @@ const STATUS_TOOLS = [
|
|||||||
{ key: { type: 'string' } }),
|
{ key: { type: 'string' } }),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const ROLL_TOOL = T('roll',
|
||||||
|
'Flip a coin: pick one of the options at random. For genuinely non-obvious choices, or in-fiction chance she herself controls (a tossed coin, a drawn straw). Randomizes choices, never outcomes — whether an attempt succeeds is the GM\'s to resolve. Commit to the result; do not re-roll.',
|
||||||
|
{ options: { type: 'array', items: { type: 'string' }, minItems: 2, description: 'the options, equal weight' } },
|
||||||
|
['options']);
|
||||||
|
|
||||||
const RECORD_TOOLS = [
|
const RECORD_TOOLS = [
|
||||||
T('records_search', 'Consult her files. Narrow terms — what this beat needs. The result is capped at 10. A miss is a miss: do not rephrase, broaden, or retry this scene.',
|
T('records_search', 'Consult her files. Narrow terms — what this beat needs. The result is capped at 10. A miss is a miss: do not rephrase, broaden, or retry this scene.',
|
||||||
{ terms: { type: 'array', items: { type: 'string' }, description: 'all terms must match' } },
|
{ terms: { type: 'array', items: { type: 'string' }, description: 'all terms must match' } },
|
||||||
@@ -87,7 +92,7 @@ function recordsEnabled() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const TOOLS = [...STATUS_TOOLS, ...(recordsEnabled() ? RECORD_TOOLS : [])];
|
const TOOLS = [...STATUS_TOOLS, ROLL_TOOL, ...(recordsEnabled() ? RECORD_TOOLS : [])];
|
||||||
|
|
||||||
// tool name → clerk argv
|
// tool name → clerk argv
|
||||||
const DISPATCH = {
|
const DISPATCH = {
|
||||||
@@ -95,6 +100,7 @@ const DISPATCH = {
|
|||||||
status_norm: (a) => ['norm', a.key, a.baseline],
|
status_norm: (a) => ['norm', a.key, a.baseline],
|
||||||
status_clear: (a) => ['clear', a.key],
|
status_clear: (a) => ['clear', a.key],
|
||||||
status_drop: (a) => ['unset', a.key],
|
status_drop: (a) => ['unset', a.key],
|
||||||
|
roll: (a) => ['pick', ...a.options],
|
||||||
records_search: (a) => ['search', ...a.terms],
|
records_search: (a) => ['search', ...a.terms],
|
||||||
records_file: (a) => ['file', a.kind, a.label, a.detail ?? ''],
|
records_file: (a) => ['file', a.kind, a.label, a.detail ?? ''],
|
||||||
records_amend: (a) => ['amend', a.rid, a.detail],
|
records_amend: (a) => ['amend', a.rid, a.detail],
|
||||||
@@ -142,8 +148,10 @@ function assembleSystem() {
|
|||||||
+ 'Tool mode: the mechanical verbs described above — status declarations'
|
+ 'Tool mode: the mechanical verbs described above — status declarations'
|
||||||
+ ' and records work — are available to you as function tools. Prefer the'
|
+ ' and records work — are available to you as function tools. Prefer the'
|
||||||
+ ' tools over writing the ((...)) lines; tool calls happen between prose'
|
+ ' tools over writing the ((...)) lines; tool calls happen between prose'
|
||||||
+ ' beats without narrating them. The OOC channel remains for talking to'
|
+ ' beats without narrating them. The roll tool is your coin flip for'
|
||||||
+ ' the GM: points of order, canon questions, proposals.\n';
|
+ ' non-obvious choices — commit to what it returns. The OOC channel'
|
||||||
|
+ ' remains for talking to the GM: points of order, canon questions,'
|
||||||
|
+ ' proposals.\n';
|
||||||
if (!recordsEnabled()) {
|
if (!recordsEnabled()) {
|
||||||
sys += 'There are no records tools: this character keeps no files to consult.\n';
|
sys += 'There are no records tools: this character keeps no files to consult.\n';
|
||||||
}
|
}
|
||||||
@@ -181,18 +189,26 @@ async function callModel(cfg, messages, tools) {
|
|||||||
function mockModel(messages) {
|
function mockModel(messages) {
|
||||||
const last = messages[messages.length - 1];
|
const last = messages[messages.length - 1];
|
||||||
if (last.role === 'tool') {
|
if (last.role === 'tool') {
|
||||||
return { role: 'assistant', content: 'Mock: the tool result is noted. *She settles back against the container, watching the light.* ((mock turn complete))' };
|
if (last.content.startsWith('picked:')) {
|
||||||
|
return {
|
||||||
|
role: 'assistant',
|
||||||
|
content: null,
|
||||||
|
tool_calls: [{
|
||||||
|
id: `mock-status-${messages.length}`,
|
||||||
|
type: 'function',
|
||||||
|
function: { name: 'status_set', arguments: JSON.stringify({ key: 'mood', value: 'committed to the roll' }) },
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { role: 'assistant', content: 'Mock: noted. *She commits to the path the coin chose.*' };
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: null,
|
content: null,
|
||||||
tool_calls: [{
|
tool_calls: [{
|
||||||
id: `mock-${messages.length}`,
|
id: `mock-roll-${messages.length}`,
|
||||||
type: 'function',
|
type: 'function',
|
||||||
function: {
|
function: { name: 'roll', arguments: JSON.stringify({ options: ['press on to the lighthouse', 'go back for Dessa'] }) },
|
||||||
name: 'status_set',
|
|
||||||
arguments: JSON.stringify({ key: 'mood', value: 'testing the bridge', reason: 'mock turn' }),
|
|
||||||
},
|
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user