flavor-code 1.2.10 → 1.2.11

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.
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="light" />
7
7
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* http://localhost:* ws://127.0.0.1:* ws://localhost:*; frame-src http://127.0.0.1:* http://localhost:*" />
8
8
  <title>Flavor Code</title>
9
- <script type="module" crossorigin src="./assets/index-BVxdOZFW.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-sgEm4kjf.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="./assets/index-CPxt3vFY.css">
11
11
  </head>
12
12
  <body>
@@ -0,0 +1,6 @@
1
+ export interface PalSocketAddressOptions {
2
+ platform: NodeJS.Platform;
3
+ userScope: string;
4
+ runtimeDir: string;
5
+ }
6
+ export declare function palSocketAddress(options: PalSocketAddressOptions): string;
@@ -0,0 +1,7 @@
1
+ export declare const PAL_AUTH_TOKEN_BYTES = 32;
2
+ export interface PalAuthTokenOptions {
3
+ home?: string;
4
+ random?: (size: number) => Buffer;
5
+ }
6
+ export declare function loadOrCreatePalAuthToken(options?: PalAuthTokenOptions): Promise<string>;
7
+ export declare function validatePalAuthToken(token: string): string;
@@ -0,0 +1,18 @@
1
+ import { PalBrokerServer, type PalBrokerServerOptions } from "./broker.js";
2
+ export interface RunPalBrokerOptions extends PalBrokerServerOptions {
3
+ sweepIntervalMs?: number;
4
+ idleShutdownMs?: number;
5
+ }
6
+ export interface RunningPalBroker {
7
+ server: PalBrokerServer;
8
+ closed: Promise<void>;
9
+ close: () => Promise<void>;
10
+ }
11
+ export interface EnsurePalBrokerOptions {
12
+ address: string;
13
+ timeoutMs?: number;
14
+ retryDelayMs?: number;
15
+ startBroker?: () => Promise<void>;
16
+ }
17
+ export declare function runPalBroker(options: RunPalBrokerOptions): Promise<RunningPalBroker>;
18
+ export declare function ensurePalBrokerRunning(options: EnsurePalBrokerOptions): Promise<void>;
@@ -0,0 +1,156 @@
1
+ import { type BrokerEvent, type CoWorkParticipant, type CoWorkPlan, type CoWorkSnapshot, type DeliveryReceipt, type PalPresence, type PalTaskEvent } from "./protocol.js";
2
+ export type BrokerStateErrorCode = "alias-conflict" | "ambiguous-target" | "not-found" | "invalid-transition" | "stale-epoch" | "capacity";
3
+ export declare class BrokerStateError extends Error {
4
+ readonly code: BrokerStateErrorCode;
5
+ constructor(code: BrokerStateErrorCode, message: string);
6
+ }
7
+ export interface PalBrokerServerOptions {
8
+ address: string;
9
+ platform?: NodeJS.Platform;
10
+ state?: PalBrokerState;
11
+ maxFrameBytes?: number;
12
+ authToken?: string;
13
+ authHome?: string;
14
+ processAlive?: (pid: number) => boolean;
15
+ probeAddress?: (address: string) => Promise<boolean>;
16
+ }
17
+ export declare function isWindowsPipeAddress(address: string, platform?: NodeJS.Platform): boolean;
18
+ export declare class PalBrokerServer {
19
+ readonly address: string;
20
+ lastActivityAt: number;
21
+ private readonly platform;
22
+ private readonly state;
23
+ private readonly maxFrameBytes;
24
+ private readonly server;
25
+ private readonly connections;
26
+ private readonly palConnections;
27
+ private started;
28
+ private ownsAddress;
29
+ private closing?;
30
+ private authToken;
31
+ private readonly authHome;
32
+ private readonly processAlive;
33
+ private readonly probeAddress;
34
+ private endpointLock;
35
+ constructor(options: PalBrokerServerOptions);
36
+ get connectionCount(): number;
37
+ start(): Promise<void>;
38
+ sweep(): void;
39
+ close(): Promise<void>;
40
+ private closeOnce;
41
+ private prepareAddress;
42
+ private releaseEndpointLock;
43
+ private unlinkKnownSocket;
44
+ private accept;
45
+ private remove;
46
+ private receive;
47
+ private handleFrame;
48
+ private dispatch;
49
+ private requireRegistered;
50
+ private authenticates;
51
+ private ok;
52
+ private send;
53
+ private deliver;
54
+ private deliverCoWork;
55
+ }
56
+ export interface PalBrokerStateOptions {
57
+ now?: () => number;
58
+ idFactory?: () => string;
59
+ heartbeatTimeoutMs?: number;
60
+ dedupLimit?: number;
61
+ maxPals?: number;
62
+ maxCoWorks?: number;
63
+ }
64
+ export interface PalRegistration {
65
+ id: string;
66
+ alias: string;
67
+ projectPath: string;
68
+ }
69
+ export interface RouteResult<TEvent extends BrokerEvent> {
70
+ receipt: DeliveryReceipt;
71
+ deliveries: Array<{
72
+ recipientId: string;
73
+ event: TEvent;
74
+ }>;
75
+ }
76
+ export interface CoWorkTransition {
77
+ snapshot: CoWorkSnapshot;
78
+ events: BrokerEvent[];
79
+ }
80
+ export declare function canonicalPlanHash(input: CoWorkPlan): string;
81
+ export declare class PalBrokerState {
82
+ private readonly now;
83
+ private readonly idFactory;
84
+ private readonly heartbeatTimeoutMs;
85
+ private readonly dedupLimit;
86
+ private readonly maxPals;
87
+ private readonly maxCoWorks;
88
+ private readonly pals;
89
+ private readonly aliases;
90
+ private readonly delivered;
91
+ private coWorks;
92
+ constructor(options?: PalBrokerStateOptions);
93
+ register(registration: PalRegistration): PalPresence;
94
+ list(): PalPresence[];
95
+ resolveTarget(target: string): PalPresence;
96
+ heartbeat(palId: string): PalPresence;
97
+ disconnect(palId: string): void;
98
+ routeChat(senderId: string, input: {
99
+ messageId: string;
100
+ target: string;
101
+ message: string;
102
+ }): RouteResult<Extract<BrokerEvent, {
103
+ type: "chat-event";
104
+ }>>;
105
+ routeTask(senderId: string, input: {
106
+ messageId: string;
107
+ target: string;
108
+ goal: string;
109
+ }): RouteResult<PalTaskEvent>;
110
+ proposeCoWork(actorId: string, input: {
111
+ coWorkId: string;
112
+ goal: string;
113
+ participants: CoWorkParticipant[];
114
+ }): CoWorkTransition;
115
+ acceptCoWork(actorId: string, coWorkId: string, epoch: number): CoWorkTransition;
116
+ submitCoWorkPlan(actorId: string, input: CoWorkPlan): CoWorkTransition;
117
+ acceptCoWorkPlan(actorId: string, token: {
118
+ coWorkId: string;
119
+ epoch: number;
120
+ planHash: string;
121
+ }): CoWorkTransition;
122
+ markCoWorkReady(actorId: string, token: {
123
+ coWorkId: string;
124
+ epoch: number;
125
+ planHash: string;
126
+ }): CoWorkTransition;
127
+ completeCoWork(actorId: string, input: {
128
+ coWorkId: string;
129
+ epoch: number;
130
+ planHash: string;
131
+ passed: boolean;
132
+ detail?: string;
133
+ }): CoWorkTransition;
134
+ integrateCoWork(actorId: string, input: {
135
+ coWorkId: string;
136
+ epoch: number;
137
+ planHash: string;
138
+ passed: boolean;
139
+ evidence: string;
140
+ }): CoWorkTransition;
141
+ getCoWork(coWorkId: string): CoWorkSnapshot;
142
+ cancelCoWork(actorId: string, coWorkId: string, _reason: string): CoWorkTransition;
143
+ private sweepExpired;
144
+ private requirePal;
145
+ private duplicateReceipt;
146
+ private rememberDelivery;
147
+ private requireCoWork;
148
+ private requireParticipant;
149
+ private requireRequiredParticipant;
150
+ private requiredIds;
151
+ private assertEpoch;
152
+ private assertPlanToken;
153
+ private transition;
154
+ private mutateCoWork;
155
+ private coWorkEvictionCandidate;
156
+ }
@@ -0,0 +1,109 @@
1
+ import { Socket } from "node:net";
2
+ import { type BrokerEvent, type CoWorkParticipant, type CoWorkPlan, type CoWorkSnapshot, type DeliveryReceipt, type PalPresence } from "./protocol.js";
3
+ export interface PalClientRegistration {
4
+ id: string;
5
+ alias: string;
6
+ projectPath: string;
7
+ }
8
+ export interface PalClientOptions {
9
+ address: string;
10
+ registration: PalClientRegistration;
11
+ requestTimeoutMs?: number;
12
+ heartbeatIntervalMs?: number;
13
+ reconnectMinDelayMs?: number;
14
+ reconnectMaxDelayMs?: number;
15
+ connect?: (address: string) => Socket;
16
+ startBroker?: () => Promise<void>;
17
+ authToken?: string;
18
+ authHome?: string;
19
+ }
20
+ export type CoWorkAction = {
21
+ type: "cowork-accept";
22
+ coWorkId: string;
23
+ epoch: number;
24
+ } | {
25
+ type: "cowork-plan";
26
+ plan: CoWorkPlan;
27
+ } | {
28
+ type: "cowork-plan-accept";
29
+ coWorkId: string;
30
+ epoch: number;
31
+ planHash: string;
32
+ } | {
33
+ type: "cowork-ready";
34
+ coWorkId: string;
35
+ epoch: number;
36
+ planHash: string;
37
+ } | {
38
+ type: "cowork-complete";
39
+ coWorkId: string;
40
+ epoch: number;
41
+ planHash: string;
42
+ passed: boolean;
43
+ detail?: string;
44
+ } | {
45
+ type: "cowork-integration";
46
+ coWorkId: string;
47
+ epoch: number;
48
+ planHash: string;
49
+ passed: boolean;
50
+ evidence: string;
51
+ };
52
+ export declare class PalClient {
53
+ private readonly address;
54
+ private readonly requestTimeoutMs;
55
+ private readonly heartbeatIntervalMs;
56
+ private readonly reconnectMinDelayMs;
57
+ private readonly reconnectMaxDelayMs;
58
+ private readonly connectSocket;
59
+ private readonly startBroker;
60
+ private readonly listeners;
61
+ private readonly pending;
62
+ private readonly seenEvents;
63
+ private registration;
64
+ private socket;
65
+ private buffer;
66
+ private starting;
67
+ private heartbeatTimer;
68
+ private reconnectTimer;
69
+ private connectingReject;
70
+ private reconnectDelayMs;
71
+ private closed;
72
+ private registered;
73
+ private heartbeatPending;
74
+ private authToken;
75
+ private readonly authHome;
76
+ constructor(options: PalClientOptions);
77
+ start(): Promise<PalPresence>;
78
+ list(): Promise<PalPresence[]>;
79
+ rename(alias: string): Promise<PalPresence>;
80
+ sendTask(target: string, message: string, messageId?: string): Promise<DeliveryReceipt>;
81
+ sendChat(target: string, message: string, messageId?: string): Promise<DeliveryReceipt>;
82
+ startCoWork(input: {
83
+ coWorkId?: string;
84
+ goal: string;
85
+ participants: CoWorkParticipant[];
86
+ }): Promise<CoWorkSnapshot>;
87
+ coWorkAction(action: CoWorkAction): Promise<CoWorkSnapshot>;
88
+ coWorkStatus(coWorkId: string): Promise<CoWorkSnapshot>;
89
+ integrateCoWork(input: {
90
+ coWorkId: string;
91
+ epoch: number;
92
+ planHash: string;
93
+ passed: boolean;
94
+ evidence: string;
95
+ }): Promise<CoWorkSnapshot>;
96
+ cancelCoWork(coWorkId: string, reason: string): Promise<CoWorkSnapshot>;
97
+ subscribe(listener: (event: BrokerEvent) => void): () => void;
98
+ close(): Promise<void>;
99
+ private startInternal;
100
+ private openSocket;
101
+ private register;
102
+ private request;
103
+ private receive;
104
+ private emit;
105
+ private handleSocketClose;
106
+ private rejectPending;
107
+ private beginHeartbeat;
108
+ private scheduleReconnect;
109
+ }
@@ -0,0 +1,13 @@
1
+ export interface AcquirePalFileLockOptions {
2
+ path: string;
3
+ endpointLive: () => Promise<boolean>;
4
+ processAlive?: (pid: number) => boolean;
5
+ pid?: number;
6
+ now?: () => number;
7
+ corruptGraceMs?: number;
8
+ }
9
+ export interface PalFileLock {
10
+ path: string;
11
+ release(): Promise<void>;
12
+ }
13
+ export declare function acquirePalFileLock(options: AcquirePalFileLockOptions): Promise<PalFileLock | undefined>;
@@ -0,0 +1,23 @@
1
+ export interface PalTaskPromptInput {
2
+ readonly senderId: string;
3
+ readonly senderAlias: string;
4
+ readonly messageId: string;
5
+ readonly remoteText: string;
6
+ }
7
+ export interface PalCoWorkPromptInput {
8
+ readonly senderId: string;
9
+ readonly senderAlias: string;
10
+ readonly messageId: string;
11
+ readonly coWorkId: string;
12
+ readonly epoch: number;
13
+ readonly planHash: string;
14
+ readonly snapshot: unknown;
15
+ readonly localId?: string;
16
+ }
17
+ export interface PalCoWorkPlanningPromptInput extends Omit<PalCoWorkPromptInput, "messageId" | "planHash"> {
18
+ readonly action: "PROPOSE" | "PLAN";
19
+ readonly planHash: string | null;
20
+ }
21
+ export declare function buildPalTaskPrompt(input: PalTaskPromptInput): string;
22
+ export declare function buildPalCoWorkPrompt(input: PalCoWorkPromptInput): string;
23
+ export declare function buildPalCoWorkPlanningPrompt(input: PalCoWorkPlanningPromptInput): string;