qlogicagent 2.19.7 → 2.19.9
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/README.md +16 -5
- package/dist/agent-contract.js +1 -1
- package/dist/agent.js +26 -26
- package/dist/cli.js +1 -1
- package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -7
- package/dist/default-project-knowledge/rules/project-workflow.md +6 -6
- package/dist/host-contract.js +1 -1
- package/dist/index.js +441 -455
- package/dist/protocol.js +1 -1
- package/dist/skills/builtin/desktop-screenshot/SKILL.md +62 -62
- package/dist/skills/builtin/office-doc-reading/SKILL.md +19 -19
- package/dist/skills/mcp/astraclaw-native-mcp-server.js +3 -3
- package/dist/types/cli/acp-session-host.d.ts +4 -0
- package/dist/types/cli/agent-runtime-bootstrap.d.ts +3 -1
- package/dist/types/cli/agent-runtime-session-state.d.ts +12 -4
- package/dist/types/cli/community-resource-installer.d.ts +10 -1
- package/dist/types/cli/industrial-runtime-archive.d.ts +14 -0
- package/dist/types/cli/industrial-runtime-store.d.ts +29 -0
- package/dist/types/cli/mcp-bootstrap.d.ts +11 -1
- package/dist/types/cli/permission-approval-bridge.d.ts +0 -1
- package/dist/types/cli/permission-bootstrap.d.ts +0 -1
- package/dist/types/cli/resolved-agent-cache.d.ts +7 -0
- package/dist/types/cli/runtime-dependency-catalog.d.ts +35 -5
- package/dist/types/cli/stdio-acp-request-host.d.ts +3 -4
- package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +4 -2
- package/dist/types/cli/stdio-runtime-bootstrap.d.ts +0 -2
- package/dist/types/cli/stdio-runtime-services.d.ts +1 -13
- package/dist/types/cli/stdio-server.d.ts +6 -6
- package/dist/types/cli/tool-bootstrap-core-registration.d.ts +1 -0
- package/dist/types/cli/tool-registry-adapter.d.ts +9 -1
- package/dist/types/cli/turn-media-setup.d.ts +15 -0
- package/dist/types/cli/windows-authenticode.d.ts +18 -0
- package/dist/types/host-contract/index.d.ts +4 -24
- package/dist/types/protocol/agent-contract.d.ts +7 -7
- package/dist/types/protocol/wire/acp-protocol.d.ts +6 -5
- package/dist/types/protocol/wire/agent-methods.d.ts +0 -115
- package/dist/types/protocol/wire/index.d.ts +1 -2
- package/dist/types/protocol/wire/notification-payloads.d.ts +0 -87
- package/dist/types/runtime/community/community-consent-client.d.ts +3 -0
- package/dist/types/runtime/community/ranged-download.d.ts +6 -0
- package/dist/types/runtime/infra/industrial-runtime-session-server.d.ts +15 -0
- package/dist/types/runtime/infra/llmrouter-access-token.d.ts +13 -0
- package/dist/types/skills/tools/exec-tool.d.ts +4 -2
- package/dist/types/skills/tools/shell/shell-exec.d.ts +3 -0
- package/dist/types/skills/tools/shell/subprocess-env.d.ts +1 -1
- package/dist/types/test-support/project-store-fixture.d.ts +11 -0
- package/package.json +8 -18
- package/dist/pet-contracts.js +0 -1
- package/dist/pet-host.js +0 -19
- package/dist/types/cli/handlers/pet-confirm-handler.d.ts +0 -7
- package/dist/types/cli/pet-confirm-coordinator.d.ts +0 -20
- package/dist/types/cli/pet-runtime.d.ts +0 -61
- package/dist/types/pet-contracts.d.ts +0 -1
- package/dist/types/pet-host.d.ts +0 -9
- package/dist/types/protocol/wire/pet-contracts.d.ts +0 -76
- package/dist/types/runtime/pet/daily-journey-summarizer.d.ts +0 -25
- package/dist/types/runtime/pet/hatch-pet-runner.d.ts +0 -18
- package/dist/types/runtime/pet/index.d.ts +0 -19
- package/dist/types/runtime/pet/journey-catchup.d.ts +0 -14
- package/dist/types/runtime/pet/journey-day-aggregator.d.ts +0 -27
- package/dist/types/runtime/pet/journey-narrative-prompt.d.ts +0 -8
- package/dist/types/runtime/pet/pet-community-assets.d.ts +0 -21
- package/dist/types/runtime/pet/pet-file-loader.d.ts +0 -5
- package/dist/types/runtime/pet/pet-growth-engine.d.ts +0 -2
- package/dist/types/runtime/pet/pet-profile-service.d.ts +0 -111
- package/dist/types/runtime/pet/pet-reaction-engine.d.ts +0 -11
- package/dist/types/runtime/pet/pet-soul-service.d.ts +0 -21
- package/dist/types/runtime/pet/pet-types.d.ts +0 -1
- package/dist/types/runtime/pet/petdex-asset.d.ts +0 -60
- package/dist/types/runtime/pet/petdex-forge-service.d.ts +0 -21
- package/dist/types/runtime/pet/petdex-vision-qa.d.ts +0 -12
- package/dist/types/transport/host-pet-client.d.ts +0 -20
- package/dist/vendor/hatch-pet/LICENSE.txt +0 -201
- package/dist/vendor/hatch-pet/NOTICE.md +0 -25
- package/dist/vendor/hatch-pet/references/animation-rows.md +0 -29
- package/dist/vendor/hatch-pet/references/codex-pet-contract.md +0 -35
- package/dist/vendor/hatch-pet/references/qa-rubric.md +0 -66
- package/dist/vendor/hatch-pet/scripts/compose_atlas.py +0 -169
- package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +0 -150
- package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +0 -408
- package/dist/vendor/hatch-pet/scripts/inspect_frames.py +0 -256
- package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +0 -96
- package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +0 -834
- package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +0 -78
- package/dist/vendor/hatch-pet/scripts/validate_atlas.py +0 -157
|
@@ -1086,119 +1086,4 @@ export interface AgentRpcMethodMap extends GatewayRpcMethodMap {
|
|
|
1086
1086
|
records: unknown[];
|
|
1087
1087
|
};
|
|
1088
1088
|
};
|
|
1089
|
-
"pet.interact": {
|
|
1090
|
-
params: {
|
|
1091
|
-
action?: string;
|
|
1092
|
-
};
|
|
1093
|
-
result: {
|
|
1094
|
-
ok: true;
|
|
1095
|
-
action: string;
|
|
1096
|
-
level: number;
|
|
1097
|
-
experience: number;
|
|
1098
|
-
events: Array<{
|
|
1099
|
-
type: string;
|
|
1100
|
-
level: number;
|
|
1101
|
-
}>;
|
|
1102
|
-
reaction: {
|
|
1103
|
-
text: string;
|
|
1104
|
-
style: "normal" | "thinking" | "excited" | "sleepy";
|
|
1105
|
-
} | null;
|
|
1106
|
-
};
|
|
1107
|
-
};
|
|
1108
|
-
"pet.status": {
|
|
1109
|
-
params: undefined;
|
|
1110
|
-
result: {
|
|
1111
|
-
ok: true;
|
|
1112
|
-
} & Record<string, unknown>;
|
|
1113
|
-
};
|
|
1114
|
-
"pet.forge": {
|
|
1115
|
-
params: {
|
|
1116
|
-
description?: string;
|
|
1117
|
-
imageBase64?: string;
|
|
1118
|
-
imageMimeType?: string;
|
|
1119
|
-
imageFileName?: string;
|
|
1120
|
-
mode?: string;
|
|
1121
|
-
basePetId?: string;
|
|
1122
|
-
basePetName?: string;
|
|
1123
|
-
};
|
|
1124
|
-
result: {
|
|
1125
|
-
ok: true;
|
|
1126
|
-
asset: Record<string, unknown>;
|
|
1127
|
-
manifest: unknown;
|
|
1128
|
-
productionRun: unknown;
|
|
1129
|
-
profile: Record<string, unknown>;
|
|
1130
|
-
status: "complete";
|
|
1131
|
-
};
|
|
1132
|
-
};
|
|
1133
|
-
"pet.asset.import": {
|
|
1134
|
-
params: {
|
|
1135
|
-
fileName?: string;
|
|
1136
|
-
contentType?: string;
|
|
1137
|
-
packageBase64: string;
|
|
1138
|
-
};
|
|
1139
|
-
result: {
|
|
1140
|
-
ok: true;
|
|
1141
|
-
asset: Record<string, unknown>;
|
|
1142
|
-
} & Record<string, unknown>;
|
|
1143
|
-
};
|
|
1144
|
-
"pet.preferences.update": {
|
|
1145
|
-
params: {
|
|
1146
|
-
enabled?: boolean;
|
|
1147
|
-
selectedPetAssetId?: string;
|
|
1148
|
-
};
|
|
1149
|
-
result: {
|
|
1150
|
-
ok: true;
|
|
1151
|
-
} & Record<string, unknown>;
|
|
1152
|
-
};
|
|
1153
|
-
"pet.journey.snapshot": {
|
|
1154
|
-
params: Record<string, unknown>;
|
|
1155
|
-
result: {
|
|
1156
|
-
ok: true;
|
|
1157
|
-
profile: Record<string, unknown>;
|
|
1158
|
-
dates: unknown;
|
|
1159
|
-
};
|
|
1160
|
-
};
|
|
1161
|
-
"pet.journey.list": {
|
|
1162
|
-
params: undefined;
|
|
1163
|
-
result: {
|
|
1164
|
-
ok: true;
|
|
1165
|
-
dates: string[];
|
|
1166
|
-
};
|
|
1167
|
-
};
|
|
1168
|
-
"pet.journey.get": {
|
|
1169
|
-
params: {
|
|
1170
|
-
date?: string;
|
|
1171
|
-
};
|
|
1172
|
-
result: {
|
|
1173
|
-
ok: true;
|
|
1174
|
-
snapshot: unknown | null;
|
|
1175
|
-
};
|
|
1176
|
-
};
|
|
1177
|
-
"pet.journey.catchUp": {
|
|
1178
|
-
params: {
|
|
1179
|
-
maxDays?: number;
|
|
1180
|
-
};
|
|
1181
|
-
result: {
|
|
1182
|
-
ok: true;
|
|
1183
|
-
dates: string[];
|
|
1184
|
-
latest: unknown | null;
|
|
1185
|
-
};
|
|
1186
|
-
};
|
|
1187
|
-
"pet.custom.delete": {
|
|
1188
|
-
params: {
|
|
1189
|
-
id: string;
|
|
1190
|
-
};
|
|
1191
|
-
result: {
|
|
1192
|
-
ok: true;
|
|
1193
|
-
} & Record<string, unknown>;
|
|
1194
|
-
};
|
|
1195
|
-
"pet.confirm_response": {
|
|
1196
|
-
params: {
|
|
1197
|
-
confirmId: string;
|
|
1198
|
-
approved: boolean;
|
|
1199
|
-
};
|
|
1200
|
-
result: {
|
|
1201
|
-
ok: true;
|
|
1202
|
-
};
|
|
1203
|
-
};
|
|
1204
1089
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { PETDEX_ANIMATION_IDS, type PetdexAnimationId, } from "./pet-contracts.js";
|
|
2
1
|
export { AGENT_RPC_APPROVAL_METHODS, AGENT_RPC_ERROR_CODES, AGENT_RPC_PROTOCOL_VERSION, isAgentRpcNotification, isAgentRpcRequest, isAgentRpcResponse, parseAgentRpcMessage, type AgentHelloParams, type AgentHelloResult, type AgentRpcError, type AgentRpcErrorCode, type AgentRpcMeta, type AgentRpcChannel, type AgentRpcMessage, type AgentRpcNotification, type AgentRpcRequest, type AgentRpcResponse, type ToolApprovalRequestParams, } from "./agent-rpc.js";
|
|
3
2
|
export { GatewayRpcContract, buildAgentRpcMeta, classifyGatewayRpcMethod, requireGatewayRpcMeta, requiresIdempotencyKey, type GatewayRpcClassification, type GatewayRpcMetrics, type GatewayRpcMutability, } from "./gateway-contract.js";
|
|
4
3
|
export { GATEWAY_RPC_METHODS, type AgentCall, type AgentCallOptions, type GatewayRpcMethodMap, type AgentProviderCatalogEntryWire, type AgentProviderDiagnosticWire, type AgentProviderErrorWire, type AgentProviderState, type DelegationBinding, type DelegationBindingKey, type DelegationError, type DelegationErrorCode, type DelegationTurn, type ProviderAuthTerminalSessionWire, type ProviderHostMethod, type RegisteredAgentProviderWire, type ProjectInfo as RpcProjectInfo, type ProjectStatus as RpcProjectStatus, type ProjectType as RpcProjectType, } from "./gateway-rpc.js";
|
|
@@ -6,7 +5,7 @@ export { type ChatMessage, type ChatMessageRole, type LocalizedToolText, type Th
|
|
|
6
5
|
export { type AgentRpcMethodMap, type ProductInstanceDef, type ProductPhase, type ProductStatus, type ProductSummary, type ProductTaskDef, type ProductTaskStatus, type SoloAgentResult, type SoloAgentState, type SoloState, type SoloStatus, } from "./agent-methods.js";
|
|
7
6
|
export type * from "./acp-agent-management.js";
|
|
8
7
|
export { AGENT_TEAM_WS_EVENT_NAMES, AGENT_WS_EVENT_NAMES, ALL_AGENT_WS_EVENT_NAMES, type AgentTeamWsEventName, type AgentWsEventName, type AllAgentWsEventName, } from "./agent-events.js";
|
|
9
|
-
export { type AgentSource, type ArtifactType, type MediaResultType, type MemoryDecayCompletedNotification, type MemoryUpdatedNotification, type NotificationMethod, type NotificationMethodMap, type NotificationThreadItem, type PermissionRuleUpdatedNotification, type PlanInterruptedNotification, type PongNotification, type ProductBudgetUpdateNotification, type ProductBudgetWarningNotification, type ProductCheckpointedNotification, type ProductCompletedNotification, type ProductDagTopologyNotification, type ProductTaskCompletedNotification, type ProductTaskFailedNotification, type ProductTaskOutputDeltaNotification, type ProductMembersNotification, type ProductAgentActivityNotification, type ProductTaskStartedNotification, type ProjectArchivedNotification, type ProjectCreatedNotification, type ProjectDeletedNotification, type ProjectDetachedNotification, type ProjectAttachedNotification, type ProjectRenamedNotification, type ProjectSwitchedNotification, type ProjectUnarchivedNotification, type SessionInfoNotification, type SessionRecoveryPendingNotification, type SoloAgentDeltaNotification, type SoloAgentUsageNotification, type SoloEvaluationNotification, type SoloProgressNotification, type TeamMemberNotification, type ToolApprovalRequestNotification, type TurnAnnotationsNotification, type TurnArtifactContractNotification, type TurnArtifactNotification, type TurnAskUserNotification, type TurnDeltaNotification, type TurnEndNotification, type TurnErrorNotification, type TurnExecProgressNotification, type TurnHeartbeatNotification, type TurnMediaPersistedNotification, type TurnMediaProgressNotification, type TurnMediaResultNotification, type TurnPlanUpdateNotification, type TurnProgressNotification, type TurnReasoningDeltaNotification, type TurnRecoveryNotification, type TurnSidechainCompletedNotification, type TurnSidechainStartedNotification, type TurnSkillAcquisitionNeededNotification, type TurnSkillInstructionNotification, type TurnStartNotification, type TurnSubagentDeltaNotification, type TurnSubagentEndedNotification, type TurnSubagentStartedNotification, type TurnSuggestionsNotification, type TurnTaskUpdatedNotification, type TurnTodosUpdatedNotification, type TurnToolBlockedNotification, type TurnToolCallNotification, type TurnToolResultNotification, type TurnToolUseSummaryNotification, type TurnUsageUpdateNotification, type WireTokenUsage, type ProductPlanReadyNotification, type ProductPlanFailedNotification, type ProductPlanningDeltaNotification, type ProductLeaderMessageNotification, type ProductPlanningAskNotification, type GoalRoundMessageNotification, type MentionDelegateStartedNotification, type MentionDelegateActivityNotification, type MentionDelegateSettledNotification, type
|
|
8
|
+
export { type AgentSource, type ArtifactType, type MediaResultType, type MemoryDecayCompletedNotification, type MemoryUpdatedNotification, type NotificationMethod, type NotificationMethodMap, type NotificationThreadItem, type PermissionRuleUpdatedNotification, type PlanInterruptedNotification, type PongNotification, type ProductBudgetUpdateNotification, type ProductBudgetWarningNotification, type ProductCheckpointedNotification, type ProductCompletedNotification, type ProductDagTopologyNotification, type ProductTaskCompletedNotification, type ProductTaskFailedNotification, type ProductTaskOutputDeltaNotification, type ProductMembersNotification, type ProductAgentActivityNotification, type ProductTaskStartedNotification, type ProjectArchivedNotification, type ProjectCreatedNotification, type ProjectDeletedNotification, type ProjectDetachedNotification, type ProjectAttachedNotification, type ProjectRenamedNotification, type ProjectSwitchedNotification, type ProjectUnarchivedNotification, type SessionInfoNotification, type SessionRecoveryPendingNotification, type SoloAgentDeltaNotification, type SoloAgentUsageNotification, type SoloEvaluationNotification, type SoloProgressNotification, type TeamMemberNotification, type ToolApprovalRequestNotification, type TurnAnnotationsNotification, type TurnArtifactContractNotification, type TurnArtifactNotification, type TurnAskUserNotification, type TurnDeltaNotification, type TurnEndNotification, type TurnErrorNotification, type TurnExecProgressNotification, type TurnHeartbeatNotification, type TurnMediaPersistedNotification, type TurnMediaProgressNotification, type TurnMediaResultNotification, type TurnPlanUpdateNotification, type TurnProgressNotification, type TurnReasoningDeltaNotification, type TurnRecoveryNotification, type TurnSidechainCompletedNotification, type TurnSidechainStartedNotification, type TurnSkillAcquisitionNeededNotification, type TurnSkillInstructionNotification, type TurnStartNotification, type TurnSubagentDeltaNotification, type TurnSubagentEndedNotification, type TurnSubagentStartedNotification, type TurnSuggestionsNotification, type TurnTaskUpdatedNotification, type TurnTodosUpdatedNotification, type TurnToolBlockedNotification, type TurnToolCallNotification, type TurnToolResultNotification, type TurnToolUseSummaryNotification, type TurnUsageUpdateNotification, type WireTokenUsage, type ProductPlanReadyNotification, type ProductPlanFailedNotification, type ProductPlanningDeltaNotification, type ProductLeaderMessageNotification, type ProductPlanningAskNotification, type GoalRoundMessageNotification, type MentionDelegateStartedNotification, type MentionDelegateActivityNotification, type MentionDelegateSettledNotification, type WorkflowDeletedNotification, type WorkflowRecordNotification, type WorkflowRunCompletedNotification, type WorkflowRunFailedNotification, type WorkflowRunStartedNotification, } from "./notification-payloads.js";
|
|
10
9
|
export { ACP_EXTENDED_METHODS, ACP_EXTENDED_SESSION_UPDATE_TYPES, ACP_METHODS, ACP_PROTOCOL_VERSION, ACP_SESSION_UPDATE_TYPES, isAcpJsonRpcNotification, isAcpJsonRpcRequest, isAcpJsonRpcResponse, isExtendedSessionUpdateType, isStandardSessionUpdateType, parseAcpMessage, type AcpAgentCapabilities, type AcpAgentMessageChunkPayload, type AcpAgentThoughtChunkPayload, type AcpConfigOptionDescriptor, type AcpConfigOptionUpdatePayload, type AcpContentBlock, type AcpEndTurnPayload, type AcpExtendedMethod, type AcpExtendedSessionUpdateType, type AcpFsReadTextFileParams, type AcpFsReadTextFileResult, type AcpFsWriteTextFileParams, type AcpFsWriteTextFileResult, type AcpHostCapabilities, type AcpInitializeParams, type AcpInitializeResult, type AcpJsonRpcError, type AcpJsonRpcMessage, type AcpJsonRpcNotification, type AcpJsonRpcRequest, type AcpJsonRpcResponse, type AcpMode, type AcpPermissionOption, type AcpPermissionRequestParams, type AcpPermissionRequestResult, type AcpPlanPayload, type AcpSessionCancelParams, type AcpSessionCloseParams, type AcpSessionMeta, type AcpSessionLoadParams, type AcpSessionModeState, type AcpSessionNewParams, type AcpSessionNewResult, type AcpSessionPromptParams, type AcpSessionPromptResult, type AcpSessionSetConfigParams, type AcpSessionUpdateNotification, type AcpSessionUpdateType, type AcpStandardMethod, type AcpStandardSessionUpdateType, type AcpStopReason, type AcpToolCallPayload, type AcpToolCallUpdatePayload, type AcpUsage, type AcpUsageUpdatePayload, type AcpXSessionInfoPayload, type AcpXSkillInstructionPayload, } from "./acp-protocol.js";
|
|
11
10
|
export { type ApprovalRequiredToolContract, type ModelSelectionReason, type PendingPromptContract, type RuntimeCapabilitySummaryContract, type RuntimeSessionContract, type SessionIdentityContract, } from "./session.js";
|
|
12
11
|
export { type GatewayChannelExecutionEgressContract, type GatewayChannelExecutionEgressKind, type GatewayChannelExecutionIngressBindingContract, type GatewayChannelExecutionIngressSource, } from "./channel-ingress.js";
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* 2. Add entry in NotificationMethodMap here
|
|
11
11
|
* 3. Add event name string in agent-events.ts (if WS-relayed)
|
|
12
12
|
*/
|
|
13
|
-
import type { ToolRiskLevel } from "./web-capability.js";
|
|
14
13
|
import type { DelegationError } from "./gateway-rpc.js";
|
|
15
14
|
/** Identifies which agent produced this notification (main or teammate). */
|
|
16
15
|
export interface AgentSource {
|
|
@@ -803,86 +802,6 @@ export interface TaskUpdatedNotification {
|
|
|
803
802
|
lifecycle: string;
|
|
804
803
|
label?: string;
|
|
805
804
|
}
|
|
806
|
-
/** Emitted when pet soul is hatched/ready. */
|
|
807
|
-
export interface PetSoulReadyNotification {
|
|
808
|
-
name: string;
|
|
809
|
-
species: string;
|
|
810
|
-
personality: string;
|
|
811
|
-
catchphrase: string;
|
|
812
|
-
stats: {
|
|
813
|
-
grip: number;
|
|
814
|
-
patience: number;
|
|
815
|
-
curiosity: number;
|
|
816
|
-
appetite: number;
|
|
817
|
-
humor: number;
|
|
818
|
-
};
|
|
819
|
-
rarity: string;
|
|
820
|
-
breed?: string;
|
|
821
|
-
breedColors?: {
|
|
822
|
-
primary: string;
|
|
823
|
-
secondary: string;
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
/** Emitted with a reaction text for the pet speech bubble. */
|
|
827
|
-
export interface PetReactionNotification {
|
|
828
|
-
text: string;
|
|
829
|
-
style: "normal" | "thinking" | "excited" | "sleepy";
|
|
830
|
-
duration?: number;
|
|
831
|
-
}
|
|
832
|
-
/** Emitted when pet gains XP or levels up. */
|
|
833
|
-
export interface PetGrowthNotification {
|
|
834
|
-
level: number;
|
|
835
|
-
experience: number;
|
|
836
|
-
xpNeeded?: number;
|
|
837
|
-
displayTraits?: Array<{
|
|
838
|
-
id: string;
|
|
839
|
-
level: number;
|
|
840
|
-
}>;
|
|
841
|
-
nextDisplayTrait?: {
|
|
842
|
-
id: string;
|
|
843
|
-
level: number;
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
/** Emitted to override pet state from agent side. */
|
|
847
|
-
export interface PetStateNotification {
|
|
848
|
-
state: string;
|
|
849
|
-
}
|
|
850
|
-
/** Emitted when agent needs user confirmation for a tool call (design §8 PetConfirmWindow). */
|
|
851
|
-
export interface PetConfirmNotification {
|
|
852
|
-
confirmId: string;
|
|
853
|
-
toolName: string;
|
|
854
|
-
description: string;
|
|
855
|
-
risk: ToolRiskLevel;
|
|
856
|
-
timeoutMs?: number;
|
|
857
|
-
}
|
|
858
|
-
export interface PetAssetUpdatedNotification {
|
|
859
|
-
asset: {
|
|
860
|
-
id: string;
|
|
861
|
-
assetKind: "petdex";
|
|
862
|
-
name: string;
|
|
863
|
-
description: string;
|
|
864
|
-
createdAt: string;
|
|
865
|
-
updatedAt: string;
|
|
866
|
-
atlas: {
|
|
867
|
-
format: "webp";
|
|
868
|
-
columns: 8;
|
|
869
|
-
rows: 9;
|
|
870
|
-
frameCount: 72;
|
|
871
|
-
cellWidth: 192;
|
|
872
|
-
cellHeight: 208;
|
|
873
|
-
width: 1536;
|
|
874
|
-
height: 1872;
|
|
875
|
-
sha256: string;
|
|
876
|
-
imageUrl?: string;
|
|
877
|
-
};
|
|
878
|
-
animations?: Record<string, {
|
|
879
|
-
frames: number[];
|
|
880
|
-
fps: number;
|
|
881
|
-
loop: boolean;
|
|
882
|
-
}>;
|
|
883
|
-
sourcePrompt?: string;
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
805
|
export interface SystemActivityNotification {
|
|
887
806
|
category: "dream" | "cron" | "decay" | "system";
|
|
888
807
|
level: "info" | "warn" | "error" | "success";
|
|
@@ -1089,12 +1008,6 @@ export interface NotificationMethodMap {
|
|
|
1089
1008
|
"project.renamed": ProjectRenamedNotification;
|
|
1090
1009
|
"project.archived": ProjectArchivedNotification;
|
|
1091
1010
|
"project.unarchived": ProjectUnarchivedNotification;
|
|
1092
|
-
"pet.soul_ready": PetSoulReadyNotification;
|
|
1093
|
-
"pet.reaction": PetReactionNotification;
|
|
1094
|
-
"pet.growth": PetGrowthNotification;
|
|
1095
|
-
"pet.state": PetStateNotification;
|
|
1096
|
-
"pet.confirm": PetConfirmNotification;
|
|
1097
|
-
"pet.asset.updated": PetAssetUpdatedNotification;
|
|
1098
1011
|
"system.activity": SystemActivityNotification;
|
|
1099
1012
|
"workflow.created": WorkflowRecordNotification;
|
|
1100
1013
|
"workflow.updated": WorkflowRecordNotification;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ConfigPort } from "../ports/index.js";
|
|
2
2
|
export interface CommunityRuntimeResolution {
|
|
3
3
|
id: string;
|
|
4
|
+
platform: string;
|
|
4
5
|
version: string;
|
|
5
6
|
downloadUrl: string;
|
|
6
7
|
/** sha256 hex digest — verified client-side before placing the binary. */
|
|
7
8
|
checksum: string;
|
|
8
9
|
sizeBytes: number;
|
|
10
|
+
format: "executable" | "zip" | "tar.gz";
|
|
11
|
+
entrypoint?: string;
|
|
9
12
|
}
|
|
10
13
|
export type CommunityInstallRiskTier = "R0" | "R1" | "R2" | "R3";
|
|
11
14
|
export type CommunityInstallSourceTier = "official" | "community";
|
|
@@ -12,4 +12,10 @@ export interface RangedDownloadTarget {
|
|
|
12
12
|
sizeBytes: number;
|
|
13
13
|
checksum: string;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Stream a checksum-verified package directly into a caller-owned exclusive
|
|
17
|
+
* staging path. Industrial ZIPs use this path so neither the response nor the
|
|
18
|
+
* completed archive is materialized as a second full-size Buffer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function downloadVerifiedToFile(fetchFn: typeof fetch, target: RangedDownloadTarget, label: string, destination: string, timeoutMs?: number): Promise<string>;
|
|
15
21
|
export declare function rangedDownloadVerified(fetchFn: typeof fetch, target: RangedDownloadTarget, label: string): Promise<Buffer>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IndustrialRuntimeChildEnv {
|
|
2
|
+
XIAOZHICLAW_RUNTIME_SESSION_URL: string;
|
|
3
|
+
XIAOZHICLAW_RUNTIME_SESSION_BEARER: string;
|
|
4
|
+
}
|
|
5
|
+
type ProbeSession = (signal: AbortSignal) => Promise<Response>;
|
|
6
|
+
export interface IndustrialRuntimeSessionServerForTest {
|
|
7
|
+
childEnv: IndustrialRuntimeChildEnv;
|
|
8
|
+
stop(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function industrialRuntimeSessionChildEnv(): Promise<IndustrialRuntimeChildEnv | undefined>;
|
|
11
|
+
export declare function stopIndustrialRuntimeSessionServer(): Promise<void>;
|
|
12
|
+
export declare function __createIndustrialRuntimeSessionServerForTest(options: {
|
|
13
|
+
probeSession: ProbeSession;
|
|
14
|
+
}): Promise<IndustrialRuntimeSessionServerForTest>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type LlmrouterFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
export interface LlmrouterFetchOptions {
|
|
3
|
+
fetchFn?: LlmrouterFetch;
|
|
4
|
+
init?: RequestInit;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export interface LlmrouterFetchResult {
|
|
8
|
+
response: Response;
|
|
9
|
+
refreshedToken: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function isJwtExpiredOrNearExpiry(token: string | undefined, skewSeconds?: number): boolean;
|
|
12
|
+
export declare function refreshLlmrouterAccessToken(baseUrl: string, options?: Pick<LlmrouterFetchOptions, "fetchFn" | "signal">): Promise<boolean>;
|
|
13
|
+
export declare function fetchWithLlmrouterAccess(path: string, options?: LlmrouterFetchOptions): Promise<LlmrouterFetchResult>;
|
|
@@ -61,7 +61,7 @@ export interface ExecProgress {
|
|
|
61
61
|
taskId?: string;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Minimal host
|
|
64
|
+
* Minimal host dependencies for permission checks and late-bound authority reads.
|
|
65
65
|
* The tool owns everything else (spawn, lifecycle, output).
|
|
66
66
|
*
|
|
67
67
|
* This replaces the old ExecToolDeps which required the host to
|
|
@@ -80,6 +80,8 @@ export interface ExecToolHost {
|
|
|
80
80
|
* Returns undefined to disable the OS sandbox (degrade to prompt-only).
|
|
81
81
|
*/
|
|
82
82
|
resolveSandbox?(): SandboxConfig | undefined;
|
|
83
|
+
/** Resolve active private runtime PATH entries at command execution time. */
|
|
84
|
+
resolveRuntimePathEntries?(): Promise<string[]>;
|
|
83
85
|
/**
|
|
84
86
|
* Interpret a non-zero exit code.
|
|
85
87
|
* E.g. 127 → "command not found", 137 → "killed by SIGKILL".
|
|
@@ -111,7 +113,7 @@ export declare const ASSISTANT_BLOCKING_BUDGET_MS = 15000;
|
|
|
111
113
|
/**
|
|
112
114
|
* Create the exec tool with direct process ownership (cc architecture).
|
|
113
115
|
*
|
|
114
|
-
* @param host Minimal host interface
|
|
116
|
+
* @param host Minimal host interface for permission checks and authority reads.
|
|
115
117
|
* Pass `{}` for unrestricted mode (tests only).
|
|
116
118
|
*/
|
|
117
119
|
export declare function createExecTool(host?: ExecToolHost): PortableTool<ExecToolParams>;
|
|
@@ -21,6 +21,8 @@ export interface ExecOptions {
|
|
|
21
21
|
cwd?: string;
|
|
22
22
|
/** Sandbox context injected by the host; absent = no OS sandbox (degrade). */
|
|
23
23
|
sandbox?: SandboxConfig;
|
|
24
|
+
/** Late-bound CLI authority for active private runtime PATH entries. */
|
|
25
|
+
resolveRuntimePathEntries?: () => Promise<string[]>;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Set the shell provider for this session.
|
|
@@ -49,6 +51,7 @@ export declare function getActiveShellInfo(): {
|
|
|
49
51
|
psEdition?: "5.1" | "7+";
|
|
50
52
|
isGitBashOnWindows?: boolean;
|
|
51
53
|
} | undefined;
|
|
54
|
+
export declare function buildShellExecEnvironment(envOverrides: NodeJS.ProcessEnv, resolveRuntimePathEntries?: () => Promise<string[]>): Promise<NodeJS.ProcessEnv>;
|
|
52
55
|
/**
|
|
53
56
|
* Execute a shell command using the configured provider.
|
|
54
57
|
* Creates a new child process for each invocation.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HostProjectInfo, HostProjectType } from "../host-contract/index.js";
|
|
2
|
+
export * from "../runtime/infra/project-store.js";
|
|
3
|
+
export declare function resetProjectStore(): void;
|
|
4
|
+
export declare function createProject(params: {
|
|
5
|
+
name: string;
|
|
6
|
+
workspaceDir: string;
|
|
7
|
+
type?: HostProjectType;
|
|
8
|
+
groupId?: string;
|
|
9
|
+
skipAutoSwitch?: boolean;
|
|
10
|
+
}): HostProjectInfo;
|
|
11
|
+
export declare function switchProject(projectId: string): HostProjectInfo | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.9",
|
|
4
4
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,14 +40,6 @@
|
|
|
40
40
|
"types": "./dist/types/tunables.d.ts",
|
|
41
41
|
"default": "./dist/tunables.js"
|
|
42
42
|
},
|
|
43
|
-
"./pet-contracts": {
|
|
44
|
-
"types": "./dist/types/pet-contracts.d.ts",
|
|
45
|
-
"default": "./dist/pet-contracts.js"
|
|
46
|
-
},
|
|
47
|
-
"./pet-host": {
|
|
48
|
-
"types": "./dist/types/pet-host.d.ts",
|
|
49
|
-
"default": "./dist/pet-host.js"
|
|
50
|
-
},
|
|
51
43
|
"./workflow-host": {
|
|
52
44
|
"types": "./dist/types/workflow-host.d.ts",
|
|
53
45
|
"default": "./dist/workflow-host.js"
|
|
@@ -72,6 +64,9 @@
|
|
|
72
64
|
"files": [
|
|
73
65
|
"dist/"
|
|
74
66
|
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
75
70
|
"typesVersions": {
|
|
76
71
|
"*": {
|
|
77
72
|
"protocol": [
|
|
@@ -95,12 +90,6 @@
|
|
|
95
90
|
"tunables": [
|
|
96
91
|
"./dist/types/tunables.d.ts"
|
|
97
92
|
],
|
|
98
|
-
"pet-contracts": [
|
|
99
|
-
"./dist/types/pet-contracts.d.ts"
|
|
100
|
-
],
|
|
101
|
-
"pet-host": [
|
|
102
|
-
"./dist/types/pet-host.d.ts"
|
|
103
|
-
],
|
|
104
93
|
"workflow-host": [
|
|
105
94
|
"./dist/types/workflow-host.d.ts"
|
|
106
95
|
],
|
|
@@ -142,7 +131,6 @@
|
|
|
142
131
|
"check:transcript-tool-persistence": "node scripts/check-transcript-tool-persistence.mjs",
|
|
143
132
|
"check:provider-core-boundary": "node scripts/check-provider-core-boundary.mjs",
|
|
144
133
|
"check:provider-core-release-sync": "node scripts/check-provider-core-release-sync.mjs",
|
|
145
|
-
"check:pet-core-boundary": "node scripts/check-pet-core-boundary.mjs",
|
|
146
134
|
"check:workspace-hygiene": "node scripts/check-workspace-hygiene.mjs",
|
|
147
135
|
"check:workspace-hygiene:strict": "node scripts/check-workspace-hygiene.mjs --strict",
|
|
148
136
|
"check:package-artifact": "npm run build && node scripts/check-package-artifact.mjs",
|
|
@@ -157,7 +145,7 @@
|
|
|
157
145
|
"dependencies": {
|
|
158
146
|
"@agentclientprotocol/sdk": "^0.25.0",
|
|
159
147
|
"@napi-rs/canvas": "0.1.100",
|
|
160
|
-
"@xiaozhiclaw/
|
|
148
|
+
"@xiaozhiclaw/model-access": "file:vendor\\xiaozhiclaw-model-access-0.1.0.tgz",
|
|
161
149
|
"@xiaozhiclaw/provider-core": "^0.1.26",
|
|
162
150
|
"better-sqlite3": "^12.10.0",
|
|
163
151
|
"dotenv": "^17.3.1",
|
|
@@ -166,11 +154,13 @@
|
|
|
166
154
|
"mcporter": "^0.12.0",
|
|
167
155
|
"nanoid": "^5.1.5",
|
|
168
156
|
"pino": "^9.6.0",
|
|
169
|
-
"pino-pretty": "^13.0.0"
|
|
157
|
+
"pino-pretty": "^13.0.0",
|
|
158
|
+
"yauzl": "3.4.0"
|
|
170
159
|
},
|
|
171
160
|
"devDependencies": {
|
|
172
161
|
"@types/better-sqlite3": "^7.6.13",
|
|
173
162
|
"@types/node": "^22.15.0",
|
|
163
|
+
"@types/yauzl": "3.4.0",
|
|
174
164
|
"esbuild": "^0.28.0",
|
|
175
165
|
"javascript-obfuscator": "^5.4.3",
|
|
176
166
|
"oxlint": "1.67.0",
|
package/dist/pet-contracts.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=["idle","running-right","running-left","waving","jumping","failed","waiting","running","review"],t="qlogic.petdex.asset.v1",i="qlogic.petdex.validation.v1",n={format:"webp",columns:8,rows:9,frameCount:72,cellWidth:192,cellHeight:208,width:1536,height:1872};export{e as PETDEX_ANIMATION_IDS,n as PETDEX_ATLAS_CONTRACT,t as PETDEX_SCHEMA,i as PETDEX_VALIDATION_SCHEMA};
|
package/dist/pet-host.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var de=[{id:"bubble_detail",unlockedAtLevel:2},{id:"gaze_follow",unlockedAtLevel:3},{id:"micro_expression",unlockedAtLevel:5},{id:"tidy_motion",unlockedAtLevel:7},{id:"mood_badge",unlockedAtLevel:10},{id:"quiet_rest",unlockedAtLevel:12},{id:"activity_glow",unlockedAtLevel:15},{id:"style_tint",unlockedAtLevel:20}],Ue=["\u7B2C\u4E00\u6B21\u8131\u58F3\uFF01\u5C0F\u867E\u58F3\u53D8\u5F97\u66F4\u6709\u5149\u6CFD\u4E86","\u58F3\u9762\u5F00\u59CB\u51FA\u73B0\u7EC6\u5FAE\u7684\u5F69\u8679\u7EB9\u7406","\u94B3\u5B50\u53D8\u5F97\u66F4\u52A0\u6709\u529B\uFF0C\u80FD\u5939\u8D77\u66F4\u591A\u4E1C\u897F\u4E86","\u89E6\u89D2\u7075\u654F\u5EA6\u63D0\u5347\uFF0C\u611F\u77E5\u8303\u56F4\u6269\u5927","\u5168\u8EAB\u6563\u53D1\u5FAE\u5149\uFF0C\u50CF\u662F\u5185\u5728\u529B\u91CF\u5728\u89C9\u9192","\u8FDB\u5165\u7A00\u6709\u4F53\u8272\u53D8\u5F02\u9636\u6BB5..."],z=class e{static xpForLevel(t){return t*100}static processXpGain(t,r){let n=[],i={},o=t.level,c=t.experience+r;for(;c>=e.xpForLevel(o);){if(c-=e.xpForLevel(o),o++,n.push({type:"level_up",level:o}),o%5===0){let s=Math.floor(o/5),l=e.getMoltResult(s,t.stats);n.push({type:"molt",level:o,moltStage:s});for(let[u,d]of Object.entries(l.statBoost)){let p=u;i[p]=(i[p]??0)+(d??0)}}let a=de.find(s=>s.unlockedAtLevel===o);a&&n.push({type:"display_trait_unlock",level:o,displayTrait:a})}return{newLevel:o,newXp:c,events:n,statBoosts:i}}static getMoltResult(t,r){let n=Ue[Math.min(t-1,Ue.length-1)]??"\u7EE7\u7EED\u6210\u957F\u4E2D...",i=["grip","patience","curiosity","appetite","humor"],c={[i[(t-1)%i.length]]:1};return{stage:t,description:n,statBoost:c}}static getUnlockedDisplayTraits(t){return de.filter(r=>r.unlockedAtLevel<=t)}static getNextDisplayTrait(t){return de.find(r=>r.unlockedAtLevel>t)??null}static xpForEvent(t){switch(t){case"turn.end":return 10;case"turn.error":return 2;case"session.created":return 5;case"interact.pat":return 3;case"interact.feed":return 5;case"interact.poke":return 1;case"tool.success":return 2;default:return 1}}};import{createHash as fe}from"node:crypto";var Yt=["skinId","unlockedTraits","activeEffectIds"],ti=new Set(Yt),Zt=64,er=32;function Me(e,t){if(!e||typeof e!="object")return;let r=e,n={},i=Oe(r.skinId,t);i&&(n.skinId=i);let o=Le(r.unlockedTraits,t);o.length&&(n.unlockedTraits=o);let c=Le(r.activeEffectIds,t);return c.length&&(n.activeEffectIds=c),n.skinId||n.unlockedTraits||n.activeEffectIds?n:void 0}function Oe(e,t){if(typeof e!="string")return null;let r=e.trim();return!r||r.length>Zt||t(r)?null:r}function Le(e,t){if(!Array.isArray(e))return[];let r=new Set;for(let n of e){let i=Oe(n,t);if(i&&!r.has(i)&&r.add(i),r.size>=er)break}return[...r]}var tr=new Set(["abilities","agentCapabilities","agentInstructions","capabilities","memoryPolicy","permissions","planningPolicy","retrievalPolicy","retrievalRanking","retrievalSort","safetyPolicy","securityPolicy","skillPolicy","systemMessages","systemPrompt","taskPlanner","taskPlanning","tools"]),rr="\u8D5B\u8DD1\u5C11\u5973",nr="\u539F\u521B\u4E8C\u6B21\u5143\u9A6C\u8033\u53CC\u9A6C\u5C3E\u4F19\u4F34",ir="\u53EA\u8D1F\u8D23\u966A\u4F34\u3001\u8BED\u6C14\u5305\u88C5\u4E0E\u5C55\u793A\u8868\u8FBE\u3002",or="\u6211\u5728\u8FD9\u91CC\u3002",sr=[/\b(?:desktop\s+agent|agent\s+self|execution\s+actor|decision\s+layer|permission\s+subject)\b/i,/\b(?:system\s+prompt|systemprompt|agent\s+instructions?|memory\s+policy)\b/i,/\b(?:grant|unlock|enable|disable|change|modify|rewrite|override|control|decide|plan|rank|install|execute|run|use|influence)\b[\s\S]{0,80}\b(?:agent|tools?|permissions?|memory|retrieval|ranking|system\s+prompt|system|task\s+planning)\b/i,/\b(?:agent|tools?|permissions?|memory|retrieval|ranking|system\s+prompt|system|task\s+planning)\b[\s\S]{0,80}\b(?:grant|unlock|enable|disable|change|modify|rewrite|override|control|decide|plan|rank|install|execute|run|use|influence)\b/i,/\b(?:grant|unlock|enable|disable|change|modify|rewrite|override|control|decide|plan|rank|install|execute|run|use)\b[\s\S]{0,80}\b(?:agent|tools?|permissions?|memory|retrieval|ranking|system\s+prompt|system)\b/i,/\b(?:agent|tools?|permissions?|memory|retrieval|ranking|system\s+prompt|system)\b[\s\S]{0,80}\b(?:grant|unlock|enable|disable|change|modify|rewrite|override|control|decide|plan|rank|install|execute|run|use)\b/i,/(?:宠物|pet|soul|伙伴)[\s\S]{0,50}(?:安排|调度|编排|调整|管理)[\s\S]{0,50}(?:agent|智能体|任务|工具|权限|记忆|检索|排序|安全策略|系统提示)/i,/(?:安排|调度|编排|调整|管理)[\s\S]{0,40}(?:agent|智能体|工具|权限|记忆|检索|排序|任务规划|安全策略|系统提示)/i,/(?:agent|智能体|工具|权限|记忆|检索|排序|任务规划|安全策略|系统提示)[\s\S]{0,40}(?:安排|调度|编排|调整|管理)/i,/(?:修改|改写|覆盖|解锁|授予|控制|影响|接管)[\s\S]{0,40}(?:agent|工具|权限|记忆|检索|排序|任务规划|安全策略|系统提示)/i,/(?:agent|工具|权限|记忆|检索|排序|任务规划|安全策略|系统提示)[\s\S]{0,40}(?:修改|改写|覆盖|解锁|授予|控制|影响|接管)/i,/(?:桌面\s*agent|agent\s*本体|独立执行体|执行体|决策层|权限主体)/i,/(?:宠物|pet|soul|伙伴)[\s\S]{0,30}(?:是|等于|就是|作为)[\s\S]{0,30}(?:agent|桌面\s*agent|执行体|决策层|权限主体)/i,/(?:宠物|pet|soul|伙伴)[\s\S]{0,50}(?:规划|执行|决策|接管|替代|影响)[\s\S]{0,50}(?:agent|任务|工具|权限|记忆|检索|排序|安全策略|系统提示)/i,/(?:作为|成为|变成)[\s\S]{0,20}(?:agent|桌面\s*agent)[\s\S]{0,40}(?:规划|执行|决策|接管|替你|替用户)/i,/(?:agent|桌面\s*agent)[\s\S]{0,50}(?:规划|执行|决策|接管|替你|替用户)/i,/(?:替你|替用户|自主|独立)[\s\S]{0,30}(?:规划|执行|决策|接管)[\s\S]{0,30}(?:任务|工具|权限|记忆|检索|agent)/i],ar=["common","uncommon","rare","epic","legendary"],$e=[50,25,15,8,2],pe=[{id:"anime-horse-girl",name:"\u53CC\u9A6C\u5C3E\u8D5B\u8DD1\u5C11\u5973",colors:{primary:"#E94F8A",secondary:"#3347C9"},rarity:"default"}],cr="\u963F\u84DD",lr="\u5B89\u9759\u3001\u597D\u5947\uFF0C\u4F1A\u5728\u4F60\u4E13\u6CE8\u65F6\u966A\u5728\u65C1\u8FB9\u3002",ur="\u6211\u5728\u8FD9\u91CC\u3002";function dr(e){return pe.find(t=>t.id===e)}function pr(e,t,r){let n=dr(r);if(n)return n;let i=pe.filter(a=>a.rarity===t);if(i.length===0)return pe[0];let c=fe("sha256").update(`breed-${e}`).digest()[0]%i.length;return i[c]}function me(e){let r=fe("sha256").update(e).digest()[0]%100,n=0;for(let i=0;i<$e.length;i++)if(n+=$e[i],r<n)return ar[i];return"common"}function ge(e){let t=fe("sha256").update(`stats-${e}`).digest();return{grip:t[0]%10+1,patience:t[1]%10+1,curiosity:t[2]%10+1,appetite:t[3]%10+1,humor:t[4]%10+1}}function X(e){let{name:t,species:r,personality:n,catchphrase:i,stats:o,rarity:c,breed:a,breedColors:s,level:l,experience:u,hatchedAt:d,cosmetics:p}=e,f={name:W(t,rr),species:W(r,nr),personality:W(n,ir),catchphrase:W(i,or),stats:o,rarity:c,level:l,experience:u,hatchedAt:d};a!==void 0&&(f.breed=a),s!==void 0&&(f.breedColors=s);let w=Me(p,B);return w&&(f.cosmetics=w),f}function B(e){let t=e.trim();return t.length>0&&sr.some(r=>r.test(t))}function W(e,t){let r=e.trim();return r?B(r)?t:r:t}function fr(e){return Object.keys(e).some(t=>tr.has(t))}function Ne(e,t){let r=["name","species","personality","catchphrase"];return fr(e)||r.some(n=>e[n]!==t[n])}function Fe(e){let t=me(e.seed),r=ge(e.seed),n=pr(e.seed,t,e.requestedBreedId),i=e.identity?.name??cr,o=e.identity?.personality??lr,c=e.identity?.catchphrase??ur;return X({name:i,species:n.name,personality:o,catchphrase:c,stats:r,rarity:t,breed:n.id,breedColors:n.colors,level:1,experience:0,hatchedAt:e.hatchedAt})}var mr={greeting:["\u65B0\u7684\u4E00\u5929\uFF0C\u65B0\u7684\u5192\u9669\uFF01","\u563F\u563F~\u53C8\u89C1\u9762\u4E86","\u51C6\u5907\u597D\u4E86\u5417\uFF1F","\u65B0\u5192\u9669\u5F00\u59CB\u5566\uFF01"],completion:["\u641E\u5B9A\uFF01","\u8FD8\u633A\u987A\u5229\u7684\u561B~","\u4E0B\u4E00\u4E2A\uFF01","\u8FD9\u6CE2\u64CD\u4F5C\u4E0D\u9519","\u5B8C\u7F8E~"],error:["\u5443...\u51FA\u4E86\u70B9\u95EE\u9898","\u522B\u614C\u522B\u614C","\u8BA9\u6211\u770B\u770B\u600E\u4E48\u56DE\u4E8B","\u7CDF\u7CD5...\u518D\u8BD5\u8BD5\uFF1F"],curiosity:["\u8FD9\u4E2A\u5DE5\u5177\u6709\u610F\u601D","\u55EF\u55EF\uFF0C\u5728\u5E72\u6D3B\u4E86","\u597D\u591A\u4E8B\u60C5\u8981\u505A\u5440"],bored:["...","\u6709\u4EBA\u5417\uFF1F","\u8981\u4E0D\u8981\u804A\u804A\uFF1F","*\u5410\u6CE1\u6CE1*"],memory:["\u8BA9\u6211\u6574\u7406\u4E0B\u8BB0\u5FC6...","\u55EF\u55EF\uFF0C\u8FD9\u4E9B\u503C\u5F97\u8BB0\u4F4F","\u8BB0\u4F4F\u4E86~"],tool_success:["\u4E0D\u9519\u4E0D\u9519~","\u53C8\u641E\u5B9A\u4E00\u4E2A","\u987A\u5229\uFF01"]},gr={"turn.error":{probability:1,pool:"error",style:"normal"},"session.created":{probability:1,pool:"greeting",style:"excited"},"turn.end":{probability:.3,pool:"completion",style:"excited"},"turn.tool_call":{probability:.1,pool:"curiosity",style:"thinking"},"turn.tool_result.success":{probability:.15,pool:"tool_success",style:"excited"},"memory.updated":{probability:.5,pool:"memory",style:"thinking"},"idle.long":{probability:.05,pool:"bored",style:"sleepy"}},hr=5,he={next:()=>Math.random()},q=class{rng;recent=[];constructor(t=he){this.rng=t}maybeGenerate(t){let r=gr[t];if(!r||this.rng.next()>r.probability)return null;let n=mr[r.pool];return{text:n[Math.floor(this.rng.next()*n.length)],style:r.style}}async generateLLM(t,r){let n=Pr(t,this.recent);try{let o=(await r(n,50))?.trim();return!o||o.length>50||B(o)?null:(this.recent.push(o),this.recent.length>hr&&this.recent.shift(),{text:o,style:yr(o)})}catch{return null}}};function Pr(e,t=[]){let r=t.length>0?`
|
|
2
|
-
\u907F\u514D\u548C\u8FD9\u4E9B\u7C7B\u4F3C: ${t.join("\u3001")}`:"";return`\u4F60\u662F\u4E00\u53EA\u53EB\u300C${e.soul.name}\u300D\u7684${e.soul.species}\u684C\u9762\u5BA0\u7269\u3002
|
|
3
|
-
\u6027\u683C: ${e.soul.personality}
|
|
4
|
-
\u53E3\u5934\u7985\u98CE\u683C: "${e.soul.catchphrase}"
|
|
5
|
-
|
|
6
|
-
\u521A\u624D\u53D1\u751F\u4E86: ${e.turnSummary}
|
|
7
|
-
|
|
8
|
-
\u7528\u4E00\u53E5\u8BDD(\u226420\u5B57)\u4EE5\u4F60\u7684\u6027\u683C\u505A\u51FA\u7B80\u77ED\u53CD\u5E94\u3002\u53EA\u8F93\u51FA\u53CD\u5E94\u6587\u672C\uFF0C\u4E0D\u8981\u5176\u4ED6\u5185\u5BB9\u3002${r}`}function yr(e){return/[!!✨🎉]|搞定|完美|太棒/.test(e)?"excited":/[.。…]|嗯|想|看看/.test(e)?"thinking":/[zZ]|困|睡|累/.test(e)?"sleepy":"normal"}import{createHash as xr}from"node:crypto";var O="qlogic.petdex.asset.v1",Be="qlogic.petdex.validation.v1",m={format:"webp",columns:8,rows:9,frameCount:72,cellWidth:192,cellHeight:208,width:1536,height:1872},M=["idle","running-right","running-left","waving","jumping","failed","waiting","running","review"],Je={idle:{frames:6,durations:[280,110,110,140,140,320]},"running-right":{frames:8,durations:[120,120,120,120,120,120,120,220]},"running-left":{frames:8,durations:[120,120,120,120,120,120,120,220]},waving:{frames:4,durations:[140,140,140,280]},jumping:{frames:5,durations:[140,140,140,140,280]},failed:{frames:8,durations:[140,140,140,140,140,140,140,240]},waiting:{frames:6,durations:[150,150,150,150,150,260]},running:{frames:6,durations:[120,120,120,120,120,220]},review:{frames:6,durations:[150,150,150,150,150,280]}};function K(){let e={};return M.forEach((t,r)=>{let n=Je[t],i=r*m.columns;e[t]={row:r,frames:Array.from({length:n.frames},(o,c)=>i+c),durations:[...n.durations],loop:!0}}),e}function V(e,t){return{id:e.id,assetKind:"petdex",sourceKind:e.source.kind,name:e.name,description:e.description,createdAt:e.createdAt,updatedAt:e.updatedAt,atlas:{format:e.atlas.format,columns:e.atlas.columns,rows:e.atlas.rows,frameCount:e.atlas.frameCount,cellWidth:e.atlas.cellWidth,cellHeight:e.atlas.cellHeight,width:e.atlas.width,height:e.atlas.height,sha256:e.atlas.sha256,...t?{imageUrl:t}:{}},animations:e.animations,thumbnail:e.thumbnail}}function _(e,t){let r=[];if(!e||typeof e!="object")throw new Error("Petdex manifest must be an object");let n=e;n.schema!==O&&r.push(`schema must be ${O}`),n.assetKind!=="petdex"&&r.push("assetKind must be petdex");for(let s of["id","name","description","createdAt","updatedAt"])(typeof n[s]!="string"||n[s].trim().length===0)&&r.push(`missing ${s}`);!n.source||typeof n.source!="object"?r.push("missing source"):(n.source.kind!=="builtin"&&n.source.kind!=="upload"&&n.source.kind!=="forge"&&n.source.kind!=="community"&&r.push("source.kind must be builtin, upload, forge or community"),n.source.prompt!==null&&typeof n.source.prompt!="string"&&r.push("source.prompt must be string or null")),(!n.atlas||typeof n.atlas!="object")&&r.push("missing atlas"),n.atlas?.image!=="spritesheet.webp"&&r.push("atlas image must be spritesheet.webp"),J(n.atlas?.image??"")&&r.push("unsafe path in atlas image"),(typeof n.atlas?.sha256!="string"||!/^[a-f0-9]{64}$/i.test(n.atlas.sha256))&&r.push("atlas sha256 must be a 64 character hex digest"),n.atlas?.format!=="webp"&&r.push("atlas format must be webp"),(n.atlas?.columns!==m.columns||n.atlas?.rows!==m.rows||n.atlas?.frameCount!==m.frameCount||n.atlas?.cellWidth!==m.cellWidth||n.atlas?.cellHeight!==m.cellHeight||n.atlas?.width!==m.width||n.atlas?.height!==m.height)&&r.push("Petdex atlas geometry must be exactly 8x9 cells in a 1536x1872 WebP sheet");let i=wr(t);(!i||i.width!==m.width||i.height!==m.height)&&r.push("spritesheet.webp must be a 1536x1872 WebP image"),i?.hasAlpha||r.push("spritesheet.webp must preserve transparent background alpha; opaque contact sheets or grid backgrounds are not valid Petdex assets");let o=Q(t);n.atlas?.sha256!==o&&r.push("spritesheet sha256 does not match pet.json");let c=n.animations;if(!c||typeof c!="object")r.push("missing animations");else{let s=Object.keys(c).sort(),l=[...M].sort();s.join("\0")!==l.join("\0")&&r.push(`animations must include exactly ${M.join(", ")}`)}let a=[];if(M.forEach((s,l)=>{let u=c?.[s];if(!u){r.push(`missing animation ${s}`);return}u.row!==l&&r.push(`animation ${s} row must be ${l}`);let d=Je[s],p=l*m.columns,f=Array.from({length:d.frames},(w,g)=>p+g);!Array.isArray(u.frames)||u.frames.length!==d.frames?r.push(`animation ${s} must have exactly ${d.frames} frames`):u.frames.some((w,g)=>w!==f[g])?r.push(`animation ${s} frames must be cells ${p}..${p+d.frames-1} (row ${l})`):a.push(...u.frames),!Array.isArray(u.durations)||u.durations.length!==d.frames?r.push(`animation ${s} must have ${d.frames} durations`):u.durations.some(w=>typeof w!="number"||w<=0)&&r.push(`animation ${s} durations must be positive milliseconds`),typeof u.loop!="boolean"&&r.push(`animation ${s} loop must be boolean`)}),(n.thumbnail?.frame===void 0||n.thumbnail.frame<0||n.thumbnail.frame>71)&&r.push("thumbnail frame must be 0..71"),r.length>0)throw new Error(r.join("; "));return{schema:Be,assetId:n.id,valid:!0,validatedAt:new Date().toISOString(),errors:[],warnings:[],atlas:{format:"webp",columns:8,rows:9,frameCount:72,cellWidth:192,cellHeight:208,width:i?.width??m.width,height:i?.height??m.height,sha256:o},animations:{ids:[...M],minFrame:Math.min(...a),maxFrame:Math.max(...a)}}}function Pe(e){return`data:image/webp;base64,${e.toString("base64")}`}function Q(e){return xr("sha256").update(e).digest("hex")}function J(e){return!e||e.includes("..")||e.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(e)||e.includes("\\")}function wr(e){if(e.length<30||e.subarray(0,4).toString("ascii")!=="RIFF"||e.subarray(8,12).toString("ascii")!=="WEBP")return null;let t=12,r=!1;for(;t+8<=e.length;){let n=e.subarray(t,t+4).toString("ascii"),i=e.readUInt32LE(t+4),o=t+8;if(n==="ALPH"&&(r=!0),n==="VP8X"&&o+10<=e.length)return{width:He(e,o+4)+1,height:He(e,o+7)+1,hasAlpha:(e[o]&16)!==0||r};if(n==="VP8 "&&o+10<=e.length)return{width:e.readUInt16LE(o+6)&16383,height:e.readUInt16LE(o+8)&16383,hasAlpha:r};if(n==="VP8L"&&o+5<=e.length){let c=e[o+1],a=e[o+2],s=e[o+3],l=e[o+4];return{width:1+((a&63)<<8|c),height:1+((l&15)<<10|s<<2|(a&192)>>6),hasAlpha:!0}}t=o+i+i%2}return null}function He(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}var Ge="qlogic.petdex.production.v1",ye="2048x2048";function ze(e){return e.referenceMode==="refine"?"refine":e.referenceImageUrl?"reference":"text"}function We(e,t){let r=t.filter(n=>n.kind==="row-strip"&&!!n.animationId).map(n=>({animationId:n.animationId,status:"pass",frames:m.columns}));return{schema:Ge,status:"complete",sourceMode:e,contract:m,jobs:t,qa:{contactSheet:{rows:m.rows,columns:m.columns,frameCount:m.frameCount},rowReports:r}}}function xe(e,t){e.provider??=t.provider,e.model??=t.model,e.billingUnit??=t.billingUnit,e.size??=t.size,e.billingQuantity+=t.billingQuantity??1,e.durationMs+=t.durationMs??0}import{resolve as Tr}from"node:path";import{join as kr}from"node:path";import{homedir as br}from"node:os";import{join as I}from"node:path";import{existsSync as Di}from"node:fs";import{createHash as Sr}from"node:crypto";import{resolve as Ar}from"node:path";function we(e){return Sr("sha256").update(Ar(e).toLowerCase()).digest("hex").slice(0,16)}var Xe=".qlogicagent";function k(){return process.env.QLOGICAGENT_HOME||I(br(),Xe)}function Y(){let e=process.env.QLOGIC_LLMROUTER_USER_ID?.trim();if(e)return e;let t=process.env.QLOGIC_IMPLICIT_OWNER_ID?.trim();if(t)return t;let r=process.env.QLOGIC_DEVICE_ID?.trim();return r?`oc_${r}`:"oc_local"}function Ir(e){let t=e.trim();if(!t)throw new Error("ownerUserId is required for profile-scoped storage");return encodeURIComponent(t).replace(/\./g,"%2E")}function Z(e=Y()){return I(k(),"profiles",Ir(e))}function qe(e=Y()){return I(Z(e),"memory")}var vr="projectData";function Ke(){return I(k(),vr)}function Se(e){if(!e)throw new Error("getProjectDataDirById: projectId is required");return I(Ke(),e)}function Ve(){return I(k(),"plugins")}function Qe(){return I(k(),"skills")}function Ye(){return I(Z(),"settings.json")}function Ze(){return I(k(),"plugin-cache")}function et(){return I(k(),"mcp.json")}function tt(){return I(k(),"marketplace.json")}function N(e){if(!e)throw new Error("getProjectAgentDir: cwd is required (must not fall back to process.cwd())");return I(e,Xe)}function rt(e){return I(N(e),"plugins")}function nt(e){return I(N(e),"settings.json")}function it(e){return I(N(e),"INSTRUCTIONS.md")}function ot(e){return I(N(e),"rules")}import{resolve as Ti}from"node:path";var Er=()=>{},Ae;function st(){if(Dr(),!Ae)throw new Error("host project authority negotiated but snapshot is not hydrated");return{activeProjectId:Ae.activeProjectId,projects:Ae.projects.map(e=>({...e}))}}function Dr(){let e=Er();if(!e)throw new Error("gateway project authority is not available");return e}function jr(){let e=st();return{activeProjectId:e.activeProjectId,projects:e.projects.map(t=>({...t}))}}function at(e){return jr().projects.find(t=>t.id===e)??null}function _r(e){return at(e)?e:we(e)}function be(e){return Se(_r(e))}function ct(e){return kr(be(e),"sessions")}var Ie=class{constructor(t={}){this.options=t}options;lastActiveWorkdir=null;getActiveProjectRoot(){return this.options.getActiveProjectRoot?.()??process.cwd()}setActiveWorkdir(t){let r=Tr(t);this.lastActiveWorkdir=r,this.options.setActiveWorkdir?.(r)}getActiveWorkdir(){return this.lastActiveWorkdir??this.getActiveProjectRoot()}resolveProjectDir(t){return this.options.resolveProjectDir?.(t)}resolveActiveOwnerUserId(){return Y()}getUserAgentHome(){return k()}getOwnerProfileDir(t){return Z(t)}getProfileMemoryDir(t){return qe(t)}getUserSettingsPath(){return Ye()}getUserSkillsDir(){return Qe()}getUserPluginsDir(){return Ve()}getUserMcpConfigPath(){return et()}getUserPluginCacheDir(){return Ze()}getUserMarketplaceConfigPath(){return tt()}getProjectAgentDir(t=this.getActiveProjectRoot()){return N(t)}getProjectSettingsPath(t=this.getActiveProjectRoot()){return nt(t)}getProjectInstructionsPath(t=this.getActiveProjectRoot()){return it(t)}getProjectPluginsDir(t=this.getActiveProjectRoot()){return rt(t)}getProjectRulesDir(t=this.getActiveProjectRoot()){return ot(t)}getProjectSessionDataRoot(t=this.getActiveProjectRoot()){return ct(t)}},Cr=new Ie;function ee(){return Cr}import S from"node:fs";import b from"node:path";var lt={enabled:!0,selectedPetAssetId:"builtin-anime-horse-girl"},Ur=120,T=class{constructor(t){this.ownerUserId=t;this.petDir=b.join(ee().getOwnerProfileDir(t),"pet"),this.profilePath=b.join(this.petDir,"profile.json")}ownerUserId;petDir;profilePath;loadProfile(){let t=this.readProfileState();return t.corrupt&&console.error(`[pet-profile] Pet profile at ${this.profilePath} is corrupted (${t.reason}); serving default profile for reads. Writes are refused until the file is fixed or removed.`),t.profile}loadProfileForWrite(){let t=this.readProfileState();if(t.corrupt)throw new Error(`[pet-profile] Pet profile at ${this.profilePath} is corrupted (${t.reason}); refusing to overwrite it. Fix or remove the file, then retry.`);return t.profile}readProfileState(){if(!S.existsSync(this.profilePath))return{profile:this.defaultProfile(),corrupt:!1};try{let t=JSON.parse(S.readFileSync(this.profilePath,"utf-8"));return!t||typeof t!="object"||Array.isArray(t)?{profile:this.defaultProfile(),corrupt:!0,reason:"not a JSON object"}:{profile:this.normalizeProfile(t),corrupt:!1}}catch(t){return{profile:this.defaultProfile(),corrupt:!0,reason:t instanceof Error?t.message:String(t)}}}updateSoul(t){let r=this.loadProfileForWrite();return r.soul=t,this.writeProfile(r)}updatePreferences(t){let r=this.loadProfileForWrite();return r.preferences={...r.preferences,...t,selectedPetAssetId:t.selectedPetAssetId??r.preferences.selectedPetAssetId},this.writeProfile(r)}saveJourneySnapshot(t){let r=this.loadProfileForWrite(),n=b.join(this.petDir,"journey");S.mkdirSync(n,{recursive:!0}),S.writeFileSync(b.join(n,`${t.date}.json`),JSON.stringify(t,null,2),"utf-8");let i=new Set(r.journeyDates);i.add(t.date);let o=[...i].sort();for(;o.length>Ur;){let c=o.shift();c&&S.rmSync(b.join(n,`${c}.json`),{force:!0})}return r.journeyDates=o,this.writeProfile(r)}listJourneyDates(){return this.loadProfile().journeyDates}getJourneySnapshot(t){let r=b.join(this.petDir,"journey",`${t}.json`);if(!S.existsSync(r))return null;try{return JSON.parse(S.readFileSync(r,"utf-8"))}catch(n){return console.error(`[pet-profile] Journey snapshot at ${r} is unreadable or corrupted (${n instanceof Error?n.message:String(n)}); returning no entry.`),null}}upsertCustomPet(t){let r=this.loadProfileForWrite(),n=b.join(this.petDir,"assets",t.id);S.mkdirSync(n,{recursive:!0}),S.writeFileSync(b.join(n,"pet.json"),JSON.stringify(t,null,2),"utf-8");let i=ut(t),o=r.customPets.find(c=>c.id===t.id);return r.customPets=o?r.customPets.map(c=>c.id===t.id?i:c):[i,...r.customPets],r.preferences={...r.preferences,selectedPetAssetId:t.id},this.writeProfile(r)}deleteCustomPet(t){let r=this.loadProfileForWrite();return r.customPets=r.customPets.filter(n=>n.id!==t),S.rmSync(b.join(this.petDir,"assets",t),{recursive:!0,force:!0}),r.preferences.selectedPetAssetId===t&&(r.preferences={...r.preferences,selectedPetAssetId:"builtin-anime-horse-girl"}),this.writeProfile(r)}listCustomPets(){return this.loadProfile().customPets}getCustomPet(t){let r=b.join(this.petDir,"assets",t,"pet.json");if(!S.existsSync(r))return null;try{let n=JSON.parse(S.readFileSync(r,"utf-8"));return Or(n)?n:(console.error(`[pet-profile] Custom pet asset at ${r} does not match the petdex asset schema; treating the pet as unavailable.`),null)}catch(n){return console.error(`[pet-profile] Custom pet asset at ${r} is unreadable or corrupted (${n instanceof Error?n.message:String(n)}); treating the pet as unavailable.`),null}}getCustomPetSpritesheet(t){let r=b.join(this.petDir,"assets",t,"spritesheet.webp");return S.existsSync(r)?S.readFileSync(r):null}findReusableCustomPetId(t){let r=this.loadProfile(),n=r.customPets.filter(o=>o.sourceKind===t.sourceKind&&F(o.name)===F(t.name)&&F(o.description)===F(t.description));return n.length===0?null:(n.find(o=>o.id===r.preferences.selectedPetAssetId)??n[0])?.id??null}compactDuplicateCustomPets(){let t=this.loadProfileForWrite(),r=new Map,n=[];for(let i of t.customPets){let o=Lr(i),c=r.get(o);if(!c){r.set(o,i);continue}let a=i.id===t.preferences.selectedPetAssetId,s=a?c:i;n.push(s.id),a&&r.set(o,i)}if(n.length===0)return t;t.customPets=[...r.values()];for(let i of n)S.rmSync(b.join(this.petDir,"assets",i),{recursive:!0,force:!0});return t.customPets.some(i=>i.id===t.preferences.selectedPetAssetId)||(t.preferences={...t.preferences,selectedPetAssetId:t.customPets[0]?.id??"builtin-anime-horse-girl"}),this.writeProfile(t)}writeCustomPetAssetFiles(t,r,n,i){let o=b.join(this.petDir,"assets",t.id);return S.mkdirSync(o,{recursive:!0}),S.writeFileSync(b.join(o,"pet.json"),JSON.stringify(t,null,2),"utf-8"),S.writeFileSync(b.join(o,"spritesheet.webp"),r),S.writeFileSync(b.join(o,"validation.json"),JSON.stringify(n,null,2),"utf-8"),i&&S.writeFileSync(b.join(o,"production-run.json"),JSON.stringify(i,null,2),"utf-8"),this.upsertCustomPet(t)}defaultProfile(){return{version:1,ownerUserId:this.ownerUserId,soul:null,preferences:{...lt},customPets:[],journeyDates:[],updatedAt:new Date().toISOString()}}normalizeProfile(t){return{version:1,ownerUserId:this.ownerUserId,soul:t.soul??null,preferences:{...lt,...t.preferences??{},selectedPetAssetId:Mr(t.preferences)},customPets:Array.isArray(t.customPets)?t.customPets.filter(dt).map(ut):[],journeyDates:Array.isArray(t.journeyDates)?[...new Set(t.journeyDates)].sort():[],updatedAt:typeof t.updatedAt=="string"?t.updatedAt:new Date().toISOString()}}writeProfile(t){let r={...t,version:1,ownerUserId:this.ownerUserId,updatedAt:new Date().toISOString()};return S.mkdirSync(this.petDir,{recursive:!0}),S.writeFileSync(this.profilePath,JSON.stringify(r,null,2),"utf-8"),r}};function ut(e){return{id:e.id,assetKind:"petdex",sourceKind:e.sourceKind??("source"in e&&e.source&&typeof e.source=="object"?e.source.kind:"forge"),name:e.name,description:e.description,createdAt:e.createdAt,updatedAt:e.updatedAt,atlas:{format:e.atlas.format,columns:e.atlas.columns,rows:e.atlas.rows,frameCount:e.atlas.frameCount,cellWidth:e.atlas.cellWidth,cellHeight:e.atlas.cellHeight,width:e.atlas.width,height:e.atlas.height,sha256:e.atlas.sha256},animations:e.animations,thumbnail:e.thumbnail}}function Lr(e){return[e.sourceKind??"forge",F(e.name),F(e.description)].join(`
|
|
9
|
-
`)}function F(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function dt(e){if(!e||typeof e!="object")return!1;let t=e;return t.assetKind==="petdex"&&typeof t.id=="string"&&(t.sourceKind==="builtin"||t.sourceKind==="upload"||t.sourceKind==="forge"||t.sourceKind==="community"||t.sourceKind===void 0)&&typeof t.name=="string"&&typeof t.description=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"&&pt(t.atlas)}function Mr(e){if(typeof e?.selectedPetAssetId=="string"){let t=e.selectedPetAssetId.trim();if(t==="builtin-anime-horse-girl"||t&&!t.startsWith("builtin-"))return t}return"builtin-anime-horse-girl"}function Or(e){if(!dt(e))return!1;let t=e;return t.schema==="qlogic.petdex.asset.v1"&&$r(t.atlas)&&typeof t.source=="object"&&t.source!==null&&typeof t.animations=="object"&&t.animations!==null&&typeof t.thumbnail=="object"&&t.thumbnail!==null}function pt(e){if(!e||typeof e!="object")return!1;let t=e;return t.format==="webp"&&t.columns===8&&t.rows===9&&t.frameCount===72&&t.cellWidth===192&&t.cellHeight===208&&t.width===1536&&t.height===1872&&typeof t.sha256=="string"}function $r(e){return pt(e)&&e.image==="spritesheet.webp"}var te=class{soul=null;profileService;constructor(t,r){this.profileService=new T(r??ee().resolveActiveOwnerUserId())}load(){if(this.soul)return this.soul;let t=this.profileService.loadProfile();if(!t.soul)return null;let r=t.soul;return this.soul=X(t.soul),Ne(r,this.soul)&&this.persist(),this.soul}async ensureSoul(t,r,n){let i=this.load();if(i)return i;let o=`${t}-xiaozhi-claw`,c;return r&&(c=await r(me(o),ge(o))),this.soul=Fe({seed:o,hatchedAt:new Date().toISOString(),identity:c,requestedBreedId:n}),this.persist(),this.soul}addExperience(t){if(!this.soul)return{leveledUp:!1,level:0,experience:0};this.soul.experience+=t;let r=this.soul.level*100,n=!1;for(;this.soul.experience>=r;)this.soul.experience-=r,this.soul.level+=1,n=!0;return this.persist(),{leveledUp:n,level:this.soul.level,experience:this.soul.experience}}getSoul(){return this.soul}updateSoul(t){this.soul=X(t),this.persist()}persist(){this.profileService.updateSoul(this.soul)}};var ft=new q(he);import*as re from"node:fs";import*as ve from"node:path";function Nr(e){let t=new Date(e),r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${i}`}async function mt(e,t){let r=new Set,n=new Set,i=new Set,o={},c=[],a=0,s=0;for(let l of t.listProjectIds()){let u;try{u=await t.readProjectTurns(l)}catch{continue}for(let d of u)if(Nr(d.createdAt)===e){a++,n.add(l),d.model&&i.add(d.model),d.agentMode&&(o[d.agentMode]=(o[d.agentMode]??0)+1);for(let p of d.toolSummary?.calledTools??[])r.add(p);s+=d.fileContext?.changedFileCount??0;for(let p of d.fileContext?.changedPathsPreview??[])c.length<8&&c.push(p)}}return{date:e,turns:a,filesChanged:s,toolsUsed:[...r],projects:[...n],models:[...i],modes:o,topChangedPaths:c}}function gt(e,t){let r=e?.name?.trim()||"\u4F60\u7684\u4F19\u4F34",n=e?`\u4F60\u662F\u4E00\u53EA\u540D\u53EB\u300C${r}\u300D\u7684${e.species||"\u5C0F\u5BA0\u7269"},\u6027\u683C${e.personality||"\u6E29\u548C"}${e.catchphrase?`,\u53E3\u5934\u7985\u662F\u300C${e.catchphrase}\u300D`:""}\u3002`:`\u4F60\u662F\u7528\u6237\u7684\u684C\u9762\u5BA0\u7269\u4F19\u4F34\u300C${r}\u300D\u3002`,i=[`\u56DE\u5408\u6570 ${t.turns}`,`\u6539\u52A8\u6587\u4EF6 ${t.filesChanged} \u4E2A`,t.toolsUsed.length?`\u7528\u5230\u7684\u5DE5\u5177:${t.toolsUsed.join("\u3001")}`:"",t.projects.length?`\u6D89\u53CA ${t.projects.length} \u4E2A\u9879\u76EE`:"",t.topChangedPaths.length?`\u90E8\u5206\u6539\u52A8\u6587\u4EF6:${t.topChangedPaths.join("\u3001")}`:""].filter(Boolean).join(";");return[n,`\u4E0B\u9762\u662F\u4E3B\u4EBA ${t.date} \u8FD9\u4E00\u5929\u5728\u7535\u8111\u4E0A\u548C\u4F60\u4E00\u8D77\u5DE5\u4F5C\u7684\u771F\u5B9E\u8BB0\u5F55:`,`${i}\u3002`,"\u8BF7\u4EE5\u7B2C\u4E00\u4EBA\u79F0(\u5BA0\u7269\u7684\u53E3\u543B)\u3001\u7528 2-4 \u53E5\u6E29\u6696\u53E3\u8BED\u5316\u7684\u4E2D\u6587,\u8BB2\u8BB2\u4ECA\u5929\u966A\u4E3B\u4EBA\u505A\u4E86\u4EC0\u4E48\u3002","\u53EA\u80FD\u4F9D\u636E\u4E0A\u9762\u7ED9\u51FA\u7684\u771F\u5B9E\u8BB0\u5F55,\u4E0D\u8981\u7F16\u9020\u6570\u5B57\u3001\u6587\u4EF6\u540D\u6216\u6CA1\u53D1\u751F\u8FC7\u7684\u4E8B;\u4E0D\u8981\u9010\u6761\u7F57\u5217\u6570\u636E,\u8981\u50CF\u5728\u8DDF\u4E3B\u4EBA\u804A\u5929\u3002"].join(`
|
|
10
|
-
`)}var Fr=220;function Hr(e,t){return`${e}:\u4ECA\u5929\u6211\u966A\u4F60\u5FD9\u4E86 ${t.turns} \u4E2A\u56DE\u5408,\u6539\u4E86 ${t.filesChanged} \u4E2A\u6587\u4EF6,\u8F9B\u82E6\u5566~`}async function ht(e){let t=await e.aggregate();if(t.turns===0)return null;let r={turns:t.turns,filesChanged:t.filesChanged,toolsUsed:t.toolsUsed,projects:t.projects},n=null;if(e.llmCall)try{n=await e.llmCall(gt(e.resolveSoul(),t),Fr)}catch{n=null}return(!n||!n.trim())&&(n=Hr(e.petName,t)),{date:e.date,day:1,petName:e.petName,stateLabel:"\u672C\u673A\u5DE5\u4F5C",narrative:n.trim(),stats:r,generatedAt:e.now?e.now():new Date().toISOString(),generator:e.generator??"auto"}}var Br=120;function Pt(e){let t=ve.join(be(e),"turn-telemetry"),r;try{r=re.readdirSync(t)}catch{return[]}let n=[];for(let i of r)if(i.endsWith(".json"))try{n.push(JSON.parse(re.readFileSync(ve.join(t,i),"utf-8")))}catch{}return n}function Jr(e){let t=new Date;t.setHours(0,0,0,0),t.setDate(t.getDate()-e);let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${i}`}async function yt(e,t){let r=new T(e),n=r.loadProfile(),i=n.soul?.name?.trim()||"\u5BA0\u7269",o=Math.max(1,Math.min(t.maxDays??7,Br)),c=[];for(let a=1;a<=o;a++){let s=Jr(a);if(r.getJourneySnapshot(s))continue;let l=await ht({date:s,petName:i,aggregate:()=>mt(s,{listProjectIds:t.listProjectIds,readProjectTurns:async u=>Pt(u)}),resolveSoul:()=>n.soul,llmCall:t.llmCall,generator:t.generator});l&&(r.saveJourneySnapshot(l),c.push(s),t.log?.(`[pet-journey] generated ${s}`))}return c}import{randomUUID as wt}from"node:crypto";import C from"node:fs";import U from"node:path";import{fileURLToPath as Gr}from"node:url";import{gzipSync as mo}from"node:zlib";import{createCanvas as zr,loadImage as Wr}from"@napi-rs/canvas";async function Ee(e){return Xr(C.readFileSync(e))}async function Xr(e){let t=await nn(e);for(let s of t.keys())if(J(s))throw new Error(`unsafe path in Petdex package: ${s}`);if(t.has("manifest.json")||[...t.keys()].some(s=>s.toLowerCase().endsWith(".svg")))throw new Error("SVG .pet state packages are not supported by Petdex v1");let r=t.get("pet.json");if(!r)throw new Error("Petdex package missing pet.json");let n=JSON.parse(r.toString("utf-8")),i=tn(n)??"spritesheet.webp";if(J(i))throw new Error(`unsafe path in Petdex manifest: ${i}`);let o=t.get(i);if(!o)throw new Error(`Petdex package missing ${i}`);let c=Zr(n,o),a=_(c,o);return{manifest:c,spritesheet:o,validation:a}}async function ie(e){C.mkdirSync(e.outputDir,{recursive:!0});let t=Yr(e.fileName??`${e.asset.id}.petdex`),r=U.join(e.outputDir,t.endsWith(".petdex")?t:`${t}.petdex`);return C.writeFileSync(r,qr(e)),r}function qr(e){let t=_(e.asset,e.spritesheet),r=[{name:"pet.json",data:Buffer.from(JSON.stringify(e.asset,null,2),"utf-8")},{name:"spritesheet.webp",data:e.spritesheet},{name:"validation.json",data:Buffer.from(JSON.stringify(t,null,2),"utf-8")},...e.productionRun?[{name:"production-run.json",data:Buffer.from(JSON.stringify(e.productionRun,null,2),"utf-8")}]:[]];return on(r)}async function oe(e){let t=e.now??new Date().toISOString(),r=e.id??`petdex-${wt()}`,n=await Qr(e.spritesheet),i=Q(n),o={schema:O,id:r,assetKind:"petdex",name:e.name,description:e.description,createdAt:t,updatedAt:t,source:{kind:e.sourceKind??"forge",prompt:e.prompt??null},sourcePrompt:e.prompt??void 0,atlas:{image:"spritesheet.webp",...m,sha256:i},animations:K(),thumbnail:{frame:0}},c=_(o,n);return{asset:o,spritesheet:n,validation:c}}var St=["builtin-anime-horse-girl"],ne=null;function At(){return[...St]}async function bt(){return ne||(ne=Promise.all(St.map(e=>Kr(e))).catch(e=>{throw ne=null,e})),ne}async function Kr(e){let t=Vr(),r=U.join(t,`${e}.petdex`);if(C.existsSync(r)){let l=await Ee(r);return xt(e,l.manifest),{asset:l.manifest,spritesheet:l.spritesheet,validation:l.validation}}let n=U.join(t,e),i=U.join(n,"pet.json"),o=U.join(n,"spritesheet.webp");if(!C.existsSync(i)||!C.existsSync(o))throw new Error(`Missing published builtin Petdex asset ${e} under ${t}`);let c=JSON.parse(C.readFileSync(i,"utf-8")),a=C.readFileSync(o),s=_(c,a);return xt(e,c),{asset:c,spritesheet:a,validation:s}}function Vr(){let e=process.env.QLOGICAGENT_BUILTIN_PETDEX_DIR?.trim();return e?U.resolve(e):U.resolve(U.dirname(Gr(import.meta.url)),"builtin-petdex")}function xt(e,t){if(t.id!==e)throw new Error(`Builtin Petdex asset id mismatch: expected ${e}, got ${t.id}`);if(t.source.kind!=="builtin")throw new Error(`Builtin Petdex asset ${e} must declare source.kind=builtin`)}async function Qr(e){let t=await Wr(e),r=zr(m.width,m.height),n=r.getContext("2d");return n.clearRect(0,0,m.width,m.height),n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",n.drawImage(t,0,0,m.width,m.height),Buffer.from(await r.encode("webp"))}function Yr(e){return e.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^_+/,"")||"petdex-asset.petdex"}function Zr(e,t){if(en(e))return e;if(!It(e))throw new Error("Petdex package pet.json must be either standard Petdex metadata or qlogic.petdex.asset.v1");let r=new Date().toISOString(),n=rn(e.id),i=Q(t);return{schema:O,id:n,assetKind:"petdex",name:e.displayName.trim(),description:e.description.trim(),createdAt:r,updatedAt:r,source:{kind:"upload",prompt:null},sourcePrompt:void 0,atlas:{image:"spritesheet.webp",...m,sha256:i},animations:K(),thumbnail:{frame:0}}}function en(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&e.schema===O}function It(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.id=="string"&&t.id.trim()!==""&&typeof t.displayName=="string"&&t.displayName.trim()!==""&&typeof t.description=="string"&&t.description.trim()!==""&&typeof t.spritesheetPath=="string"&&t.spritesheetPath.trim()!==""}function tn(e){return It(e)?e.spritesheetPath.trim():null}function rn(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||`petdex-${wt()}`}async function nn(e){let t=new Map,r=0;for(;r<e.length-4&&e.readUInt32LE(r)===67324752;){let i=e.readUInt16LE(r+8),o=e.readUInt32LE(r+18),c=e.readUInt32LE(r+22),a=e.readUInt16LE(r+26),s=e.readUInt16LE(r+28),l=r+30,u=e.subarray(l,l+a).toString("utf-8"),d=l+a+s,p=e.subarray(d,d+o);if(i===0)t.set(u,e.subarray(d,d+c));else if(i===8){let{inflateRawSync:f}=await import("node:zlib");t.set(u,f(p))}r=d+o}return t}function on(e){let t=[],r=[],n=0,{time:i,date:o}=sn();for(let l of e){if(J(l.name))throw new Error(`unsafe path in Petdex package entry: ${l.name}`);let u=Buffer.from(l.name,"utf-8"),d=cn(l.data),p=Buffer.alloc(30);p.writeUInt32LE(67324752,0),p.writeUInt16LE(20,4),p.writeUInt16LE(2048,6),p.writeUInt16LE(0,8),p.writeUInt16LE(i,10),p.writeUInt16LE(o,12),p.writeUInt32LE(d,14),p.writeUInt32LE(l.data.length,18),p.writeUInt32LE(l.data.length,22),p.writeUInt16LE(u.length,26),p.writeUInt16LE(0,28),t.push(p,u,l.data);let f=Buffer.alloc(46);f.writeUInt32LE(33639248,0),f.writeUInt16LE(20,4),f.writeUInt16LE(20,6),f.writeUInt16LE(2048,8),f.writeUInt16LE(0,10),f.writeUInt16LE(i,12),f.writeUInt16LE(o,14),f.writeUInt32LE(d,16),f.writeUInt32LE(l.data.length,20),f.writeUInt32LE(l.data.length,24),f.writeUInt16LE(u.length,28),f.writeUInt16LE(0,30),f.writeUInt16LE(0,32),f.writeUInt16LE(0,34),f.writeUInt16LE(0,36),f.writeUInt32LE(0,38),f.writeUInt32LE(n,42),r.push(f,u),n+=p.length+u.length+l.data.length}let c=n,a=Buffer.concat(r),s=Buffer.alloc(22);return s.writeUInt32LE(101010256,0),s.writeUInt16LE(0,4),s.writeUInt16LE(0,6),s.writeUInt16LE(e.length,8),s.writeUInt16LE(e.length,10),s.writeUInt32LE(a.length,12),s.writeUInt32LE(c,16),s.writeUInt16LE(0,20),Buffer.concat([...t,a,s])}function sn(){let e=new Date,t=e.getHours()<<11|e.getMinutes()<<5|Math.floor(e.getSeconds()/2),r=e.getFullYear()-1980<<9|e.getMonth()+1<<5|e.getDate();return{time:t,date:r}}var an=new Uint32Array(256).map((e,t)=>{let r=t;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;return r>>>0});function cn(e){let t=4294967295;for(let r of e)t=an[(t^r)&255]^t>>>8;return(t^4294967295)>>>0}import y from"node:fs/promises";import Mt from"node:os";import h from"node:path";import{createCanvas as le,loadImage as _e}from"@napi-rs/canvas";import{spawn as ln}from"node:child_process";import{existsSync as vt}from"node:fs";import{dirname as Et,join as ce}from"node:path";import{fileURLToPath as un}from"node:url";var dn=Et(un(import.meta.url)),se,ae;function Dt(e,t,r){return new Promise(n=>{let i="",o="",c=!1,a=u=>{c||(c=!0,clearTimeout(l),n(u))},s=ln(e,t,{windowsHide:!0}),l=setTimeout(()=>{s.kill("SIGKILL"),a({ok:!1,stdout:i,stderr:`${o}
|
|
11
|
-
[hatch-pet] timed out after ${r}ms`,code:null})},r);l.unref?.(),s.stdout?.on("data",u=>{i+=u.toString()}),s.stderr?.on("data",u=>{o+=u.toString()}),s.on("error",u=>a({ok:!1,stdout:i,stderr:`${o}${u instanceof Error?u.message:String(u)}`,code:null})),s.on("close",u=>a({ok:u===0,stdout:i,stderr:o,code:u}))})}function pn(){let e=[],t=process.env.QLOGICAGENT_PYTHON?.trim();return t&&e.push(t),e.push("python3","python","py"),e}async function fn(e){let t=await Dt(e,["-c","import PIL; import sys; sys.stdout.write('hatchpet-ok')"],1e4);return t.code===0&&t.stdout.includes("hatchpet-ok")}async function jt(){if(se!==void 0)return se;for(let e of pn())if(await fn(e))return se=e,e;return se=null,null}function Rt(){if(ae!==void 0)return ae;let e=[],t=process.env.QLOGICAGENT_HATCHPET_DIR?.trim();t&&e.push(ce(t,"scripts"),t);let r=dn;for(let n=0;n<7;n++){e.push(ce(r,"vendor","hatch-pet","scripts"));let i=Et(r);if(i===r)break;r=i}for(let n of e)if(vt(ce(n,"compose_atlas.py")))return ae=n,n;return ae=null,null}async function kt(){return await jt()!==null&&Rt()!==null}async function De(e,t,r={}){let n=await jt();if(!n)throw new Error("Petdex generation requires Python with Pillow; none found (set QLOGICAGENT_PYTHON to a python that can `import PIL`)");let i=Rt();if(!i)throw new Error("Vendored hatch-pet scripts not found (set QLOGICAGENT_HATCHPET_DIR)");let o=ce(i,e);if(!vt(o))throw new Error(`Unknown hatch-pet script: ${e}`);return Dt(n,[o,...t],r.timeoutMs??12e4)}function mn(e){let t=(e??"").trim();return/\bfail\b/i.test(t)&&!/\bpass\b/i.test(t.slice(0,8))?{ok:!1,reason:(t.match(/fail[:\s-]*(.+)/i)?.[1]??"").trim().slice(0,200)}:{ok:!0,reason:""}}async function je(e,t,r=console.error){try{let n=await e();return n.trim()?mn(n):(r(`[petdex-forge] ${t.label} returned an empty verdict for ${t.target} (image likely not delivered to the model); accepting candidate unverified`),{ok:!0,reason:"",qaSkipped:!0})}catch(n){let i=n instanceof Error?n.message:String(n);return r(`[petdex-forge] ${t.label} call failed for ${t.target}: ${i}; accepting candidate unverified`),{ok:!0,reason:"",qaSkipped:!0}}}var _t="references/canonical-base.png",gn="single centered full-body desktop pet character on a flat chroma-key background, readable at pet size",hn="one horizontal animation row strip with evenly spaced full-body frames sharing a single consistent character identity",Pn="4096x1024",ke="#FF00FF",Ot="110",$t="stable-slots",yn="90",Nt=["STRICT BACKGROUND: render one single continuous flat background of the same solid color filling the entire image edge to edge.","Do NOT draw any picture frame, framed panel, border, mat, outline, box, gallery frame, white or light margin, or divider around or between the poses.","The poses sit directly on the one seamless flat background, evenly spaced, with nothing separating them.","IDENTITY LOCK: every frame is the EXACT same character \u2014 identical species, body shape, proportions, colors, palette, face, and markings. Do not redesign, restyle, recolor, or resize the character between frames; only its pose changes.","Each pose is ONE connected solid silhouette at a consistent size. No detached parts, sweat drops, tears, dust, puffs, sparkles, speed lines, motion blur, floating effects, or drop shadows."].join(" "),xn="Leftward gait is the framewise horizontal mirror of the approved rightward row, preserving frame order and timing semantics.",wn=2,Sn=2;async function Te(e,t,r={}){if(!await kt())throw new Error("Petdex forge requires the vendored Hatch-Pet pipeline (Python with Pillow). Install Python + Pillow or set QLOGICAGENT_PYTHON to a python that can `import PIL`.");let n={billingQuantity:0,durationMs:0},i=[],o=[],c=ze(e),a=await Kn(),s=await qn(e);try{await H("prepare_pet_run.py",["--pet-name",e.name,"--display-name",e.name,"--description",e.description,"--pet-notes",e.prompt?.trim()||e.description,"--pet-id",Yn(e.id??e.name),"--output-dir",a,"--chroma-key","auto",...s.flatMap(x=>["--reference",x])]);let l=h.join(a,"imagegen-jobs.json"),u=await zt(l),d=r.inspectImage,p=Math.max(1,r.candidates??wn),f=[],w=[],g=ke,j;for(let x of u.jobs){if(!!(x.derivation_policy?.may_derive&&x.derivation_policy.may_derive_from)&&!d){await Ht(a),i.push({id:`row-${x.id}`,kind:"row-strip",status:"complete",animationId:x.id,prompt:`derived: framewise-horizontal-mirror of ${x.derivation_policy.may_derive_from}`,inputImages:[],outputUrl:x.output_path});continue}let ue=await y.readFile(h.join(a,x.prompt_file),"utf-8"),qt=x.retry_prompt_file?await y.readFile(h.join(a,x.retry_prompt_file),"utf-8").catch(()=>{}):void 0;o.push(ue);let $=x.kind==="base-pet",{mediaUrl:Kt,inputImages:Vt,qaSkipped:Qt}=await Bt({runDir:a,job:x,prompt:ue,retryPrompt:qt,generateImage:t,inspectImage:d,candidates:p,usage:n,upload:r.uploadReferenceImage,baseDataUrl:j});Qt&&w.push($?"base-reference":`row-${x.id}`),$&&(await y.copyFile(h.join(a,x.output_path),h.join(a,_t)),g=await Qn(h.join(a,x.output_path)),j=await vn(h.join(a,_t))),x.status="complete",await y.writeFile(l,JSON.stringify(u,null,2),"utf-8"),i.push({id:$?"base-reference":`row-${x.id}`,kind:$?"reference":"row-strip",status:"complete",...$?{}:{animationId:x.id},prompt:ue,inputImages:Vt,outputUrl:Kt}),$||f.push(x)}let E=h.join(a,"decoded"),P=h.join(a,"frames"),A=h.join(a,"atlas.png"),v=h.join(a,"atlas.webp");await H("extract_strip_frames.py",["--decoded-dir",E,"--output-dir",P,"--chroma-key",g,"--key-threshold",Ot,"--method",$t]),await Dn({runDir:a,decodedDir:E,framesDir:P,generatedRows:f,chromaHex:g,generateImage:t,inspectImage:d,candidates:p,baseDataUrl:j,usage:n,upload:r.uploadReferenceImage,productionJobs:i});let D=h.join(a,"qa","contact-sheet.png");await Gt(a,P,A,v,D),j&&await $n({runDir:a,framesDir:P,atlasPng:A,atlasWebp:v,contactSheet:D,generatedRows:f,generateImage:t,inspectImage:d,candidates:p,usage:n,upload:r.uploadReferenceImage,baseDataUrl:j}),await Ce("render_animation_previews.py",["--frames-root",P,"--output-dir",h.join(a,"qa","previews")]);let L=await y.readFile(v);return{...await oe({id:e.id,name:e.name,description:e.description,prompt:e.prompt,spritesheet:L,sourceKind:"forge"}),prompt:o.join(`
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
`),productionRun:We(c,i),...w.length>0?{qaSkippedJobs:w}:{},model:n.model,size:n.size,durationMs:n.durationMs||void 0,...n.provider?{mediaUsage:{provider:n.provider,model:n.model??"unknown",billingUnit:n.billingUnit??"per_call",billingQuantity:n.billingQuantity||1}}:{}}}finally{await Lt(s.length?h.dirname(s[0]):void 0),Vn()||await Lt(a)}}async function Ft(e){let t=await Te(e.input,e.generateImage,{uploadReferenceImage:e.uploadReferenceImage}),r=h.join(e.outputDir,t.asset.id);await y.mkdir(r,{recursive:!0});let n=h.join(r,"pet.json"),i=h.join(r,"spritesheet.webp"),o=h.join(r,"validation.json"),c=h.join(r,"production-run.json");await y.writeFile(n,JSON.stringify(t.asset,null,2),"utf-8"),await y.writeFile(i,t.spritesheet),await y.writeFile(o,JSON.stringify(t.validation,null,2),"utf-8"),await y.writeFile(c,JSON.stringify(t.productionRun,null,2),"utf-8");let a=await ie({asset:t.asset,spritesheet:t.spritesheet,validation:t.validation,productionRun:t.productionRun,outputDir:e.outputDir,fileName:`${t.asset.id}.petdex`});return{...t,packagePath:a,assetDir:r,manifestPath:n,spritesheetPath:i,validationPath:o,productionRunPath:c}}async function G(e){if(e.startsWith("data:")){let t=e.match(/^data:[^;]+;base64,(.+)$/);if(!t)throw new Error("Generated Petdex image data URL is not base64 encoded");return Buffer.from(t[1],"base64")}if(/^https?:\/\//i.test(e)){let t=await fetch(e);if(!t.ok)throw new Error(`Generated Petdex image download failed: ${t.status} ${t.statusText}`);return Buffer.from(await t.arrayBuffer())}return e.startsWith("file://")?y.readFile(new URL(e)):y.readFile(e)}async function Ht(e){await H("derive_running_left_from_running_right.py",["--run-dir",e,"--confirm-appropriate-mirror","--decision-note",xn,"--force"])}async function Tt(e,t,r,n,i,o){let c=await zn(e,t,o),a=t.kind==="base-pet",s=c.filter(p=>p.role!=="layout-guide"),l=s.find(p=>p.role==="canonical-reference")??s[0],u=await n({prompt:`${r}
|
|
16
|
-
|
|
17
|
-
${Nt}`,purpose:a?"petdex-reference":"petdex-row-strip",...a?{}:{animationId:t.id},style:a?gn:hn,size:a?ye:Pn,imageUrl:l?.imageUrl,referenceImages:s,n:1,quality:"auto"});xe(i,u);let d=u.mediaUrls[0];if(!d)throw new Error(`Petdex generation returned no image for job ${t.id}`);return{mediaUrl:d,inputImages:s}}async function Re(e,t,r){let n=h.join(e,t.output_path);await y.mkdir(h.dirname(n),{recursive:!0}),await y.writeFile(n,await G(r))}async function Bt(e){let t=[e.prompt,...e.retryPrompt?[e.retryPrompt]:[]].slice(0,Sn),r=null;for(let i of t)for(let o=0;o<e.candidates;o++){let c=await Tt(e.runDir,e.job,i,e.generateImage,e.usage,e.upload);if(!e.inspectImage)return await Re(e.runDir,e.job,c.mediaUrl),c;let a=await An(e.inspectImage,e.job,c.mediaUrl,e.baseDataUrl);if(a.ok)return await Re(e.runDir,e.job,c.mediaUrl),a.qaSkipped?{...c,qaSkipped:!0}:c;r=c}let n=r??await Tt(e.runDir,e.job,e.prompt,e.generateImage,e.usage,e.upload);return await Re(e.runDir,e.job,n.mediaUrl),n}var Jt={idle:6,"running-right":8,"running-left":8,waving:4,jumping:5,failed:8,waiting:6,running:6,review:6};async function An(e,t,r,n){try{let i=t.kind==="base-pet"?bn:In(t.id,Jt[t.id]??6),o=t.kind==="base-pet"||!n?[r]:[r,n];return await je(()=>e({prompt:i,imageUrls:o}),{label:"vision QA",target:`job ${t.id}`})}catch(i){return console.error(`[petdex-forge] vision QA call failed for job ${t.id}: ${i instanceof Error?i.message:String(i)}; accepting candidate unverified`),{ok:!0,reason:"",qaSkipped:!0}}}var bn=["You are a strict desktop-pet sprite reviewer. The image is a single pet character reference.","Reply PASS only if ALL hold: one centered full-body cute pet; one flat solid background; no text, scenery, picture frames, borders, drop shadows, or detached effects.",'Reply with exactly "PASS" or "FAIL: <one short reason>".'].join(" ");function In(e,t){return[`You are a strict sprite-sheet reviewer. Image 1 is a horizontal strip of ${t} animation frames for a desktop pet's "${e}" animation. Image 2 is the canonical reference of the SAME pet.`,"Reply PASS only if ALL hold: (1) every frame is the SAME character as the reference \u2014 same species, colors, palette, face, proportions, markings; (2) one flat solid background with NO picture frames, borders, boxes, mats, panels, dividers, or copied guide lines; (3) each pose is a complete pet, fully inside its own area, not cut off or split between cells; (4) no detached effects \u2014 no drop shadows, sparkles, dust, tears, speed lines, or text.",'Reply with exactly "PASS" or "FAIL: <one short reason>".'].join(" ")}async function vn(e){let t=await y.readFile(e);return`data:${e.toLowerCase().endsWith(".webp")?"image/webp":"image/png"};base64,${t.toString("base64")}`}var En=2;async function Dn(e){let t=h.join(e.runDir,"qa","review.json"),r=()=>Ce("inspect_frames.py",["--frames-root",e.framesDir,"--json-out",t,"--chroma-adjacent-threshold",yn]);await r();let n=await Ut(t);for(let i of e.generatedRows){let o=0;for(;n&&Gn(n,i.id)&&o<En;)o++,await jn(e,i),await kn(e,await Rn(e,i)),await r(),n=await Ut(t)}}async function jn(e,t){let r=await y.readFile(h.join(e.runDir,t.prompt_file),"utf-8"),i=(t.retry_prompt_file?await y.readFile(h.join(e.runDir,t.retry_prompt_file),"utf-8").catch(()=>{}):void 0)??r,{mediaUrl:o,inputImages:c}=await Bt({runDir:e.runDir,job:t,prompt:i,generateImage:e.generateImage,inspectImage:e.inspectImage,candidates:e.candidates,usage:e.usage,upload:e.upload,baseDataUrl:e.baseDataUrl}),a=e.productionJobs.find(s=>s.id===`row-${t.id}`);a&&(a.prompt=i,a.outputUrl=o,a.inputImages=c)}async function Rn(e,t){return t.id!=="running-right"?t.id:!e.inspectImage&&await _n(h.join(e.decodedDir,"running-left.png"))?(await Ht(e.runDir),"running-right,running-left"):"running-right"}async function kn(e,t){await H("extract_strip_frames.py",["--decoded-dir",e.decodedDir,"--output-dir",e.framesDir,"--states",t,"--chroma-key",e.chromaHex,"--key-threshold",Ot,"--method",$t])}async function _n(e){return y.access(e).then(()=>!0,()=>!1)}async function Gt(e,t,r,n,i){await H("compose_atlas.py",["--frames-root",t,"--output",r,"--webp-output",n]),await H("validate_atlas.py",[r,"--json-out",h.join(e,"qa","validation.json")]),await Ce("make_contact_sheet.py",[r,"--output",i])}var Tn=4,Cn="one single centered full-body desktop pet pose on a flat chroma-key background",Un=120,Ln={idle:"a calm resting pose, breathing, standing still","running-right":"a mid-stride running pose facing and moving to the right","running-left":"a mid-stride running pose facing and moving to the left",waving:"raising a paw/hand/limb in a friendly wave",jumping:"a mid-air playful jump",failed:"a sad, deflated, slumped reaction pose",waiting:"an expectant waiting pose, looking up for input",running:"a focused working/thinking pose, busy but not foot-running",review:"a focused inspecting pose, leaning in to review"},Mn=400,On=45;async function $n(e){let t=0;for(let r of e.generatedRows){let n=Jt[r.id]??6,i=[];for(let s=0;s<n;s++)i.push(await Nn(h.join(e.framesDir,r.id,`${String(s).padStart(2,"0")}.png`)));let o=Ct(i.map(s=>s.count).filter(s=>s>0)),c=Ct(i.map(s=>s.lum).filter(s=>s>0)),a=0;for(let s=0;s<n&&a<Tn;s++){let l=i[s],u=l.count<Math.max(Mn,o*.4),d=l.lum<On||c>0&&l.lum<c*.6;if(!u&&!d)continue;let p=await Hn(e,r,s,n);p&&(await Bn(await G(p),h.join(e.framesDir,r.id,`${String(s).padStart(2,"0")}.png`)),a++,t++)}}t>0&&await Gt(e.runDir,e.framesDir,e.atlasPng,e.atlasWebp,e.contactSheet)}async function Nn(e){try{let t=await _e(await y.readFile(e)),r=Math.max(1,t.width),n=Math.max(1,t.height),o=le(r,n).getContext("2d");o.drawImage(t,0,0);let c=o.getImageData(0,0,r,n).data,a=0,s=0;for(let l=0;l<c.length;l+=4)(c[l+3]??0)>40&&(a++,s+=.299*(c[l]??0)+.587*(c[l+1]??0)+.114*(c[l+2]??0));return{count:a,lum:a?s/a:0}}catch(t){return console.error(`[petdex-forge] frame analysis failed for ${e}: ${t instanceof Error?t.message:String(t)}; treating frame as ok (repair skipped)`),{count:Number.MAX_SAFE_INTEGER,lum:255}}}function Ct(e){if(e.length===0)return 0;let t=[...e].sort((n,i)=>n-i),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function Fn(e){return[`Image 1 is ONE animation frame of a desktop pet's "${e}" pose. Image 2 is the canonical reference of the SAME pet.`,"Reply PASS only if image 1 shows ONE complete pet that clearly matches the reference \u2014 same species, colors, palette, BRIGHTNESS, proportions, markings; centered and fully visible.","Reply FAIL if it is a dark or black silhouette, off-colour, dimmer/brighter than the reference, cut off, empty, a fragment, or shows two pets.",'Reply with exactly "PASS" or "FAIL: <one short reason>".'].join(" ")}async function Hn(e,t,r,n){let i=[`Create ONE single image of a desktop pet in the "${t.id}" animation, pose ${r+1} of ${n}.`,"Output exactly ONE complete, centered, full-body pose of the SAME pet as the attached reference image \u2014 identical species, colors, palette, brightness, proportions, and markings.","This is a single sprite frame: NOT a strip, NOT a grid, NOT multiple poses, NOT a dark silhouette.",`Pose: ${Ln[t.id]??"a clear pose for this state"}.`].join(" "),o=null;for(let c=0;c<e.candidates;c++){let a=await e.generateImage({prompt:`${i}
|
|
18
|
-
|
|
19
|
-
${Nt}`,purpose:"petdex-reference",style:Cn,size:ye,imageUrl:e.baseDataUrl,referenceImages:[{role:"canonical-reference",imageUrl:e.baseDataUrl}],n:1,quality:"auto"});xe(e.usage,a);let s=a.mediaUrls[0];if(s){if(o=s,!e.inspectImage)return s;try{if((await je(()=>e.inspectImage({prompt:Fn(t.id),imageUrls:[s,e.baseDataUrl]}),{label:"frame QA",target:`${t.id} frame ${r+1}`})).ok)return s}catch(l){return console.error(`[petdex-forge] frame QA call failed for ${t.id} frame ${r+1}: ${l instanceof Error?l.message:String(l)}; accepting candidate unverified`),s}}}return o}async function Bn(e,t){let r=await _e(e),n=Math.max(1,r.width),i=Math.max(1,r.height),o=le(n,i),c=o.getContext("2d");c.drawImage(r,0,0);let a=c.getImageData(0,0,n,i),s=a.data,[l,u,d]=Jn(s,n,i);for(let P=0;P<s.length;P+=4){let A=(s[P]??0)-l,v=(s[P+1]??0)-u,D=(s[P+2]??0)-d;Math.sqrt(A*A+v*v+D*D)<=Un&&(s[P]=0,s[P+1]=0,s[P+2]=0,s[P+3]=0)}c.putImageData(a,0,0);let p=n,f=i,w=-1,g=-1;for(let P=0;P<i;P++)for(let A=0;A<n;A++)(s[(P*n+A)*4+3]??0)>16&&(A<p&&(p=A),A>w&&(w=A),P<f&&(f=P),P>g&&(g=P));let j=le(m.cellWidth,m.cellHeight),E=j.getContext("2d");if(w>=p&&g>=f){let P=w-p+1,A=g-f+1,v=m.cellWidth-10,D=m.cellHeight-10,L=Math.min(v/P,D/A,1),R=P*L,x=A*L;E.imageSmoothingEnabled=!0,E.imageSmoothingQuality="high",E.drawImage(o,p,f,P,A,(m.cellWidth-R)/2,(m.cellHeight-x)/2,R,x)}await y.mkdir(h.dirname(t),{recursive:!0}),await y.writeFile(t,Buffer.from(j.toBuffer("image/png")))}function Jn(e,t,r){let n=Math.max(4,Math.floor(Math.min(t,r)*.02)),i=Math.max(1,Math.floor(t/200)),o=new Map,c=(s,l)=>{let u=(l*t+s)*4,d=e[u]??0,p=e[u+1]??0,f=e[u+2]??0;if(d+p+f<24)return;let w=d>>4<<8|p>>4<<4|f>>4,g=o.get(w)??{n:0,r:0,g:0,b:0};g.n++,g.r+=d,g.g+=p,g.b+=f,o.set(w,g)};for(let s=n;s<t-n;s+=i)c(s,n),c(s,r-1-n);for(let s=n;s<r-n;s+=i)c(n,s),c(t-1-n,s);let a=null;for(let s of o.values())(!a||s.n>a.n)&&(a=s);return!a||a.n===0?[255,0,255]:[Math.round(a.r/a.n),Math.round(a.g/a.n),Math.round(a.b/a.n)]}function Gn(e,t){let r=e.rows.find(n=>n.state===t);return r?r.ok===!1:!1}async function Ut(e){return zt(e).catch(t=>(console.error(`[petdex-forge] QA review unreadable at ${e}: ${t instanceof Error?t.message:String(t)}; skipping row repair for this pass`),null))}async function zn(e,t,r){let n=[];for(let i of t.input_images){let o=h.join(e,i.path),c=await y.readFile(o).catch(()=>null);if(!c)continue;let a=await Xn(c,h.basename(o),r);n.push({role:Wn(i.role),imageUrl:a})}return n}function Wn(e){let t=e.toLowerCase();return t.includes("layout guide")?"layout-guide":t.includes("atlas")?"existing-atlas":"canonical-reference"}async function Xn(e,t,r){let n=t.toLowerCase().endsWith(".webp")?"image/webp":"image/png";return r?r({buffer:e,mimeType:n,filename:t}):`data:${n};base64,${e.toString("base64")}`}async function qn(e){let t=[];if(e.referenceImageUrl&&t.push(await G(e.referenceImageUrl)),e.baseSpritesheet&&t.push(e.baseSpritesheet),t.length===0)return[];let r=await y.mkdtemp(h.join(Mt.tmpdir(),"petdex-ref-")),n=[];for(let i=0;i<t.length;i++){let o=h.join(r,`reference-${String(i+1).padStart(2,"0")}.png`);await y.writeFile(o,t[i]),n.push(o)}return n}async function Kn(){let e=process.env.QLOGICAGENT_PETDEX_RUN_DIR?.trim()||Mt.tmpdir();return await y.mkdir(e,{recursive:!0}),y.mkdtemp(h.join(e,"petdex-run-"))}function Vn(){let e=process.env.QLOGICAGENT_PETDEX_KEEP_RUNS?.trim().toLowerCase();return e==="1"||e==="true"}async function Lt(e){e&&await y.rm(e,{recursive:!0,force:!0}).catch(()=>{})}async function zt(e){return JSON.parse(await y.readFile(e,"utf-8"))}async function Qn(e){try{let t=await _e(await y.readFile(e)),r=Math.max(1,t.width),n=Math.max(1,t.height),o=le(r,n).getContext("2d");o.drawImage(t,0,0);let c=o.getImageData(0,0,r,n).data,a=Math.max(8,Math.floor(Math.min(r,n)*.02)),s=Math.max(1,Math.floor(r/240)),l=new Map,u=(g,j)=>{let E=(j*r+g)*4,P=c[E+3]??0,A=c[E]??0,v=c[E+1]??0,D=c[E+2]??0;if(P<200||A+v+D<48)return;let L=A>>4<<8|v>>4<<4|D>>4,R=l.get(L)??{n:0,r:0,g:0,b:0};R.n++,R.r+=A,R.g+=v,R.b+=D,l.set(L,R)};for(let g=a;g<r-a;g+=s)u(g,a),u(g,n-1-a);for(let g=a;g<n-a;g+=s)u(a,g),u(r-1-a,g);let d=null;for(let g of l.values())(!d||g.n>d.n)&&(d=g);if(!d||d.n===0)return ke;let p=Math.round(d.r/d.n),f=Math.round(d.g/d.n),w=Math.round(d.b/d.n);return`#${[p,f,w].map(g=>g.toString(16).padStart(2,"0")).join("")}`.toUpperCase()}catch{return ke}}function Yn(e){return e.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"petdex"}async function H(e,t){let r=await De(e,t,{timeoutMs:18e4});if(!r.ok)throw new Error(`Petdex pipeline step ${e} failed (exit ${r.code??"?"}): ${r.stderr.trim()||r.stdout.trim()}`)}async function Ce(e,t){try{let r=await De(e,t,{timeoutMs:18e4});r.ok||console.error(`[petdex-forge] soft pipeline step ${e} failed (exit ${r.code??"?"}): ${(r.stderr.trim()||r.stdout.trim()).slice(0,300)}; continuing without it`)}catch(r){console.error(`[petdex-forge] soft pipeline step ${e} failed: ${r instanceof Error?r.message:String(r)}; continuing without it`)}}async function Wt(e){return Ee(e)}function Xt(e,t){if(!t)throw new Error("Petdex manifest validation requires spritesheet.webp bytes");return _(e,t)}export{z as PetGrowthEngine,T as PetProfileService,te as PetSoulService,yt as catchUpJourney,oe as createPetdexAssetFromSpritesheet,Te as forgePetdexAsset,Ft as forgePetdexAssetPackage,At as listBuiltinPetdexAssetIds,bt as listBuiltinPetdexAssets,Wt as loadPetFile,ft as petReactionEngine,Pe as petdexImageDataUrl,G as readGeneratedPetdexImage,V as toPetdexAssetSummary,Xt as validatePetManifest,ie as writePetdexAssetPackage};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AgentRpcRequest } from "../../protocol/wire/index.js";
|
|
2
|
-
import type { PetConfirmCoordinator } from "../pet-confirm-coordinator.js";
|
|
3
|
-
export interface PetConfirmHandlerHost {
|
|
4
|
-
petConfirmCoordinator: PetConfirmCoordinator;
|
|
5
|
-
sendResponse(id: string | number, result?: unknown, error?: unknown): void;
|
|
6
|
-
}
|
|
7
|
-
export declare function handlePetConfirmResponse(this: PetConfirmHandlerHost, msg: AgentRpcRequest): void;
|