T-1, T-2: W1.11: the TypeScript side holds a seat as the Go side does
A TypeScript holder, the forge module first, must judge a verb's caller by the runtime's proof, say its seat's events and answer its first views' read and ask-again tools (design 47, The forge module's tools come from mesh-sdk's TypeScript side; G-F1 option A). The stdio session now hands each tool the caller and call id the runtime wrote in _meta (callers.callerOf, the Go rules for Callers and VerbCallers), binds the runtime for seatPublish over mesh/seat.publish and config, and views gains the Follower and its two status tools over the state first-views. @novox/mesh-sdk 0.1.19. Builds: design 47 G §196, §200, §336 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
+9
-1
@@ -16,6 +16,8 @@ import type { ToolDefinition } from "../contracts/index.js";
|
||||
import { collectTools } from "../tools/index.js";
|
||||
import { useBroker, type Broker, type Envelope } from "../messaging/index.js";
|
||||
import { useStateChannel, type StateChange } from "../state/index.js";
|
||||
import { useRuntime } from "../runtime/index.js";
|
||||
import { runAs } from "../callers/index.js";
|
||||
|
||||
/** The protocol version this speaks; the runtime says the same. */
|
||||
export const PROTOCOL = "2025-03-26";
|
||||
@@ -123,6 +125,8 @@ function startSession(): Session {
|
||||
close: async () => {},
|
||||
};
|
||||
useBroker(() => viaRuntime);
|
||||
// Every other method of the runtime a module's code asks (a seat's publish, its config): the same channel.
|
||||
useRuntime(ask);
|
||||
|
||||
let name = "bundle";
|
||||
let byName = new Map<string, ToolDefinition>();
|
||||
@@ -158,7 +162,11 @@ function startSession(): Session {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await tool.run((request.params?.arguments as Record<string, unknown> | undefined) ?? {});
|
||||
// The caller the runtime proved, in `_meta`, is held for these arguments while the tool runs (callerOf), never
|
||||
// read from the arguments (novox/hq issue 365).
|
||||
const given = request.params?.arguments;
|
||||
const args = (given && typeof given === "object" && !Array.isArray(given) ? given : {}) as Record<string, unknown>;
|
||||
const result = await runAs(request.params?._meta, args, () => tool.run(args));
|
||||
say({ jsonrpc: "2.0", id: request.id, result: { content: [{ type: "text", text: JSON.stringify(result ?? null) }] } });
|
||||
} catch (err) {
|
||||
// The tool failed; said as a tool error, not a protocol one, because the call was well-formed.
|
||||
|
||||
Reference in New Issue
Block a user