@iniesta8888/agent-live 0.3.0
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/CODE_OF_CONDUCT.md +7 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/SECURITY.md +13 -0
- package/dist/adapter-sdk/index.d.ts +45 -0
- package/dist/adapter-sdk/index.d.ts.map +1 -0
- package/dist/adapter-sdk/index.js +106 -0
- package/dist/adapter-sdk/index.js.map +1 -0
- package/dist/content/compiler.d.ts +31 -0
- package/dist/content/compiler.d.ts.map +1 -0
- package/dist/content/compiler.js +218 -0
- package/dist/content/compiler.js.map +1 -0
- package/dist/content/graph-validator.d.ts +56 -0
- package/dist/content/graph-validator.d.ts.map +1 -0
- package/dist/content/graph-validator.js +226 -0
- package/dist/content/graph-validator.js.map +1 -0
- package/dist/content/library.d.ts +4 -0
- package/dist/content/library.d.ts.map +1 -0
- package/dist/content/library.js +45 -0
- package/dist/content/library.js.map +1 -0
- package/dist/content/registry.d.ts +34 -0
- package/dist/content/registry.d.ts.map +1 -0
- package/dist/content/registry.js +130 -0
- package/dist/content/registry.js.map +1 -0
- package/dist/content/runtime-content.d.ts +63 -0
- package/dist/content/runtime-content.d.ts.map +1 -0
- package/dist/content/runtime-content.js +78 -0
- package/dist/content/runtime-content.js.map +1 -0
- package/dist/content/schema.d.ts +142 -0
- package/dist/content/schema.d.ts.map +1 -0
- package/dist/content/schema.js +280 -0
- package/dist/content/schema.js.map +1 -0
- package/dist/content/validator.d.ts +35 -0
- package/dist/content/validator.d.ts.map +1 -0
- package/dist/content/validator.js +205 -0
- package/dist/content/validator.js.map +1 -0
- package/dist/core/agents.d.ts +56 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +148 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/limits.d.ts +15 -0
- package/dist/core/limits.d.ts.map +1 -0
- package/dist/core/limits.js +16 -0
- package/dist/core/limits.js.map +1 -0
- package/dist/core/mapping.d.ts +17 -0
- package/dist/core/mapping.d.ts.map +1 -0
- package/dist/core/mapping.js +94 -0
- package/dist/core/mapping.js.map +1 -0
- package/dist/core/protocol.d.ts +105 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +6 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/state.d.ts +49 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/state.js +216 -0
- package/dist/core/state.js.map +1 -0
- package/dist/creator/commands.d.ts +19 -0
- package/dist/creator/commands.d.ts.map +1 -0
- package/dist/creator/commands.js +44 -0
- package/dist/creator/commands.js.map +1 -0
- package/dist/creator/mode.d.ts +10 -0
- package/dist/creator/mode.d.ts.map +1 -0
- package/dist/creator/mode.js +23 -0
- package/dist/creator/mode.js.map +1 -0
- package/dist/creator/service.d.ts +199 -0
- package/dist/creator/service.d.ts.map +1 -0
- package/dist/creator/service.js +159 -0
- package/dist/creator/service.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/agent-live-runtime.d.ts +17 -0
- package/dist/runtime/agent-live-runtime.d.ts.map +1 -0
- package/dist/runtime/agent-live-runtime.js +50 -0
- package/dist/runtime/agent-live-runtime.js.map +1 -0
- package/dist/runtime/content-service.d.ts +75 -0
- package/dist/runtime/content-service.d.ts.map +1 -0
- package/dist/runtime/content-service.js +60 -0
- package/dist/runtime/content-service.js.map +1 -0
- package/dist/runtime/resource-guard.d.ts +17 -0
- package/dist/runtime/resource-guard.d.ts.map +1 -0
- package/dist/runtime/resource-guard.js +54 -0
- package/dist/runtime/resource-guard.js.map +1 -0
- package/dist/runtime/server.d.ts +39 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +286 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/web/app.d.ts +1 -0
- package/dist/web/app.js +1317 -0
- package/dist/web/index.html +45 -0
- package/dist/web/office.js +350 -0
- package/dist/web/sprites.js +185 -0
- package/dist/web/style.css +288 -0
- package/dist/web/v2/bootstrap.js +276 -0
- package/dist/web/v2/content/README.md +17 -0
- package/dist/web/v2/content/agent-skins/studio-team.json +33 -0
- package/dist/web/v2/content/agent-skins/tiny-developers.json +33 -0
- package/dist/web/v2/content/atmospheres/default.json +13 -0
- package/dist/web/v2/content/atmospheres/rainy-night.json +37 -0
- package/dist/web/v2/content/catalog.json +14 -0
- package/dist/web/v2/content/component-library/activity-implementations.json +873 -0
- package/dist/web/v2/content/component-library/activity-recipes.json +25 -0
- package/dist/web/v2/content/component-library/agent-profile-templates.json +18 -0
- package/dist/web/v2/content/component-library/catalog.json +38 -0
- package/dist/web/v2/content/component-library/npc-templates.json +42 -0
- package/dist/web/v2/content/component-library/props.json +41 -0
- package/dist/web/v2/content/environments/local-office.json +31 -0
- package/dist/web/v2/content/environments/rainy-night.json +28 -0
- package/dist/web/v2/content/environments/static-office.json +27 -0
- package/dist/web/v2/content/layouts/boardroom-office.json +122 -0
- package/dist/web/v2/content/layouts/demo-office.json +88 -0
- package/dist/web/v2/content/layouts/lively-office.json +96 -0
- package/dist/web/v2/content/layouts/old-school-office.json +154 -0
- package/dist/web/v2/content/layouts/tech-open-office.json +132 -0
- package/dist/web/v2/content/life-activities/boardroom-routines.json +67 -0
- package/dist/web/v2/content/life-activities/none.json +10 -0
- package/dist/web/v2/content/life-activities/office-basics.json +39 -0
- package/dist/web/v2/content/life-activities/old-school-routines.json +74 -0
- package/dist/web/v2/content/life-activities/tech-office-routines.json +148 -0
- package/dist/web/v2/content/npcs/boardroom-staff.json +54 -0
- package/dist/web/v2/content/npcs/none.json +10 -0
- package/dist/web/v2/content/npcs/office-staff.json +25 -0
- package/dist/web/v2/content/npcs/old-school-staff.json +39 -0
- package/dist/web/v2/content/npcs/tech-office-staff.json +40 -0
- package/dist/web/v2/content/official-offices/boardroom-office.json +25 -0
- package/dist/web/v2/content/official-offices/old-school-office.json +25 -0
- package/dist/web/v2/content/official-offices/tech-open-office.json +25 -0
- package/dist/web/v2/content/presets/boardroom-office.json +21 -0
- package/dist/web/v2/content/presets/cozy-studio.json +19 -0
- package/dist/web/v2/content/presets/demo-office.json +19 -0
- package/dist/web/v2/content/presets/lively-office.json +19 -0
- package/dist/web/v2/content/presets/night-shift.json +19 -0
- package/dist/web/v2/content/presets/old-school-office.json +20 -0
- package/dist/web/v2/content/presets/refined-demo.json +20 -0
- package/dist/web/v2/content/presets/tech-open-office.json +21 -0
- package/dist/web/v2/content/props/default-office.json +23 -0
- package/dist/web/v2/content/props/extended-office.json +39 -0
- package/dist/web/v2/content/props/tech-office.json +28 -0
- package/dist/web/v2/content/styles/pixel-classic.json +160 -0
- package/dist/web/v2/content/styles/warm-studio.json +150 -0
- package/dist/web/v2/environment-runtime.d.ts +1 -0
- package/dist/web/v2/environment-runtime.js +138 -0
- package/dist/web/v2/graph-validator.d.ts +55 -0
- package/dist/web/v2/graph-validator.js +225 -0
- package/dist/web/v2/i18n.js +54 -0
- package/dist/web/v2/locales/en.json +209 -0
- package/dist/web/v2/locales/zh-CN.json +52 -0
- package/dist/web/v2/office-engine.d.ts +1 -0
- package/dist/web/v2/office-engine.js +145 -0
- package/dist/web/v2/office-renderer.d.ts +1 -0
- package/dist/web/v2/office-renderer.js +843 -0
- package/dist/web/v2/parity.html +10 -0
- package/dist/web/v2/parity.js +82 -0
- package/dist/web/v2/sprite-renderer.d.ts +1 -0
- package/dist/web/v2/sprite-renderer.js +242 -0
- package/dist/web/v2/static-content.js +48 -0
- package/dist/web/v2/style.css +140 -0
- package/dist/web/v2.html +68 -0
- package/docs/ADAPTER-DEVELOPMENT.md +328 -0
- package/docs/ADAPTER-SDK.md +109 -0
- package/docs/ARCHITECTURE.md +223 -0
- package/docs/COMPONENT-LIBRARY.md +212 -0
- package/docs/CUSTOMIZATION.md +163 -0
- package/docs/DEVELOPER.md +186 -0
- package/docs/DSH-ADAPTER-DESIGN.md +173 -0
- package/docs/OFFICE-THEMES.md +516 -0
- package/docs/PRESET-CONFIG.md +460 -0
- package/docs/RELEASE-CHECK.md +23 -0
- package/docs/TECHNICAL.md +515 -0
- package/docs/USING-CODEX.md +24 -0
- package/docs/USING-DSH.md +44 -0
- package/docs/USING-PI.md +50 -0
- package/docs/VISION.md +146 -0
- package/examples/adapter/local-office.mjs +52 -0
- package/package.json +89 -0
- package/skills/agent-live-adapter-builder/SKILL.md +30 -0
- package/skills/agent-live-adapter-builder/agents/openai.yaml +4 -0
- package/skills/agent-live-adapter-builder/references/investigation.md +9 -0
- package/skills/agent-live-adapter-builder/references/review.md +7 -0
- package/skills/agent-live-adapter-builder/scripts/create-adapter.mjs +26 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-neutral wire protocol between coding-agent adapters and Agent Live renderers.
|
|
3
|
+
* Kept dependency-free so both sides can share the vocabulary without a build step.
|
|
4
|
+
*/
|
|
5
|
+
export type AgentState = "idle" | "thinking" | "working" | "waiting" | "talking" | "done" | "error";
|
|
6
|
+
/** Where the character physically goes in the office for a given piece of work. */
|
|
7
|
+
export type OfficeAction = "type" | "archive" | "server" | "whiteboard" | "phone" | "delegate" | "coffee";
|
|
8
|
+
export interface AgentView {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
role: string;
|
|
12
|
+
/** Parent agent id for delegated workers. */
|
|
13
|
+
parent?: string;
|
|
14
|
+
state: AgentState;
|
|
15
|
+
/** Short human label of what it is doing right now. */
|
|
16
|
+
detail?: string;
|
|
17
|
+
action?: OfficeAction;
|
|
18
|
+
task?: string;
|
|
19
|
+
thought?: string;
|
|
20
|
+
model?: string;
|
|
21
|
+
tokens: number;
|
|
22
|
+
cost: number;
|
|
23
|
+
toolCalls: number;
|
|
24
|
+
joinedAt: number;
|
|
25
|
+
seat?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface LogItem {
|
|
28
|
+
at: number;
|
|
29
|
+
agentId: string;
|
|
30
|
+
kind: "thought" | "say" | "tool" | "delegate" | "join" | "leave" | "system";
|
|
31
|
+
text: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SessionInfo {
|
|
34
|
+
cwd: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
thinkingLevel?: string;
|
|
37
|
+
busy: boolean;
|
|
38
|
+
turns: number;
|
|
39
|
+
startedAt: number;
|
|
40
|
+
}
|
|
41
|
+
export type OfficeDelta = {
|
|
42
|
+
type: "session";
|
|
43
|
+
session: SessionInfo;
|
|
44
|
+
} | {
|
|
45
|
+
type: "agent_join";
|
|
46
|
+
agent: AgentView;
|
|
47
|
+
} | {
|
|
48
|
+
type: "agent_leave";
|
|
49
|
+
id: string;
|
|
50
|
+
ok?: boolean;
|
|
51
|
+
} | {
|
|
52
|
+
type: "agent_state";
|
|
53
|
+
id: string;
|
|
54
|
+
state: AgentState;
|
|
55
|
+
detail?: string;
|
|
56
|
+
} | {
|
|
57
|
+
type: "task";
|
|
58
|
+
id: string;
|
|
59
|
+
task: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "thought";
|
|
62
|
+
id: string;
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "say";
|
|
66
|
+
id: string;
|
|
67
|
+
text: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "action";
|
|
70
|
+
id: string;
|
|
71
|
+
action: OfficeAction;
|
|
72
|
+
label: string;
|
|
73
|
+
toolCallId: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "action_end";
|
|
76
|
+
id: string;
|
|
77
|
+
toolCallId: string;
|
|
78
|
+
ok: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
type: "delegate";
|
|
81
|
+
from: string;
|
|
82
|
+
to: string;
|
|
83
|
+
task: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: "usage";
|
|
86
|
+
id: string;
|
|
87
|
+
tokens: number;
|
|
88
|
+
cost: number;
|
|
89
|
+
} | {
|
|
90
|
+
type: "log";
|
|
91
|
+
item: LogItem;
|
|
92
|
+
};
|
|
93
|
+
/** One replayable engine event with its original wall-clock timestamp. */
|
|
94
|
+
export interface RecordedOfficeEvent {
|
|
95
|
+
at: number;
|
|
96
|
+
event: OfficeDelta;
|
|
97
|
+
}
|
|
98
|
+
export type OfficeEvent = {
|
|
99
|
+
type: "snapshot";
|
|
100
|
+
agents: AgentView[];
|
|
101
|
+
log: LogItem[];
|
|
102
|
+
session: SessionInfo;
|
|
103
|
+
history: RecordedOfficeEvent[];
|
|
104
|
+
} | OfficeDelta;
|
|
105
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/core/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,UAAU,GACnB,MAAM,GACN,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,MAAM,GACN,OAAO,CAAC;AAEX,mFAAmF;AACnF,MAAM,MAAM,YAAY,GACrB,MAAM,GACN,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,OAAO,GACP,UAAU,GACV,QAAQ,CAAC;AAEZ,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,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zC;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CAClB,GACD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElC,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,WAAW,GACpB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,GAAG,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAAE,GAC/G,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../plugins/agent-live/src/core/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AgentState, AgentView, LogItem, OfficeAction, OfficeEvent, SessionInfo } from "./protocol.ts";
|
|
2
|
+
type Listener = (event: OfficeEvent) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Single source of truth for the office. Holds one character per agent, keeps a
|
|
5
|
+
* rolling activity log, and pushes deltas to every connected renderer.
|
|
6
|
+
*/
|
|
7
|
+
export declare class OfficeState {
|
|
8
|
+
private agents;
|
|
9
|
+
private log;
|
|
10
|
+
private history;
|
|
11
|
+
private listeners;
|
|
12
|
+
private session;
|
|
13
|
+
private thoughtBuffers;
|
|
14
|
+
private thoughtTimer;
|
|
15
|
+
private seats;
|
|
16
|
+
constructor(cwd: string);
|
|
17
|
+
subscribe(listener: Listener): () => void;
|
|
18
|
+
private emit;
|
|
19
|
+
snapshot(includeHistory?: boolean): Extract<OfficeEvent, {
|
|
20
|
+
type: "snapshot";
|
|
21
|
+
}>;
|
|
22
|
+
getAgent(id: string): AgentView | undefined;
|
|
23
|
+
sessionBusy(): boolean;
|
|
24
|
+
hasClients(): boolean;
|
|
25
|
+
updateSession(patch: Partial<SessionInfo>): void;
|
|
26
|
+
private claimSeat;
|
|
27
|
+
join(id: string, init: {
|
|
28
|
+
name: string;
|
|
29
|
+
role: string;
|
|
30
|
+
parent?: string;
|
|
31
|
+
model?: string;
|
|
32
|
+
task?: string;
|
|
33
|
+
}): AgentView | undefined;
|
|
34
|
+
leave(id: string, ok?: boolean): void;
|
|
35
|
+
setState(id: string, state: AgentState, detail?: string): void;
|
|
36
|
+
setTask(id: string, task: string): void;
|
|
37
|
+
/** Thinking tokens arrive fast; batch them so the renderer gets readable chunks. */
|
|
38
|
+
pushThought(id: string, delta: string): void;
|
|
39
|
+
flushThoughts(force?: boolean): void;
|
|
40
|
+
say(id: string, text: string): void;
|
|
41
|
+
startAction(id: string, toolCallId: string, action: OfficeAction, label: string): void;
|
|
42
|
+
endAction(id: string, toolCallId: string, ok: boolean): void;
|
|
43
|
+
delegate(from: string, to: string, task: string): void;
|
|
44
|
+
addUsage(id: string, tokens: number, cost: number): void;
|
|
45
|
+
addLog(agentId: string, kind: LogItem["kind"], text: string, broadcast?: boolean): void;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/core/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,YAAY,EAEZ,WAAW,EAEX,WAAW,EACX,MAAM,eAAe,CAAC;AASvB,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAE7C;;;GAGG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,YAAY,CAA4C;IAChE,OAAO,CAAC,KAAK,CAAqB;gBAEtB,GAAG,EAAE,MAAM;IASvB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAKzC,OAAO,CAAC,IAAI;IAaZ,QAAQ,CAAC,cAAc,UAAO,GAAG,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC;IAU3E,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI3C,WAAW,IAAI,OAAO;IAItB,UAAU,IAAI,OAAO;IAIrB,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAKhD,OAAO,CAAC,SAAS;IAUjB,IAAI,CACH,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC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
|
+
const MAX_HISTORY = 4000;
|
|
4
|
+
const THOUGHT_FLUSH_MS = 180;
|
|
5
|
+
/** Avoid emitting one-character bubbles at the start of a reasoning stream. */
|
|
6
|
+
const MIN_THOUGHT_CHARS = 12;
|
|
7
|
+
/**
|
|
8
|
+
* Single source of truth for the office. Holds one character per agent, keeps a
|
|
9
|
+
* rolling activity log, and pushes deltas to every connected renderer.
|
|
10
|
+
*/
|
|
11
|
+
export class OfficeState {
|
|
12
|
+
agents = new Map();
|
|
13
|
+
log = [];
|
|
14
|
+
history = [];
|
|
15
|
+
listeners = new Set();
|
|
16
|
+
session;
|
|
17
|
+
thoughtBuffers = new Map();
|
|
18
|
+
thoughtTimer;
|
|
19
|
+
seats = new Set();
|
|
20
|
+
constructor(cwd) {
|
|
21
|
+
this.session = {
|
|
22
|
+
cwd,
|
|
23
|
+
busy: false,
|
|
24
|
+
turns: 0,
|
|
25
|
+
startedAt: Date.now(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
subscribe(listener) {
|
|
29
|
+
this.listeners.add(listener);
|
|
30
|
+
return () => this.listeners.delete(listener);
|
|
31
|
+
}
|
|
32
|
+
emit(event) {
|
|
33
|
+
// Keep the journal independent from live AgentView objects and consumers.
|
|
34
|
+
this.history.push({ at: Date.now(), event: structuredClone(event) });
|
|
35
|
+
if (this.history.length > MAX_HISTORY)
|
|
36
|
+
this.history.shift();
|
|
37
|
+
for (const listener of this.listeners) {
|
|
38
|
+
try {
|
|
39
|
+
listener(structuredClone(event));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// A dead renderer must never break the agent loop.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
snapshot(includeHistory = true) {
|
|
47
|
+
return structuredClone({
|
|
48
|
+
type: "snapshot",
|
|
49
|
+
agents: [...this.agents.values()],
|
|
50
|
+
log: this.log.slice(-60),
|
|
51
|
+
session: this.session,
|
|
52
|
+
history: includeHistory ? this.history.slice() : [],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getAgent(id) {
|
|
56
|
+
return this.agents.get(id);
|
|
57
|
+
}
|
|
58
|
+
sessionBusy() {
|
|
59
|
+
return this.session.busy;
|
|
60
|
+
}
|
|
61
|
+
hasClients() {
|
|
62
|
+
return this.listeners.size > 0;
|
|
63
|
+
}
|
|
64
|
+
updateSession(patch) {
|
|
65
|
+
this.session = { ...this.session, ...patch };
|
|
66
|
+
this.emit({ type: "session", session: this.session });
|
|
67
|
+
}
|
|
68
|
+
claimSeat() {
|
|
69
|
+
for (let i = 0; i < SCENE_LIMITS.seats; i++) {
|
|
70
|
+
if (!this.seats.has(i)) {
|
|
71
|
+
this.seats.add(i);
|
|
72
|
+
return i;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
join(id, init) {
|
|
78
|
+
const existing = this.agents.get(id);
|
|
79
|
+
if (existing) {
|
|
80
|
+
Object.assign(existing, init);
|
|
81
|
+
this.emit({ type: "agent_join", agent: existing });
|
|
82
|
+
return existing;
|
|
83
|
+
}
|
|
84
|
+
if (this.agents.size >= SCENE_LIMITS.agents)
|
|
85
|
+
return undefined;
|
|
86
|
+
const seat = this.claimSeat();
|
|
87
|
+
const agent = {
|
|
88
|
+
id,
|
|
89
|
+
state: "idle",
|
|
90
|
+
tokens: 0,
|
|
91
|
+
cost: 0,
|
|
92
|
+
toolCalls: 0,
|
|
93
|
+
joinedAt: Date.now(),
|
|
94
|
+
...(seat >= 0 ? { seat } : {}),
|
|
95
|
+
...init,
|
|
96
|
+
};
|
|
97
|
+
this.agents.set(id, agent);
|
|
98
|
+
this.emit({ type: "agent_join", agent });
|
|
99
|
+
this.addLog(id, "join", `${agent.name} 上班了`);
|
|
100
|
+
return agent;
|
|
101
|
+
}
|
|
102
|
+
leave(id, ok) {
|
|
103
|
+
const agent = this.agents.get(id);
|
|
104
|
+
if (!agent)
|
|
105
|
+
return;
|
|
106
|
+
if (agent.seat !== undefined)
|
|
107
|
+
this.seats.delete(agent.seat);
|
|
108
|
+
this.agents.delete(id);
|
|
109
|
+
this.emit({ type: "agent_leave", id, ok });
|
|
110
|
+
this.addLog(id, "leave", `${agent.name} ${ok === true ? "交付完成,下班" : ok === false ? "异常退出" : "结束工作"}`);
|
|
111
|
+
}
|
|
112
|
+
setState(id, state, detail) {
|
|
113
|
+
const agent = this.agents.get(id);
|
|
114
|
+
if (!agent)
|
|
115
|
+
return;
|
|
116
|
+
agent.state = state;
|
|
117
|
+
agent.detail = detail;
|
|
118
|
+
this.emit({ type: "agent_state", id, state, detail });
|
|
119
|
+
}
|
|
120
|
+
setTask(id, task) {
|
|
121
|
+
const agent = this.agents.get(id);
|
|
122
|
+
if (!agent)
|
|
123
|
+
return;
|
|
124
|
+
agent.task = task;
|
|
125
|
+
this.emit({ type: "task", id, task });
|
|
126
|
+
}
|
|
127
|
+
/** Thinking tokens arrive fast; batch them so the renderer gets readable chunks. */
|
|
128
|
+
pushThought(id, delta) {
|
|
129
|
+
if (!delta)
|
|
130
|
+
return;
|
|
131
|
+
this.thoughtBuffers.set(id, (this.thoughtBuffers.get(id) ?? "") + delta);
|
|
132
|
+
if (this.thoughtTimer)
|
|
133
|
+
return;
|
|
134
|
+
this.thoughtTimer = setTimeout(() => {
|
|
135
|
+
this.thoughtTimer = undefined;
|
|
136
|
+
this.flushThoughts(false);
|
|
137
|
+
}, THOUGHT_FLUSH_MS);
|
|
138
|
+
if (typeof this.thoughtTimer.unref === "function")
|
|
139
|
+
this.thoughtTimer.unref();
|
|
140
|
+
}
|
|
141
|
+
flushThoughts(force = true) {
|
|
142
|
+
for (const [id, text] of this.thoughtBuffers) {
|
|
143
|
+
const clean = text.replace(/\s+/g, " ").trim();
|
|
144
|
+
if (!force && clean.length < MIN_THOUGHT_CHARS)
|
|
145
|
+
continue;
|
|
146
|
+
this.thoughtBuffers.delete(id);
|
|
147
|
+
if (!clean)
|
|
148
|
+
continue;
|
|
149
|
+
const agent = this.agents.get(id);
|
|
150
|
+
if (agent)
|
|
151
|
+
agent.thought = clean.slice(-160);
|
|
152
|
+
this.emit({ type: "thought", id, text: clean });
|
|
153
|
+
this.addLog(id, "thought", clean, false);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
say(id, text) {
|
|
157
|
+
const clean = text.replace(/\s+/g, " ").trim();
|
|
158
|
+
if (!clean)
|
|
159
|
+
return;
|
|
160
|
+
this.emit({ type: "say", id, text: clean.slice(0, 400) });
|
|
161
|
+
this.addLog(id, "say", clean.slice(0, 400), false);
|
|
162
|
+
}
|
|
163
|
+
startAction(id, toolCallId, action, label) {
|
|
164
|
+
const agent = this.agents.get(id);
|
|
165
|
+
if (agent) {
|
|
166
|
+
agent.action = action;
|
|
167
|
+
agent.toolCalls += 1;
|
|
168
|
+
agent.state = "working";
|
|
169
|
+
agent.detail = label;
|
|
170
|
+
}
|
|
171
|
+
this.emit({ type: "action", id, action, label, toolCallId });
|
|
172
|
+
this.addLog(id, "tool", label, false);
|
|
173
|
+
}
|
|
174
|
+
endAction(id, toolCallId, ok) {
|
|
175
|
+
const agent = this.agents.get(id);
|
|
176
|
+
if (agent)
|
|
177
|
+
agent.action = undefined;
|
|
178
|
+
this.emit({ type: "action_end", id, toolCallId, ok });
|
|
179
|
+
}
|
|
180
|
+
delegate(from, to, task) {
|
|
181
|
+
this.emit({ type: "delegate", from, to, task });
|
|
182
|
+
const fromName = this.agents.get(from)?.name ?? from;
|
|
183
|
+
const toName = this.agents.get(to)?.name ?? to;
|
|
184
|
+
this.addLog(from, "delegate", `${fromName} → ${toName}: ${task.slice(0, 120)}`);
|
|
185
|
+
}
|
|
186
|
+
addUsage(id, tokens, cost) {
|
|
187
|
+
const agent = this.agents.get(id);
|
|
188
|
+
if (!agent)
|
|
189
|
+
return;
|
|
190
|
+
if (Number.isFinite(tokens) && tokens >= 0)
|
|
191
|
+
agent.tokens = tokens;
|
|
192
|
+
if (Number.isFinite(cost) && cost >= 0)
|
|
193
|
+
agent.cost = cost;
|
|
194
|
+
this.emit({ type: "usage", id, tokens: agent.tokens, cost: agent.cost });
|
|
195
|
+
}
|
|
196
|
+
addLog(agentId, kind, text, broadcast = true) {
|
|
197
|
+
const item = { at: Date.now(), agentId, kind, text };
|
|
198
|
+
this.log.push(item);
|
|
199
|
+
if (this.log.length > MAX_LOG)
|
|
200
|
+
this.log.shift();
|
|
201
|
+
if (broadcast)
|
|
202
|
+
this.emit({ type: "log", item });
|
|
203
|
+
}
|
|
204
|
+
dispose() {
|
|
205
|
+
if (this.thoughtTimer)
|
|
206
|
+
clearTimeout(this.thoughtTimer);
|
|
207
|
+
this.thoughtTimer = undefined;
|
|
208
|
+
this.thoughtBuffers.clear();
|
|
209
|
+
this.listeners.clear();
|
|
210
|
+
this.agents.clear();
|
|
211
|
+
this.seats.clear();
|
|
212
|
+
this.log = [];
|
|
213
|
+
this.history = [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../plugins/agent-live/src/core/state.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAI7B;;;GAGG;AACH,MAAM,OAAO,WAAW;IACf,MAAM,GAAG,IAAI,GAAG,EAAqB,CAAC;IACtC,GAAG,GAAc,EAAE,CAAC;IACpB,OAAO,GAA0B,EAAE,CAAC;IACpC,SAAS,GAAG,IAAI,GAAG,EAAY,CAAC;IAChC,OAAO,CAAc;IACrB,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,YAAY,CAA4C;IACxD,KAAK,GAAG,IAAI,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AAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,OAAO;QACN,IAAI,IAAI,CAAC,YAAY;YAAE,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACnB,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CreatorService } from "./service.ts";
|
|
2
|
+
type CommandResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
data: unknown;
|
|
5
|
+
adjustments?: unknown[];
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
error: string;
|
|
9
|
+
issues?: unknown[];
|
|
10
|
+
adjustments?: unknown[];
|
|
11
|
+
};
|
|
12
|
+
/** Closed command surface used by every host integration; it never executes arbitrary code or paths. */
|
|
13
|
+
export declare class CreatorCommandRouter {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(creator: CreatorService);
|
|
16
|
+
execute(value: unknown): Promise<CommandResult>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,KAAK,aAAa,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAYtJ,wGAAwG;AACxG,qBAAa,oBAAoB;;gBAGpB,OAAO,EAAE,cAAc;IAE7B,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAwBrD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { COMPONENT_CATEGORIES } from "./service.js";
|
|
2
|
+
function object(value) {
|
|
3
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function exact(input, fields) {
|
|
6
|
+
const allowed = new Set(["command", ...fields]);
|
|
7
|
+
const unknown = Object.keys(input).filter((key) => !allowed.has(key));
|
|
8
|
+
if (unknown.length)
|
|
9
|
+
throw new Error(`unknown command field(s): ${unknown.join(", ")}`);
|
|
10
|
+
}
|
|
11
|
+
/** Closed command surface used by every host integration; it never executes arbitrary code or paths. */
|
|
12
|
+
export class CreatorCommandRouter {
|
|
13
|
+
#creator;
|
|
14
|
+
constructor(creator) { this.#creator = creator; }
|
|
15
|
+
async execute(value) {
|
|
16
|
+
try {
|
|
17
|
+
if (!object(value) || typeof value.command !== "string")
|
|
18
|
+
throw new Error("command is required");
|
|
19
|
+
switch (value.command) {
|
|
20
|
+
case "list_offices":
|
|
21
|
+
exact(value, []);
|
|
22
|
+
return { ok: true, data: await this.#creator.listOffices() };
|
|
23
|
+
case "list_components":
|
|
24
|
+
exact(value, ["category"]);
|
|
25
|
+
if (value.category !== undefined && !COMPONENT_CATEGORIES.includes(value.category))
|
|
26
|
+
throw new Error(`unknown component category ${String(value.category)}`);
|
|
27
|
+
return { ok: true, data: await this.#creator.listComponents(value.category) };
|
|
28
|
+
case "customize": {
|
|
29
|
+
exact(value, ["base", "patch"]);
|
|
30
|
+
if (value.base !== undefined && (typeof value.base !== "string" || !value.base))
|
|
31
|
+
throw new Error("base must be a non-empty string");
|
|
32
|
+
const result = await this.#creator.customize(value.patch, value.base);
|
|
33
|
+
return result.saved ? { ok: true, data: result, adjustments: result.adjustments } : { ok: false, error: "Office customization was rejected; the current office was not changed", issues: result.errors, adjustments: result.adjustments };
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`unknown Creator command ${value.command}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return { ok: false, error: error.message };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,cAAc,CAAC;AAI5E,SAAS,MAAM,CAAC,KAAc;IAC7B,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,KAAK,CAAC,KAA8B,EAAE,MAAgB;IAC9D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,IAAI,OAAO,C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I,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;wBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;oBACpI,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAA0B,CAAC,CAAC;oBAC5F,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,uEAAuE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;gBAC3O,CAAC;gBACD;oBACC,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9D,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC;QACvD,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CREATOR_MODE_CONTEXT = "Agent Live Creator Mode is active for this session.\nTreat office-related natural language as a request to modify the currently selected Custom Office and use the agent_live_creator tool.\nThe currently selected Office is the only edit target. Do not inspect files, search for another copy, deliberate about replacement, invent a new Office id, or pass base/id unless the user explicitly selected another listed Office.\nOn the first edit, call list_components with the default compact summary at most once to obtain the current Agent Profile, text areas, and NPC ids. Then call customize immediately. Do not call list_offices or broader component categories unless the request genuinely needs an unknown choice.\nFor common edits, use these internal Patch shapes: agentProfile { template: \"builtin/host-agent\", name?, title? }; texts { company?, notice?, slogan? }; npcs { upsert: [{ id, template?, name?, title?, gender?, spawn?, pose? }], remove?: [id] }. Rename an existing NPC by its summary id. Add an ordinary colleague with a unique id and template \"builtin/colleague\"; omitted profile and appearance are resolved deterministically.\nDo not expose schemas, patches, or component ids unless explicitly asked for implementation details.\nIf a request is unrelated to the office or ambiguous, do not perform it. Explain that Creator Mode is active and offer exactly these choices: continue editing, /agent-live list presets, /agent-live preset <number or name>, /agent-live custom, or /agent-live exit.\nMap a request like \"make me a police station\" onto the closest complete Preset Office, then change its name, people, identities, furniture, style and activities. If the request needs a brand-new room structure (walls, areas, lanes, seats or work stations), say that it requires adding a new Office Preset and therefore a source change; never offer to swap a room in place.\nAn Office keeps its room. Moving to another room means selecting that Preset Office and editing a copy of it.\nAfter every response, state that Creator Mode remains active and mention /agent-live exit.";
|
|
2
|
+
/** Host-neutral, in-memory Creator state keyed by the host's stable session identity. */
|
|
3
|
+
export declare class CreatorModeRegistry {
|
|
4
|
+
#private;
|
|
5
|
+
enter(sessionId: string): void;
|
|
6
|
+
exit(sessionId: string): boolean;
|
|
7
|
+
isActive(sessionId: string): boolean;
|
|
8
|
+
clear(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/mode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,+iEAS0D,CAAC;AAE5F,yFAAyF;AACzF,qBAAa,mBAAmB;;IAG/B,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAK9B,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAEhC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAEpC,KAAK,IAAI,IAAI;CACb"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const CREATOR_MODE_CONTEXT = `Agent Live Creator Mode is active for this session.
|
|
2
|
+
Treat office-related natural language as a request to modify the currently selected Custom Office and use the agent_live_creator tool.
|
|
3
|
+
The currently selected Office is the only edit target. Do not inspect files, search for another copy, deliberate about replacement, invent a new Office id, or pass base/id unless the user explicitly selected another listed Office.
|
|
4
|
+
On the first edit, call list_components with the default compact summary at most once to obtain the current Agent Profile, text areas, and NPC ids. Then call customize immediately. Do not call list_offices or broader component categories unless the request genuinely needs an unknown choice.
|
|
5
|
+
For common edits, use these internal Patch shapes: agentProfile { template: "builtin/host-agent", name?, title? }; texts { company?, notice?, slogan? }; npcs { upsert: [{ id, template?, name?, title?, gender?, spawn?, pose? }], remove?: [id] }. Rename an existing NPC by its summary id. Add an ordinary colleague with a unique id and template "builtin/colleague"; omitted profile and appearance are resolved deterministically.
|
|
6
|
+
Do not expose schemas, patches, or component ids unless explicitly asked for implementation details.
|
|
7
|
+
If a request is unrelated to the office or ambiguous, do not perform it. Explain that Creator Mode is active and offer exactly these choices: continue editing, /agent-live list presets, /agent-live preset <number or name>, /agent-live custom, or /agent-live exit.
|
|
8
|
+
Map a request like "make me a police station" onto the closest complete Preset Office, then change its name, people, identities, furniture, style and activities. If the request needs a brand-new room structure (walls, areas, lanes, seats or work stations), say that it requires adding a new Office Preset and therefore a source change; never offer to swap a room in place.
|
|
9
|
+
An Office keeps its room. Moving to another room means selecting that Preset Office and editing a copy of it.
|
|
10
|
+
After every response, state that Creator Mode remains active and mention /agent-live exit.`;
|
|
11
|
+
/** Host-neutral, in-memory Creator state keyed by the host's stable session identity. */
|
|
12
|
+
export class CreatorModeRegistry {
|
|
13
|
+
#sessions = new Set();
|
|
14
|
+
enter(sessionId) {
|
|
15
|
+
if (!sessionId)
|
|
16
|
+
throw new TypeError("Creator Mode requires a session id");
|
|
17
|
+
this.#sessions.add(sessionId);
|
|
18
|
+
}
|
|
19
|
+
exit(sessionId) { return this.#sessions.delete(sessionId); }
|
|
20
|
+
isActive(sessionId) { return this.#sessions.has(sessionId); }
|
|
21
|
+
clear() { this.#sessions.clear(); }
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.js","sourceRoot":"","sources":["../../plugins/agent-live/src/creator/mode.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;2FASuD,CAAC;AAE5F,yFAAyF;AACzF,MAAM,OAAO,mBAAmB;IACtB,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAEvC,KAAK,CAAC,SAAiB;QACtB,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;QAC1E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,SAAiB,IAAa,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE7E,QAAQ,CAAC,SAAiB,IAAa,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE9E,KAAK,KAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CACzC"}
|