@rolexjs/core 1.5.0-dev-20260310031643 → 1.5.0-dev-20260312083443

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 CHANGED
@@ -87,8 +87,6 @@ interface Platform {
87
87
  readonly issuexProvider?: IssueXProvider;
88
88
  /** Initializer — bootstrap the world on first run. */
89
89
  readonly initializer?: Initializer;
90
- /** Prototype data to apply on genesis. */
91
- readonly prototypes?: readonly PrototypeData[];
92
90
  }
93
91
 
94
92
  declare const society: _rolexjs_system.Structure;
@@ -455,10 +453,12 @@ declare class RoleXService implements RoleX {
455
453
  private past;
456
454
  /** Cached Role instances — one per individual. */
457
455
  private readonly roles;
456
+ /** Expose commands for the RPC handler. */
457
+ get commandMap(): Commands;
458
458
  /** Permission registry — maps relation names to permissions. */
459
459
  private readonly permissions;
460
460
  private constructor();
461
- static create(platform: Platform, renderer: Renderer): Promise<RoleXService>;
461
+ static create(platform: Platform, renderer: Renderer, prototypes?: readonly PrototypeData[]): Promise<RoleXService>;
462
462
  private init;
463
463
  activate(individual: string): Promise<Role>;
464
464
  private findOrAutoBorn;
@@ -473,6 +473,440 @@ declare class RoleXService implements RoleX {
473
473
  private find;
474
474
  }
475
475
 
476
+ /**
477
+ * JSON-RPC 2.0 types and handler for RoleX.
478
+ *
479
+ * The RpcHandler is the single dispatch point for all RoleX operations.
480
+ * It accepts JSON-RPC 2.0 requests and delegates to the command layer
481
+ * via toArgs() for named-to-positional argument conversion.
482
+ */
483
+
484
+ interface JsonRpcRequest {
485
+ jsonrpc: "2.0";
486
+ method: string;
487
+ params?: Record<string, unknown>;
488
+ id?: string | number | null;
489
+ }
490
+ interface JsonRpcResponse<T = unknown> {
491
+ jsonrpc: "2.0";
492
+ id: string | number | null;
493
+ result?: T;
494
+ error?: JsonRpcError;
495
+ }
496
+ interface JsonRpcError {
497
+ code: number;
498
+ message: string;
499
+ data?: unknown;
500
+ }
501
+ interface RpcHandlerDeps {
502
+ commands: Commands;
503
+ /** Custom method handlers for methods not in the commands map (e.g. activate, inspect, survey). */
504
+ methods?: Record<string, (params: Record<string, unknown>) => Promise<unknown>>;
505
+ }
506
+ declare class RpcHandler {
507
+ private commands;
508
+ private methods;
509
+ constructor(deps: RpcHandlerDeps);
510
+ handle<T = unknown>(request: JsonRpcRequest): Promise<JsonRpcResponse<T>>;
511
+ }
512
+
513
+ /**
514
+ * Namespace interfaces and factories for RoleX builder API.
515
+ *
516
+ * Each namespace is a typed wrapper over the JSON-RPC caller function.
517
+ * Methods accept named parameter objects (matching JSON-RPC params)
518
+ * and return typed results.
519
+ */
520
+
521
+ type Caller = (method: string, params?: Record<string, unknown>) => Promise<any>;
522
+ interface SocietyNamespace {
523
+ born(params: {
524
+ content?: string;
525
+ id: string;
526
+ alias?: string[];
527
+ }): Promise<CommandResult>;
528
+ retire(params: {
529
+ individual: string;
530
+ }): Promise<CommandResult>;
531
+ die(params: {
532
+ individual: string;
533
+ }): Promise<CommandResult>;
534
+ rehire(params: {
535
+ individual: string;
536
+ }): Promise<CommandResult>;
537
+ teach(params: {
538
+ individual: string;
539
+ content: string;
540
+ id: string;
541
+ }): Promise<CommandResult>;
542
+ train(params: {
543
+ individual: string;
544
+ content: string;
545
+ id: string;
546
+ }): Promise<CommandResult>;
547
+ found(params: {
548
+ content?: string;
549
+ id: string;
550
+ alias?: string[];
551
+ admin?: string;
552
+ }): Promise<CommandResult>;
553
+ dissolve(params: {
554
+ org: string;
555
+ }): Promise<CommandResult>;
556
+ crown(params: {
557
+ individual: string;
558
+ }): Promise<CommandResult>;
559
+ uncrown(params: {
560
+ individual: string;
561
+ }): Promise<CommandResult>;
562
+ }
563
+ interface RoleNamespace {
564
+ activate(params: {
565
+ individual: string;
566
+ }): Promise<Role>;
567
+ inspect(params: {
568
+ id: string;
569
+ }): Promise<string>;
570
+ survey(params?: {
571
+ type?: string;
572
+ }): Promise<string>;
573
+ }
574
+ interface OrgNamespace {
575
+ charter(params: {
576
+ org: string;
577
+ content: string;
578
+ id: string;
579
+ }): Promise<CommandResult>;
580
+ hire(params: {
581
+ org: string;
582
+ individual: string;
583
+ }): Promise<CommandResult>;
584
+ fire(params: {
585
+ org: string;
586
+ individual: string;
587
+ }): Promise<CommandResult>;
588
+ admin(params: {
589
+ org: string;
590
+ individual: string;
591
+ }): Promise<CommandResult>;
592
+ unadmin(params: {
593
+ org: string;
594
+ individual: string;
595
+ }): Promise<CommandResult>;
596
+ launch(params: {
597
+ content?: string;
598
+ id: string;
599
+ alias?: string[];
600
+ org?: string;
601
+ maintainer?: string;
602
+ }): Promise<CommandResult>;
603
+ archive(params: {
604
+ project: string;
605
+ }): Promise<CommandResult>;
606
+ establish(params: {
607
+ content?: string;
608
+ id: string;
609
+ alias?: string[];
610
+ }): Promise<CommandResult>;
611
+ abolish(params: {
612
+ position: string;
613
+ }): Promise<CommandResult>;
614
+ }
615
+ interface PositionNamespace {
616
+ charge(params: {
617
+ position: string;
618
+ content: string;
619
+ id: string;
620
+ }): Promise<CommandResult>;
621
+ require(params: {
622
+ position: string;
623
+ content: string;
624
+ id: string;
625
+ }): Promise<CommandResult>;
626
+ appoint(params: {
627
+ position: string;
628
+ individual: string;
629
+ }): Promise<CommandResult>;
630
+ dismiss(params: {
631
+ position: string;
632
+ individual: string;
633
+ }): Promise<CommandResult>;
634
+ }
635
+ interface ProjectNamespace {
636
+ scope(params: {
637
+ project: string;
638
+ content: string;
639
+ id: string;
640
+ }): Promise<CommandResult>;
641
+ milestone(params: {
642
+ project: string;
643
+ content: string;
644
+ id: string;
645
+ }): Promise<CommandResult>;
646
+ achieve(params: {
647
+ milestone: string;
648
+ }): Promise<CommandResult>;
649
+ enroll(params: {
650
+ project: string;
651
+ individual: string;
652
+ }): Promise<CommandResult>;
653
+ remove(params: {
654
+ project: string;
655
+ individual: string;
656
+ }): Promise<CommandResult>;
657
+ deliver(params: {
658
+ project: string;
659
+ content: string;
660
+ id: string;
661
+ }): Promise<CommandResult>;
662
+ wiki(params: {
663
+ project: string;
664
+ content: string;
665
+ id: string;
666
+ }): Promise<CommandResult>;
667
+ produce(params: {
668
+ project: string;
669
+ content?: string;
670
+ id: string;
671
+ alias?: string[];
672
+ owner?: string;
673
+ }): Promise<CommandResult>;
674
+ maintain(params: {
675
+ project: string;
676
+ individual: string;
677
+ }): Promise<CommandResult>;
678
+ unmaintain(params: {
679
+ project: string;
680
+ individual: string;
681
+ }): Promise<CommandResult>;
682
+ }
683
+ interface ProductNamespace {
684
+ strategy(params: {
685
+ product: string;
686
+ content: string;
687
+ id: string;
688
+ }): Promise<CommandResult>;
689
+ spec(params: {
690
+ product: string;
691
+ content: string;
692
+ id: string;
693
+ }): Promise<CommandResult>;
694
+ release(params: {
695
+ product: string;
696
+ content: string;
697
+ id: string;
698
+ }): Promise<CommandResult>;
699
+ channel(params: {
700
+ product: string;
701
+ content: string;
702
+ id: string;
703
+ }): Promise<CommandResult>;
704
+ own(params: {
705
+ product: string;
706
+ individual: string;
707
+ }): Promise<CommandResult>;
708
+ disown(params: {
709
+ product: string;
710
+ individual: string;
711
+ }): Promise<CommandResult>;
712
+ deprecate(params: {
713
+ product: string;
714
+ }): Promise<CommandResult>;
715
+ }
716
+ interface CensusNamespace {
717
+ list(params?: {
718
+ type?: string;
719
+ }): Promise<CommandResult>;
720
+ }
721
+ interface IssueNamespace {
722
+ publish(params: {
723
+ title: string;
724
+ body: string;
725
+ author: string;
726
+ assignee?: string;
727
+ }): Promise<Issue>;
728
+ get(params: {
729
+ number: number;
730
+ }): Promise<Issue | null>;
731
+ list(params?: {
732
+ status?: string;
733
+ author?: string;
734
+ assignee?: string;
735
+ label?: string;
736
+ }): Promise<Issue[]>;
737
+ update(params: {
738
+ number: number;
739
+ title?: string;
740
+ body?: string;
741
+ assignee?: string;
742
+ }): Promise<Issue>;
743
+ close(params: {
744
+ number: number;
745
+ }): Promise<Issue>;
746
+ reopen(params: {
747
+ number: number;
748
+ }): Promise<Issue>;
749
+ assign(params: {
750
+ number: number;
751
+ assignee: string;
752
+ }): Promise<Issue>;
753
+ comment(params: {
754
+ number: number;
755
+ body: string;
756
+ author: string;
757
+ }): Promise<Comment>;
758
+ comments(params: {
759
+ number: number;
760
+ }): Promise<Comment[]>;
761
+ label(params: {
762
+ number: number;
763
+ label: string;
764
+ }): Promise<Issue | null>;
765
+ unlabel(params: {
766
+ number: number;
767
+ label: string;
768
+ }): Promise<Issue | null>;
769
+ }
770
+ interface ResourceNamespace {
771
+ add(params: {
772
+ path: string;
773
+ }): Promise<Resource>;
774
+ search(params?: {
775
+ query?: string;
776
+ }): Promise<string[]>;
777
+ has(params: {
778
+ locator: string;
779
+ }): Promise<boolean>;
780
+ info(params: {
781
+ locator: string;
782
+ }): Promise<Resource>;
783
+ remove(params: {
784
+ locator: string;
785
+ }): Promise<undefined>;
786
+ push(params: {
787
+ locator: string;
788
+ registry?: string;
789
+ }): Promise<RXM>;
790
+ pull(params: {
791
+ locator: string;
792
+ registry?: string;
793
+ }): Promise<undefined>;
794
+ clearCache(params?: {
795
+ registry?: string;
796
+ }): Promise<undefined>;
797
+ }
798
+
799
+ /**
800
+ * Schema types for RoleX instruction definitions.
801
+ *
802
+ * These types define the structure of every RoleX operation:
803
+ * parameter types, descriptions, and positional arg ordering.
804
+ */
805
+ /** Supported parameter types for instruction definitions. */
806
+ type ParamType = "string" | "number" | "gherkin" | "string[]" | "record";
807
+ /** Definition of a single parameter in an instruction. */
808
+ interface ParamDef {
809
+ type: ParamType;
810
+ required: boolean;
811
+ description: string;
812
+ }
813
+ /**
814
+ * A single positional argument entry.
815
+ *
816
+ * - `string` — simple lookup: `args[name]`
817
+ * - `{ pack: [...] }` — collect named args into an options object;
818
+ * returns `undefined` if all values are absent.
819
+ */
820
+ type ArgEntry = string | {
821
+ pack: readonly string[];
822
+ };
823
+ /** Full definition of a RoleX instruction (one namespace.method). */
824
+ interface InstructionDef {
825
+ namespace: string;
826
+ method: string;
827
+ /** Parameter definitions — keyed by param name, used for MCP/CLI schema generation. */
828
+ params: Record<string, ParamDef>;
829
+ /** Positional argument order — maps named args to method call positions. */
830
+ args: readonly ArgEntry[];
831
+ }
832
+ /** RoleX tool definition — schema for a top-level tool (activate, want, use, etc.). */
833
+ interface ToolDef {
834
+ /** Tool name (e.g. "activate", "use"). */
835
+ name: string;
836
+ /** Full Gherkin description of the tool's behavior. */
837
+ description: string;
838
+ /** Parameter definitions — keyed by param name. */
839
+ params: Record<string, ParamDef>;
840
+ }
841
+
842
+ /**
843
+ * RoleX tool definitions — the single source of truth for all tool schemas.
844
+ *
845
+ * Channel-agnostic: MCP, CLI, REST, A2A each convert to their own format.
846
+ * Each ToolDef is self-contained: name + description + params.
847
+ */
848
+
849
+ /**
850
+ * Protocol — the complete interface contract for channel adapters.
851
+ *
852
+ * Any adapter (MCP, CLI, REST, A2A) only needs this object
853
+ * to know what tools exist and what instructions to present.
854
+ */
855
+ interface Protocol {
856
+ /** All tool definitions — self-contained with description + parameter schemas. */
857
+ tools: ToolDef[];
858
+ /** World-level instructions — the cognitive framework for AI roles. */
859
+ instructions: string;
860
+ }
861
+ /** The protocol instance — single source of truth for all channel adapters. */
862
+ declare const protocol: Protocol;
863
+
864
+ /**
865
+ * RoleX Builder — synchronous factory with lazy initialization.
866
+ *
867
+ * Usage:
868
+ * const rx = createBuilder({ platform, renderer });
869
+ * const role = await rx.role.activate({ individual: "sean" });
870
+ * await rx.society.born({ id: "alice", content: "Feature: Alice" });
871
+ */
872
+
873
+ interface RoleXInternal {
874
+ service: RoleXService;
875
+ }
876
+ interface RoleXBuilder {
877
+ /** Society-level operations — born, retire, crown, teach, train, found, dissolve. */
878
+ readonly society: SocietyNamespace;
879
+ /** Role management — activate, inspect, survey. */
880
+ readonly role: RoleNamespace;
881
+ /** Organization operations — charter, hire, fire, admin, launch, establish. */
882
+ readonly org: OrgNamespace;
883
+ /** Position operations — charge, require, appoint, dismiss. */
884
+ readonly position: PositionNamespace;
885
+ /** Project operations — scope, milestone, enroll, deliver, produce. */
886
+ readonly project: ProjectNamespace;
887
+ /** Product operations — strategy, spec, release, channel, own. */
888
+ readonly product: ProductNamespace;
889
+ /** Census — world-level queries. */
890
+ readonly census: CensusNamespace;
891
+ /** Issue tracking integration. */
892
+ readonly issue: IssueNamespace;
893
+ /** Resource management integration. */
894
+ readonly resource: ResourceNamespace;
895
+ /** Tool schemas + world instructions — the unified contract for any channel adapter. */
896
+ readonly protocol: Protocol;
897
+ /** Universal JSON-RPC 2.0 dispatch. */
898
+ rpc<T = unknown>(request: JsonRpcRequest): Promise<JsonRpcResponse<T>>;
899
+ /** Internal access for testing — not part of the public contract. */
900
+ _internal(): Promise<RoleXInternal>;
901
+ }
902
+ interface BuilderConfig {
903
+ platform: Platform;
904
+ renderer: Renderer;
905
+ /** Built-in prototypes to apply on initialization (e.g. genesis). */
906
+ prototypes?: readonly PrototypeData[];
907
+ }
908
+ declare function createBuilder(config: BuilderConfig): RoleXBuilder;
909
+
476
910
  /**
477
911
  * Find — unified node lookup with priority-based disambiguation.
478
912
  *
@@ -549,47 +983,6 @@ declare const directives: Record<string, Record<string, string>>;
549
983
  */
550
984
  declare function toArgs(op: string, args: Record<string, unknown>): unknown[];
551
985
 
552
- /**
553
- * Schema types for RoleX instruction definitions.
554
- *
555
- * These types define the structure of every RoleX operation:
556
- * parameter types, descriptions, and positional arg ordering.
557
- */
558
- /** Supported parameter types for instruction definitions. */
559
- type ParamType = "string" | "number" | "gherkin" | "string[]" | "record";
560
- /** Definition of a single parameter in an instruction. */
561
- interface ParamDef {
562
- type: ParamType;
563
- required: boolean;
564
- description: string;
565
- }
566
- /**
567
- * A single positional argument entry.
568
- *
569
- * - `string` — simple lookup: `args[name]`
570
- * - `{ pack: [...] }` — collect named args into an options object;
571
- * returns `undefined` if all values are absent.
572
- */
573
- type ArgEntry = string | {
574
- pack: readonly string[];
575
- };
576
- /** Full definition of a RoleX instruction (one namespace.method). */
577
- interface InstructionDef {
578
- namespace: string;
579
- method: string;
580
- /** Parameter definitions — keyed by param name, used for MCP/CLI schema generation. */
581
- params: Record<string, ParamDef>;
582
- /** Positional argument order — maps named args to method call positions. */
583
- args: readonly ArgEntry[];
584
- }
585
- /** RoleX tool definition — schema for a top-level tool (activate, want, use, etc.). */
586
- interface ToolDef {
587
- /** Tool name (e.g. "activate", "use"). */
588
- name: string;
589
- /** Parameter definitions — keyed by param name. */
590
- params: Record<string, ParamDef>;
591
- }
592
-
593
986
  /**
594
987
  * Instruction set — schema definitions for all RoleX operations.
595
988
  *
@@ -598,27 +991,4 @@ interface ToolDef {
598
991
 
599
992
  declare const instructions: Record<string, InstructionDef>;
600
993
 
601
- /**
602
- * RoleX tool definitions — the single source of truth for all tool schemas.
603
- *
604
- * Channel-agnostic: MCP, CLI, REST, A2A each convert to their own format.
605
- * Description for each tool comes from descriptions/processes via detail().
606
- * This file only defines the parameter schema.
607
- */
608
-
609
- /**
610
- * Protocol — the complete interface contract for channel adapters.
611
- *
612
- * Any adapter (MCP, CLI, REST, A2A) only needs this object
613
- * to know what tools exist and what instructions to present.
614
- */
615
- interface Protocol {
616
- /** All tool definitions with parameter schemas. */
617
- tools: ToolDef[];
618
- /** World-level instructions — the cognitive framework for AI roles. */
619
- instructions: string;
620
- }
621
- /** The protocol instance — single source of truth for all channel adapters. */
622
- declare const protocol: Protocol;
623
-
624
- export { type ApplyResult, type ArgEntry, type CommandContext, type CommandResult, type CommandResultMap, type Commands, type ContextData, type InstructionDef, type Migration, type MigrationRecord, type ParamDef, type ParamType, type Platform, type Protocol, type PrototypeData, type PrototypeRepository, type Renderer, RendererRouter, Role, type RoleDeps, type RoleSnapshot, type RoleX, type RoleXRepository, RoleXService, type ToolDef, abandon, abolish, activate, applyPrototype, appoint, archive, background, born, channel, channelProduct, charge, charter, charterOrg, complete, createCommands, deliverProject, deliverable, deprecate, die, directives, dismiss, disownProduct, dissolve, duty, encounter, enroll, establish, experience, findInState, finish, fire, found, goal, hire, identity, individual, instructions, launch, master, milestone, milestoneProject, mindset, organization, ownProduct, past, plan, planGoal, position, principle, procedure, processes, produceProject, product, project, protocol, realize, reflect, rehire, release, releaseProduct, removeParticipant, requirement, retire, scope, scopeProject, society, spec, specProduct, strategy, strategyProduct, task, toArgs, todo, tone, want, wiki, wikiProject, world };
994
+ export { type ApplyResult, type ArgEntry, type BuilderConfig, type Caller, type CensusNamespace, type CommandContext, type CommandResult, type CommandResultMap, type Commands, type ContextData, type InstructionDef, type IssueNamespace, type JsonRpcError, type JsonRpcRequest, type JsonRpcResponse, type Migration, type MigrationRecord, type OrgNamespace, type ParamDef, type ParamType, type Platform, type PositionNamespace, type ProductNamespace, type ProjectNamespace, type Protocol, type PrototypeData, type PrototypeRepository, type Renderer, RendererRouter, type ResourceNamespace, Role, type RoleDeps, type RoleNamespace, type RoleSnapshot, type RoleX, type RoleXBuilder, type RoleXInternal, type RoleXRepository, RoleXService, RpcHandler, type SocietyNamespace, type ToolDef, abandon, abolish, activate, applyPrototype, appoint, archive, background, born, channel, channelProduct, charge, charter, charterOrg, complete, createBuilder, createCommands, deliverProject, deliverable, deprecate, die, directives, dismiss, disownProduct, dissolve, duty, encounter, enroll, establish, experience, findInState, finish, fire, found, goal, hire, identity, individual, instructions, launch, master, milestone, milestoneProject, mindset, organization, ownProduct, past, plan, planGoal, position, principle, procedure, processes, produceProject, product, project, protocol, realize, reflect, rehire, release, releaseProduct, removeParticipant, requirement, retire, scope, scopeProject, society, spec, specProduct, strategy, strategyProduct, task, toArgs, todo, tone, want, wiki, wikiProject, world };