ag-ai 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-ai",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "Provider-neutral AI client and cluster runtime for the rpi-mega cluster.",
5
5
  "license": "ISC",
6
6
  "author": "admin@gec.dev",
@@ -10,7 +10,7 @@ import { fileURLToPath } from 'node:url';
10
10
  import { createOpenCodeExecutor, DEFAULT_OPENCODE_URL } from './executor/opencode.mjs';
11
11
  import { createImageAdapter } from './image/adapter.mjs';
12
12
  import { normalizeGenerationRequest } from './protocol.mjs';
13
- import { createWorkSignal, startPushChannel } from './push.mjs';
13
+ import { createWorkSignal, parsePushFallbackMs, startPushChannel } from './push.mjs';
14
14
  import { createLocalRunner, startGenerationServer } from './server.mjs';
15
15
  import { GenerationStore } from './store.mjs';
16
16
  import { AnalyticaEvents } from './telemetry.mjs';
@@ -832,6 +832,8 @@ const readConfig = async (env = process.env) => {
832
832
  pushEnabled: env.AG_AI_PUSH === '1',
833
833
  pushTicketPath: env.AG_AI_PUSH_TICKET_PATH,
834
834
  pushHttpPath: env.AG_AI_PUSH_HTTP_PATH,
835
+ // How long a healthy push channel goes without a safety-net claim.
836
+ pushFallbackMs: parsePushFallbackMs(env.AG_AI_PUSH_FALLBACK_MS),
835
837
  analyticaToken,
836
838
  token,
837
839
  };
@@ -979,7 +981,10 @@ const main = async () => {
979
981
  process.once('SIGTERM', () => void stop('SIGTERM'));
980
982
  process.once('SIGINT', () => void stop('SIGINT'));
981
983
 
982
- const workSignal = createWorkSignal({ enabled: config.pushEnabled });
984
+ const workSignal = createWorkSignal({
985
+ enabled: config.pushEnabled,
986
+ fallbackMs: config.pushFallbackMs,
987
+ });
983
988
  const push = config.pushEnabled
984
989
  ? startPushChannel({
985
990
  baseUrl: new URL(config.queueUrl).origin,
package/runtime/push.mjs CHANGED
@@ -8,6 +8,17 @@ export const DEFAULT_PUSH_FALLBACK_MS = 60_000;
8
8
  export const DEFAULT_PUSH_TICKET_PATH = '/api/cluster/token';
9
9
  export const DEFAULT_PUSH_HTTP_PATH = '/api/cluster/reactive';
10
10
 
11
+ /**
12
+ * Reads AG_AI_PUSH_FALLBACK_MS. Unset, blank or invalid values keep the default,
13
+ * so a typo can never stop the fallback claim.
14
+ */
15
+ export const parsePushFallbackMs = (value) => {
16
+ const milliseconds = Number(value);
17
+ return value?.trim() && Number.isSafeInteger(milliseconds) && milliseconds >= 1_000
18
+ ? milliseconds
19
+ : DEFAULT_PUSH_FALLBACK_MS;
20
+ };
21
+
11
22
  /**
12
23
  * Decides when a cloud claim is worth a request. Disabled, it always claims, which
13
24
  * keeps the original polling behaviour.
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
- const ANALYTICA_EVENT_URL = 'https://analytica.click/api/site/event';
3
+ const ANALYTICA_EVENT_URL = 'https://api.analytica.click/site/event';
4
4
  const DEFAULT_ANALYTICA_EVENT_PREFIX = 'andreigec/ag-ai';
5
5
  const DEFAULT_ANALYTICA_PAGE_LOCATION = 'cluster://ag-ai';
6
6
  const ANALYTICA_REQUEST_TIMEOUT_MS = 5_000;