@rolexjs/prototype 0.12.0-dev-20260228032306
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +96 -0
- package/dist/index.js +1205 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { State, Runtime, Structure } from '@rolexjs/system';
|
|
2
|
+
import { ResourceX } from 'resourcexjs';
|
|
3
|
+
|
|
4
|
+
declare const processes: Record<string, string>;
|
|
5
|
+
declare const world: Record<string, string>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Dispatch — schema-driven argument mapping.
|
|
9
|
+
*
|
|
10
|
+
* Replaces the hand-written toArgs switch in rolex.ts with a single
|
|
11
|
+
* lookup against the instruction registry.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Map named arguments to positional arguments for a given operation.
|
|
15
|
+
*
|
|
16
|
+
* @param op - Operation key in "namespace.method" format (e.g. "individual.born")
|
|
17
|
+
* @param args - Named arguments from the caller
|
|
18
|
+
* @returns Positional argument array matching the method signature
|
|
19
|
+
*/
|
|
20
|
+
declare function toArgs(op: string, args: Record<string, unknown>): unknown[];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Schema types for RoleX instruction definitions.
|
|
24
|
+
*
|
|
25
|
+
* These types define the structure of every RoleX operation:
|
|
26
|
+
* parameter types, descriptions, and positional arg ordering.
|
|
27
|
+
*/
|
|
28
|
+
/** Supported parameter types for instruction definitions. */
|
|
29
|
+
type ParamType = "string" | "gherkin" | "string[]" | "record";
|
|
30
|
+
/** Definition of a single parameter in an instruction. */
|
|
31
|
+
interface ParamDef {
|
|
32
|
+
type: ParamType;
|
|
33
|
+
required: boolean;
|
|
34
|
+
description: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A single positional argument entry.
|
|
38
|
+
*
|
|
39
|
+
* - `string` — simple lookup: `args[name]`
|
|
40
|
+
* - `{ pack: [...] }` — collect named args into an options object;
|
|
41
|
+
* returns `undefined` if all values are absent.
|
|
42
|
+
*/
|
|
43
|
+
type ArgEntry = string | {
|
|
44
|
+
pack: readonly string[];
|
|
45
|
+
};
|
|
46
|
+
/** Full definition of a RoleX instruction (one namespace.method). */
|
|
47
|
+
interface InstructionDef {
|
|
48
|
+
namespace: string;
|
|
49
|
+
method: string;
|
|
50
|
+
/** Parameter definitions — keyed by param name, used for MCP/CLI schema generation. */
|
|
51
|
+
params: Record<string, ParamDef>;
|
|
52
|
+
/** Positional argument order — maps named args to method call positions. */
|
|
53
|
+
args: readonly ArgEntry[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Instruction set — schema definitions for all RoleX operations.
|
|
58
|
+
*
|
|
59
|
+
* Covers every namespace.method that can be dispatched through `use()`.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
declare const instructions: Record<string, InstructionDef>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Ops — platform-agnostic operation implementations.
|
|
66
|
+
*
|
|
67
|
+
* Every RoleX operation is a pure function of (Runtime, args) → OpResult.
|
|
68
|
+
* No platform-specific code — all I/O goes through injected interfaces.
|
|
69
|
+
*
|
|
70
|
+
* Usage:
|
|
71
|
+
* const ops = createOps({ rt, society, past, resolve, find, resourcex });
|
|
72
|
+
* const result = ops["individual.born"]("Feature: Sean", "sean");
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
interface OpResult {
|
|
76
|
+
state: State;
|
|
77
|
+
process: string;
|
|
78
|
+
}
|
|
79
|
+
interface OpsContext {
|
|
80
|
+
rt: Runtime;
|
|
81
|
+
society: Structure;
|
|
82
|
+
past: Structure;
|
|
83
|
+
resolve(id: string): Structure;
|
|
84
|
+
find(id: string): Structure | null;
|
|
85
|
+
resourcex?: ResourceX;
|
|
86
|
+
prototype?: {
|
|
87
|
+
settle(id: string, source: string): void;
|
|
88
|
+
evict(id: string): void;
|
|
89
|
+
list(): Record<string, string>;
|
|
90
|
+
};
|
|
91
|
+
direct?(locator: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
92
|
+
}
|
|
93
|
+
type Ops = Record<string, (...args: any[]) => any>;
|
|
94
|
+
declare function createOps(ctx: OpsContext): Ops;
|
|
95
|
+
|
|
96
|
+
export { type ArgEntry, type InstructionDef, type OpResult, type Ops, type OpsContext, type ParamDef, type ParamType, createOps, instructions, processes, toArgs, world };
|