@trayai/helix-sdk 0.87.0 → 0.89.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/CHANGELOG.md CHANGED
@@ -9,6 +9,22 @@ general availability, minor versions may include breaking changes.
9
9
  The SDK and [`@trayai/helix-cli`](https://www.npmjs.com/package/@trayai/helix-cli) are
10
10
  released together and share a version — install matching versions.
11
11
 
12
+ ## 0.89.0
13
+
14
+ ### Removed
15
+
16
+ - **`ctx.trigger.isRetry` for scheduled functions** (SUR-677). The flag was reserved and
17
+ always `false`: no platform signal reliably distinguishes a retried *execution* from a
18
+ redelivered *message* (SQS's receive count measures deliveries, not runs, and can under-
19
+ as well as over-report), so rather than promise a boolean the platform cannot honestly
20
+ populate, the contract now states retry-once semantics and requires idempotent handlers.
21
+ The runtime still accepts (and ignores) `isRetry` on the shim invocation payload, so
22
+ bundles built with older shims keep working.
23
+
24
+ ## 0.87.0
25
+
26
+ No user-visible changes in this release — co-versioned with `@trayai/helix-cli`'s changes.
27
+
12
28
  ## 0.83.0
13
29
 
14
30
  ### Changed
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as h3 from 'h3';
2
2
  import { ZodType } from 'zod';
3
- import { F as FunctionHandler, D as DefineFunctionOptions, a as DefineScheduleConfig, S as ScheduleDefinition, T as TrayContext } from './types-D-yJbYWp.js';
4
- export { b as DbCallParameters, c as DbClient, d as FileSystemClient, H as HttpClient, K as KeyValueStore, L as Logger, e as ScheduleContext, f as ScheduleHandler, g as ScheduleTrigger, h as SqlBuilder, U as UnvalidatedInput } from './types-D-yJbYWp.js';
3
+ import { F as FunctionHandler, D as DefineFunctionOptions, a as DefineScheduleConfig, S as ScheduleDefinition, T as TrayContext } from './types-CoD3x7L-.js';
4
+ export { b as DbCallParameters, c as DbClient, d as FileSystemClient, H as HttpClient, K as KeyValueStore, L as Logger, e as ScheduleContext, f as ScheduleHandler, g as ScheduleTrigger, h as SqlBuilder, U as UnvalidatedInput } from './types-CoD3x7L-.js';
5
5
  import { T as TrayConfig, L as LoadedTrayConfig, W as WatchErrorPhase } from './sdk-config-_xIe9XvP.js';
6
6
  export { P as ProvisionedTrayConfig, S as SdkRuntimeConfig, U as UnprovisionedTrayConfig, a as WORKSPACE_ID_REQUIRED_CODE, b as WorkspaceIdRequiredError, g as getSdkConfig, l as loadConfig, c as loadedTrayConfigSchema, p as projectIdSchema, r as requireWorkspaceId, d as resolveConfigFile, w as workspaceIdSchema } from './sdk-config-_xIe9XvP.js';
7
7
  export { a as ENVIRONMENT_VALUES, E as Environment, e as environmentSchema } from './env-schema-DkgTG5b0.js';
@@ -24,7 +24,6 @@ interface ScheduleInvocation {
24
24
  schedulePath: string;
25
25
  scheduledAt: string;
26
26
  firedAt: string;
27
- isRetry: boolean;
28
27
  isManual: boolean;
29
28
  }
30
29
  /**
@@ -1 +1 @@
1
- import{B as v,a as H,b as f,c as J,d as L,e as T,f as U,g as m,h,i as p,j as g,k as y,l as S,m as E,n as x,p as A,q as b,r as w,s as I,t as C,u as te,v as re,w as oe,x as D}from"../chunk-3SDUCOAT.js";import{a as G,b as V,c as _,d as q,e as B,f as z,g as Q,h as W,i as X,j as Y,k as Z,m as ee}from"../chunk-H4L4UWIK.js";import{randomUUID as ne}from"crypto";import{SpanStatusCode as R,SpanKind as se}from"@opentelemetry/api";var t=class extends Error{constructor(e){super(`runScheduledFunction: ${e}`),this.name="ScheduleInvocationError"}};async function ie(s,e){if(typeof e!="object"||e===null)throw new t("`invocation` must be an object");let{schedulePath:r}=e;if(typeof r!="string"||r.length===0)throw new t("`schedulePath` must be a non-empty string");if(typeof e.isRetry!="boolean"||typeof e.isManual!="boolean")throw new t("`isRetry` and `isManual` must be booleans");if(!v(s))throw new t(`default export of "${r}" is not a defineSchedule definition`);let P=F("scheduledAt",e.scheduledAt),k=F("firedAt",e.firedAt),d=f(),a=d.executionId??ne(),l=d.deploymentId??null,N=Date.now(),O=new Date().toISOString(),M=b(),j=A();y();let i={hasDb:!1,hasExternal:!1,hasAuth:!1,hasError:!1},c=!1,u=null;try{await h.run(i,()=>m.run(a,()=>E.startActiveSpan("schedule",{root:!0,kind:se.SERVER,attributes:{method:"SCHEDULE",route:r,executionId:a,...l?{deploymentId:l}:{}}},async o=>{let $={type:"schedule",scheduledAt:P,firedAt:k,isRetry:e.isRetry,isManual:e.isManual},K={http:w(),db:n=>I(n),kv:()=>C(),files:()=>D(),log:j,config:M,state:{},executionId:a,deploymentId:l,traceId:o.spanContext().traceId,trigger:$};g(o,"input",{scheduledAt:e.scheduledAt,firedAt:e.firedAt,isRetry:e.isRetry,isManual:e.isManual});try{await s.handler(K)}catch(n){throw c=!0,u=n instanceof Error?n.message:String(n),p("hasError"),n}finally{o.setAttribute("hasAuth",i.hasAuth),o.setAttribute("hasExternal",i.hasExternal),o.setAttribute("hasDb",i.hasDb),o.setAttribute("status",c?"error":"success");let n=c||i.hasError;o.setStatus({code:n?R.ERROR:R.OK,...u?{message:u}:{}}),o.end()}})))}finally{x({executionId:a,deploymentId:l,triggerType:"schedule",routeOrJob:r,startedAt:O,startMs:N,errored:c,errorMessage:u,userId:null,flags:i}),await S()}}function F(s,e){if(typeof e!="string"||e.length===0)throw new t(`\`${s}\` must be a timestamp string; got ${JSON.stringify(e)}`);let r=new Date(e);if(Number.isNaN(r.getTime()))throw new t(`\`${s}\` must be a Date-parseable timestamp; got ${JSON.stringify(e)}`);return r}export{J as CONFIG_BRIDGE_CHANNEL,t as ScheduleInvocationError,te as assertValidPath,U as clearActiveConfig,re as contentFilePath,T as getActiveConfig,Y as getAdditionalEnvironmentProfiles,_ as getEnvironmentProfile,V as isKnownEnvironment,ee as isSdkError,B as listEnvironmentNames,z as listExposedEnvNames,oe as metaFilePath,Q as parseExposedEnvironment,G as registerEnvironmentProfile,q as requireEnvironmentProfile,Z as resetEnvironmentRegistryForTests,X as resolveForcedEnvironment,ie as runScheduledFunction,L as setActiveConfig,W as setForcedEnvironment,H as setSdkConfig};
1
+ import{B as D,a as H,b as f,c as J,d as L,e as T,f as U,g as m,h,i as g,j as p,k as S,l as E,m as y,n as x,p as A,q as b,r as w,s as I,t as v,u as te,v as re,w as oe,x as C}from"../chunk-3SDUCOAT.js";import{a as G,b as V,c as _,d as q,e as B,f as z,g as Q,h as W,i as X,j as Y,k as Z,m as ee}from"../chunk-H4L4UWIK.js";import{randomUUID as ne}from"crypto";import{SpanStatusCode as F,SpanKind as se}from"@opentelemetry/api";var t=class extends Error{constructor(e){super(`runScheduledFunction: ${e}`),this.name="ScheduleInvocationError"}};async function ie(s,e){if(typeof e!="object"||e===null)throw new t("`invocation` must be an object");let{schedulePath:r}=e;if(typeof r!="string"||r.length===0)throw new t("`schedulePath` must be a non-empty string");if(typeof e.isManual!="boolean")throw new t("`isManual` must be a boolean");if(!D(s))throw new t(`default export of "${r}" is not a defineSchedule definition`);let k=P("scheduledAt",e.scheduledAt),N=P("firedAt",e.firedAt),d=f(),a=d.executionId??ne(),l=d.deploymentId??null,O=Date.now(),M=new Date().toISOString(),j=b(),R=A();S();let i={hasDb:!1,hasExternal:!1,hasAuth:!1,hasError:!1},c=!1,u=null;try{await h.run(i,()=>m.run(a,()=>y.startActiveSpan("schedule",{root:!0,kind:se.SERVER,attributes:{method:"SCHEDULE",route:r,executionId:a,...l?{deploymentId:l}:{}}},async o=>{let $={type:"schedule",scheduledAt:k,firedAt:N,isManual:e.isManual},K={http:w(),db:n=>I(n),kv:()=>v(),files:()=>C(),log:R,config:j,state:{},executionId:a,deploymentId:l,traceId:o.spanContext().traceId,trigger:$};p(o,"input",{scheduledAt:e.scheduledAt,firedAt:e.firedAt,isManual:e.isManual});try{await s.handler(K)}catch(n){throw c=!0,u=n instanceof Error?n.message:String(n),g("hasError"),n}finally{o.setAttribute("hasAuth",i.hasAuth),o.setAttribute("hasExternal",i.hasExternal),o.setAttribute("hasDb",i.hasDb),o.setAttribute("status",c?"error":"success");let n=c||i.hasError;o.setStatus({code:n?F.ERROR:F.OK,...u?{message:u}:{}}),o.end()}})))}finally{x({executionId:a,deploymentId:l,triggerType:"schedule",routeOrJob:r,startedAt:M,startMs:O,errored:c,errorMessage:u,userId:null,flags:i}),await E()}}function P(s,e){if(typeof e!="string"||e.length===0)throw new t(`\`${s}\` must be a timestamp string; got ${JSON.stringify(e)}`);let r=new Date(e);if(Number.isNaN(r.getTime()))throw new t(`\`${s}\` must be a Date-parseable timestamp; got ${JSON.stringify(e)}`);return r}export{J as CONFIG_BRIDGE_CHANNEL,t as ScheduleInvocationError,te as assertValidPath,U as clearActiveConfig,re as contentFilePath,T as getActiveConfig,Y as getAdditionalEnvironmentProfiles,_ as getEnvironmentProfile,V as isKnownEnvironment,ee as isSdkError,B as listEnvironmentNames,z as listExposedEnvNames,oe as metaFilePath,Q as parseExposedEnvironment,G as registerEnvironmentProfile,q as requireEnvironmentProfile,Z as resetEnvironmentRegistryForTests,X as resolveForcedEnvironment,ie as runScheduledFunction,L as setActiveConfig,W as setForcedEnvironment,H as setSdkConfig};
@@ -1,4 +1,4 @@
1
- import { T as TrayContext } from '../types-D-yJbYWp.js';
1
+ import { T as TrayContext } from '../types-CoD3x7L-.js';
2
2
  import 'h3';
3
3
  import 'ky';
4
4
  import 'zod';
@@ -169,8 +169,6 @@ interface ScheduleTrigger {
169
169
  scheduledAt: Date;
170
170
  /** When it actually executed (may differ due to cold start, retry, etc.). */
171
171
  firedAt: Date;
172
- /** True if this is a retry of a failed execution. */
173
- isRetry: boolean;
174
172
  /** True if triggered via `helix trigger` or the MCP tool. */
175
173
  isManual: boolean;
176
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayai/helix-sdk",
3
- "version": "0.87.0",
3
+ "version": "0.89.0",
4
4
  "description": "Helix SDK runtime — defineFunction, ctx, defineConfig, authed HTTP",
5
5
  "license": "Apache-2.0",
6
6
  "author": "trayio",