@photon-ai/flux 0.3.8 → 0.3.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 CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/@photon-ai/flux.svg)](https://www.npmjs.com/package/@photon-ai/flux)
10
10
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
11
+ [![GitHub release](https://img.shields.io/github/v/release/photon-hq/flux?include_prereleases)](https://github.com/photon-hq/flux/releases)
11
12
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
12
13
  [![Discord](https://img.shields.io/badge/Discord-Join-5865F2.svg?logo=discord&logoColor=white)](https://discord.gg/bZd4CMd2H5)
13
14
 
@@ -336,7 +337,7 @@ For **enterprise-level iMessage agents** with advanced features, consider our [A
336
337
  - **Dedicated phone line** — Get your own iMessage number
337
338
  - **Enterprise features** — Advanced conversation management and analytics
338
339
  - **Production-ready** — Enhanced stability and performance
339
- - **More functionalities** — Additional tools and integrations
340
+ - **More features** — Additional tools and integrations
340
341
 
341
342
  [**Explore Advanced iMessage Kit →**](https://github.com/photon-hq/advanced-imessage-kit)
342
343
 
package/dist/index.js CHANGED
@@ -52115,6 +52115,13 @@ var FluxService = class extends Service("FluxService") {
52115
52115
 
52116
52116
  // src/flux-client.ts
52117
52117
  var GRPC_SERVER_ADDRESS = process.env.FLUX_SERVER_ADDRESS || "fluxy.photon.codes:443";
52118
+ function splitIntoMessages(response) {
52119
+ if (!response.includes("\n")) {
52120
+ return [response];
52121
+ }
52122
+ const parts = response.split("\n").map((p) => p.trim()).filter((p) => p);
52123
+ return parts.length > 0 ? parts : [response];
52124
+ }
52118
52125
  var FluxClient = class {
52119
52126
  client = null;
52120
52127
  phoneNumber;
@@ -52157,7 +52164,10 @@ var FluxClient = class {
52157
52164
  await this.client.FluxService.messageStream({ ack: message.messageGuid });
52158
52165
  const response = await this.onMessage(message);
52159
52166
  if (response) {
52160
- await this.sendMessage(message.userPhoneNumber, response, message.chatGuid);
52167
+ const messages = splitIntoMessages(response);
52168
+ for (const msg of messages) {
52169
+ await this.sendMessage(message.userPhoneNumber, msg, message.chatGuid);
52170
+ }
52161
52171
  }
52162
52172
  }
52163
52173
  }
@@ -52390,6 +52400,13 @@ async function loadAgent(agentPath) {
52390
52400
  }
52391
52401
 
52392
52402
  // src/index.ts
52403
+ function splitIntoMessages2(response) {
52404
+ if (!response.includes("\n")) {
52405
+ return [response];
52406
+ }
52407
+ const parts = response.split("\n").map((p) => p.trim()).filter((p) => p);
52408
+ return parts.length > 0 ? parts : [response];
52409
+ }
52393
52410
  async function validateCommand() {
52394
52411
  const agentPath = findAgentFile();
52395
52412
  if (!agentPath) {
@@ -52441,8 +52458,11 @@ async function runLocal() {
52441
52458
  message: input,
52442
52459
  userPhoneNumber: "+1234567890"
52443
52460
  });
52444
- console.log(`Agent: ${response}
52445
- `);
52461
+ const messages = splitIntoMessages2(response);
52462
+ for (const msg of messages) {
52463
+ console.log(`Agent: ${msg}`);
52464
+ }
52465
+ console.log();
52446
52466
  } catch (error) {
52447
52467
  console.log(`[FLUX] Error: ${error.message}
52448
52468
  `);
@@ -52497,7 +52517,14 @@ async function runProd() {
52497
52517
  await flux.register();
52498
52518
  if (agent.onInit) {
52499
52519
  console.log("[FLUX] Initializing agent with proactive messaging support...");
52500
- await agent.onInit((to, text) => flux.sendMessage(to, text));
52520
+ await agent.onInit(async (to, text) => {
52521
+ const messages = splitIntoMessages2(text);
52522
+ for (const msg of messages) {
52523
+ const success = await flux.sendMessage(to, msg);
52524
+ if (!success) return false;
52525
+ }
52526
+ return true;
52527
+ });
52501
52528
  }
52502
52529
  console.log("[FLUX] Agent running in production mode. Press Ctrl+C to stop.");
52503
52530
  console.log(`[FLUX] Messages to ${phoneNumber} will be processed by your agent.