agent-relay 4.0.31 → 4.0.33

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.
Files changed (140) hide show
  1. package/bin/agent-relay-broker-darwin-arm64 +0 -0
  2. package/bin/agent-relay-broker-darwin-x64 +0 -0
  3. package/bin/agent-relay-broker-linux-arm64 +0 -0
  4. package/bin/agent-relay-broker-linux-x64 +0 -0
  5. package/dist/index.cjs +210 -75
  6. package/dist/src/cli/commands/on/start.d.ts.map +1 -1
  7. package/dist/src/cli/commands/on/start.js +149 -111
  8. package/dist/src/cli/commands/on/start.js.map +1 -1
  9. package/node_modules/@agent-relay/cloud/package.json +2 -2
  10. package/node_modules/@agent-relay/config/package.json +1 -1
  11. package/node_modules/@agent-relay/hooks/package.json +4 -4
  12. package/node_modules/@agent-relay/sdk/README.md +3 -0
  13. package/node_modules/@agent-relay/sdk/dist/relay.d.ts +16 -0
  14. package/node_modules/@agent-relay/sdk/dist/relay.d.ts.map +1 -1
  15. package/node_modules/@agent-relay/sdk/dist/relay.js +83 -0
  16. package/node_modules/@agent-relay/sdk/dist/relay.js.map +1 -1
  17. package/node_modules/@agent-relay/sdk/package.json +2 -2
  18. package/node_modules/@agent-relay/telemetry/package.json +1 -1
  19. package/node_modules/@agent-relay/trajectory/package.json +2 -2
  20. package/node_modules/@agent-relay/user-directory/package.json +2 -2
  21. package/node_modules/@agent-relay/utils/package.json +2 -2
  22. package/node_modules/@relayfile/local-mount/README.md +215 -0
  23. package/node_modules/@relayfile/local-mount/dist/auto-sync.d.ts +31 -0
  24. package/node_modules/@relayfile/local-mount/dist/auto-sync.js +466 -0
  25. package/node_modules/@relayfile/local-mount/dist/dotfiles.d.ts +18 -0
  26. package/node_modules/@relayfile/local-mount/dist/dotfiles.js +43 -0
  27. package/node_modules/@relayfile/local-mount/dist/index.d.ts +4 -0
  28. package/node_modules/@relayfile/local-mount/dist/index.js +3 -0
  29. package/node_modules/@relayfile/local-mount/dist/launch.d.ts +50 -0
  30. package/node_modules/@relayfile/local-mount/dist/launch.js +129 -0
  31. package/node_modules/@relayfile/local-mount/dist/symlink-mount.d.ts +23 -0
  32. package/{dist/src/cli/commands/on → node_modules/@relayfile/local-mount/dist}/symlink-mount.js +88 -20
  33. package/node_modules/@relayfile/local-mount/node_modules/chokidar/LICENSE +21 -0
  34. package/node_modules/@relayfile/local-mount/node_modules/chokidar/README.md +305 -0
  35. package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/handler.d.ts +90 -0
  36. package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/handler.js +629 -0
  37. package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/index.d.ts +215 -0
  38. package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/index.js +798 -0
  39. package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/package.json +1 -0
  40. package/node_modules/@relayfile/local-mount/node_modules/chokidar/handler.d.ts +90 -0
  41. package/node_modules/@relayfile/local-mount/node_modules/chokidar/handler.js +635 -0
  42. package/node_modules/@relayfile/local-mount/node_modules/chokidar/index.d.ts +215 -0
  43. package/node_modules/@relayfile/local-mount/node_modules/chokidar/index.js +804 -0
  44. package/node_modules/@relayfile/local-mount/node_modules/chokidar/package.json +69 -0
  45. package/node_modules/@relayfile/local-mount/node_modules/readdirp/LICENSE +21 -0
  46. package/node_modules/@relayfile/local-mount/node_modules/readdirp/README.md +120 -0
  47. package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/index.d.ts +108 -0
  48. package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/index.js +257 -0
  49. package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/package.json +1 -0
  50. package/node_modules/@relayfile/local-mount/node_modules/readdirp/index.d.ts +108 -0
  51. package/node_modules/@relayfile/local-mount/node_modules/readdirp/index.js +263 -0
  52. package/node_modules/@relayfile/local-mount/node_modules/readdirp/package.json +70 -0
  53. package/node_modules/@relayfile/local-mount/package.json +47 -0
  54. package/node_modules/@smithy/config-resolver/package.json +2 -2
  55. package/node_modules/@smithy/core/dist-cjs/index.js +2 -1
  56. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +32 -14
  57. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +2 -2
  58. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +16 -8
  59. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +17 -10
  60. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +6 -1
  61. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +6 -3
  62. package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
  63. package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +23 -11
  64. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +9 -3
  65. package/node_modules/@smithy/core/dist-es/submodules/endpoints/toEndpointV1.js +2 -2
  66. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +16 -8
  67. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +9 -4
  68. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +8 -6
  69. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +6 -1
  70. package/node_modules/@smithy/core/dist-es/submodules/serde/parse-utils.js +6 -3
  71. package/node_modules/@smithy/core/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
  72. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -1
  73. package/node_modules/@smithy/core/package.json +2 -2
  74. package/node_modules/@smithy/middleware-endpoint/package.json +3 -3
  75. package/node_modules/@smithy/middleware-retry/package.json +5 -5
  76. package/node_modules/@smithy/middleware-serde/package.json +2 -2
  77. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +188 -93
  78. package/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +45 -0
  79. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +71 -35
  80. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +32 -18
  81. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +41 -40
  82. package/node_modules/@smithy/node-http-handler/dist-types/http2/ClientHttp2SessionRef.d.ts +42 -0
  83. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-manager.d.ts +34 -14
  84. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-pool.d.ts +32 -8
  85. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +0 -5
  86. package/node_modules/@smithy/node-http-handler/package.json +1 -1
  87. package/node_modules/@smithy/service-error-classification/dist-cjs/index.js +5 -0
  88. package/node_modules/@smithy/service-error-classification/dist-es/index.js +4 -0
  89. package/node_modules/@smithy/service-error-classification/dist-types/index.d.ts +6 -0
  90. package/node_modules/@smithy/service-error-classification/package.json +1 -1
  91. package/node_modules/@smithy/smithy-client/package.json +4 -4
  92. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  93. package/node_modules/@smithy/util-defaults-mode-node/package.json +3 -3
  94. package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +65 -53
  95. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateCondition.js +9 -7
  96. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateConditions.js +12 -8
  97. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateEndpointRule.js +14 -13
  98. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateErrorRule.js +7 -4
  99. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +10 -8
  100. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateRules.js +4 -4
  101. package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointHeaders.js +5 -5
  102. package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointProperties.js +4 -4
  103. package/node_modules/@smithy/util-endpoints/dist-types/types/shared.d.ts +3 -3
  104. package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +2 -15
  105. package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateCondition.d.ts +6 -3
  106. package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateConditions.d.ts +3 -3
  107. package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointHeaders.d.ts +1 -1
  108. package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointProperties.d.ts +2 -2
  109. package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +2 -2
  110. package/node_modules/@smithy/util-endpoints/package.json +1 -1
  111. package/node_modules/@smithy/util-retry/package.json +2 -2
  112. package/node_modules/@smithy/util-stream/package.json +2 -2
  113. package/node_modules/agent-trajectories/dist/{chunk-2XT3DOJC.js → chunk-27AQPWHK.js} +136 -72
  114. package/node_modules/agent-trajectories/dist/chunk-27AQPWHK.js.map +1 -0
  115. package/node_modules/agent-trajectories/dist/cli/index.js +135 -71
  116. package/node_modules/agent-trajectories/dist/cli/index.js.map +1 -1
  117. package/node_modules/agent-trajectories/dist/{index-thTh5iI8.d.ts → index-C7XhwsoN.d.ts} +24 -0
  118. package/node_modules/agent-trajectories/dist/index.d.ts +2 -2
  119. package/node_modules/agent-trajectories/dist/index.js +1 -1
  120. package/node_modules/agent-trajectories/dist/sdk/index.d.ts +1 -1
  121. package/node_modules/agent-trajectories/dist/sdk/index.js +1 -1
  122. package/node_modules/agent-trajectories/package.json +1 -1
  123. package/package.json +25 -11
  124. package/packages/cloud/package.json +2 -2
  125. package/packages/config/package.json +1 -1
  126. package/packages/hooks/package.json +4 -4
  127. package/packages/sdk/README.md +3 -0
  128. package/packages/sdk/dist/relay.d.ts +16 -0
  129. package/packages/sdk/dist/relay.d.ts.map +1 -1
  130. package/packages/sdk/dist/relay.js +83 -0
  131. package/packages/sdk/dist/relay.js.map +1 -1
  132. package/packages/sdk/package.json +2 -2
  133. package/packages/telemetry/package.json +1 -1
  134. package/packages/trajectory/package.json +2 -2
  135. package/packages/user-directory/package.json +2 -2
  136. package/packages/utils/package.json +2 -2
  137. package/dist/src/cli/commands/on/symlink-mount.d.ts +0 -12
  138. package/dist/src/cli/commands/on/symlink-mount.d.ts.map +0 -1
  139. package/dist/src/cli/commands/on/symlink-mount.js.map +0 -1
  140. package/node_modules/agent-trajectories/dist/chunk-2XT3DOJC.js.map +0 -1
@@ -2,21 +2,25 @@ import { debugId, toDebugString } from "../debug";
2
2
  import { evaluateCondition } from "./evaluateCondition";
3
3
  export const evaluateConditions = (conditions = [], options) => {
4
4
  const conditionsReferenceRecord = {};
5
+ const conditionOptions = {
6
+ ...options,
7
+ referenceRecord: { ...options.referenceRecord },
8
+ };
9
+ let didAssign = false;
5
10
  for (const condition of conditions) {
6
- const { result, toAssign } = evaluateCondition(condition, {
7
- ...options,
8
- referenceRecord: {
9
- ...options.referenceRecord,
10
- ...conditionsReferenceRecord,
11
- },
12
- });
11
+ const { result, toAssign } = evaluateCondition(condition, conditionOptions);
13
12
  if (!result) {
14
13
  return { result };
15
14
  }
16
15
  if (toAssign) {
16
+ didAssign = true;
17
17
  conditionsReferenceRecord[toAssign.name] = toAssign.value;
18
+ conditionOptions.referenceRecord[toAssign.name] = toAssign.value;
18
19
  options.logger?.debug?.(`${debugId} assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
19
20
  }
20
21
  }
21
- return { result: true, referenceRecord: conditionsReferenceRecord };
22
+ if (didAssign) {
23
+ return { result: true, referenceRecord: conditionsReferenceRecord };
24
+ }
25
+ return { result: true };
22
26
  };
@@ -9,19 +9,20 @@ export const evaluateEndpointRule = (endpointRule, options) => {
9
9
  if (!result) {
10
10
  return;
11
11
  }
12
- const endpointRuleOptions = {
13
- ...options,
14
- referenceRecord: { ...options.referenceRecord, ...referenceRecord },
15
- };
12
+ const endpointRuleOptions = referenceRecord
13
+ ? {
14
+ ...options,
15
+ referenceRecord: { ...options.referenceRecord, ...referenceRecord },
16
+ }
17
+ : options;
16
18
  const { url, properties, headers } = endpoint;
17
19
  options.logger?.debug?.(`${debugId} Resolving endpoint from template: ${toDebugString(endpoint)}`);
18
- return {
19
- ...(headers != undefined && {
20
- headers: getEndpointHeaders(headers, endpointRuleOptions),
21
- }),
22
- ...(properties != undefined && {
23
- properties: getEndpointProperties(properties, endpointRuleOptions),
24
- }),
25
- url: getEndpointUrl(url, endpointRuleOptions),
26
- };
20
+ const endpointToReturn = { url: getEndpointUrl(url, endpointRuleOptions) };
21
+ if (headers != null) {
22
+ endpointToReturn.headers = getEndpointHeaders(headers, endpointRuleOptions);
23
+ }
24
+ if (properties != null) {
25
+ endpointToReturn.properties = getEndpointProperties(properties, endpointRuleOptions);
26
+ }
27
+ return endpointToReturn;
27
28
  };
@@ -7,8 +7,11 @@ export const evaluateErrorRule = (errorRule, options) => {
7
7
  if (!result) {
8
8
  return;
9
9
  }
10
- throw new EndpointError(evaluateExpression(error, "Error", {
11
- ...options,
12
- referenceRecord: { ...options.referenceRecord, ...referenceRecord },
13
- }));
10
+ const errorRuleOptions = referenceRecord
11
+ ? {
12
+ ...options,
13
+ referenceRecord: { ...options.referenceRecord, ...referenceRecord },
14
+ }
15
+ : options;
16
+ throw new EndpointError(evaluateExpression(error, "Error", errorRuleOptions));
14
17
  };
@@ -26,17 +26,19 @@ export const callFunction = ({ fn, argv }, options) => {
26
26
  evaluatedArgs[i] = group.evaluateExpression(arg, "arg", options);
27
27
  }
28
28
  }
29
- if (fn.includes(".")) {
30
- const fnSegments = fn.split(".");
31
- if (fnSegments[0] in customEndpointFunctions && fnSegments[1] != null) {
32
- return customEndpointFunctions[fnSegments[0]][fnSegments[1]](...evaluatedArgs);
29
+ const namespaceSeparatorIndex = fn.indexOf(".");
30
+ if (namespaceSeparatorIndex !== -1) {
31
+ const namespaceFunctions = customEndpointFunctions[fn.slice(0, namespaceSeparatorIndex)];
32
+ const customFunction = namespaceFunctions?.[fn.slice(namespaceSeparatorIndex + 1)];
33
+ if (typeof customFunction === "function") {
34
+ return customFunction(...evaluatedArgs);
33
35
  }
34
36
  }
35
- if (typeof endpointFunctions[fn] !== "function") {
36
- throw new Error(`function ${fn} not loaded in endpointFunctions.`);
37
- }
38
37
  const callable = endpointFunctions[fn];
39
- return callable(...evaluatedArgs);
38
+ if (typeof callable === "function") {
39
+ return callable(...evaluatedArgs);
40
+ }
41
+ throw new Error(`function ${fn} not loaded in endpointFunctions.`);
40
42
  };
41
43
  export const group = {
42
44
  evaluateExpression,
@@ -31,10 +31,10 @@ export const evaluateTreeRule = (treeRule, options) => {
31
31
  if (!result) {
32
32
  return;
33
33
  }
34
- return group.evaluateRules(rules, {
35
- ...options,
36
- referenceRecord: { ...options.referenceRecord, ...referenceRecord },
37
- });
34
+ const treeRuleOptions = referenceRecord
35
+ ? { ...options, referenceRecord: { ...options.referenceRecord, ...referenceRecord } }
36
+ : options;
37
+ return group.evaluateRules(rules, treeRuleOptions);
38
38
  };
39
39
  export const group = {
40
40
  evaluateRules,
@@ -1,12 +1,12 @@
1
1
  import { EndpointError } from "../types";
2
2
  import { evaluateExpression } from "./evaluateExpression";
3
- export const getEndpointHeaders = (headers, options) => Object.entries(headers ?? {}).reduce((acc, [headerKey, headerVal]) => ({
4
- ...acc,
5
- [headerKey]: headerVal.map((headerValEntry) => {
3
+ export const getEndpointHeaders = (headers, options) => Object.entries(headers ?? {}).reduce((acc, [headerKey, headerVal]) => {
4
+ acc[headerKey] = headerVal.map((headerValEntry) => {
6
5
  const processedExpr = evaluateExpression(headerValEntry, "Header value entry", options);
7
6
  if (typeof processedExpr !== "string") {
8
7
  throw new EndpointError(`Header '${headerKey}' value '${processedExpr}' is not a string`);
9
8
  }
10
9
  return processedExpr;
11
- }),
12
- }), {});
10
+ });
11
+ return acc;
12
+ }, {});
@@ -1,9 +1,9 @@
1
1
  import { EndpointError } from "../types";
2
2
  import { evaluateTemplate } from "./evaluateTemplate";
3
- export const getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => ({
4
- ...acc,
5
- [propertyKey]: group.getEndpointProperty(propertyVal, options),
6
- }), {});
3
+ export const getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => {
4
+ acc[propertyKey] = group.getEndpointProperty(propertyVal, options);
5
+ return acc;
6
+ }, {});
7
7
  export const getEndpointProperty = (property, options) => {
8
8
  if (Array.isArray(property)) {
9
9
  return property.map((propertyEntry) => getEndpointProperty(propertyEntry, options));
@@ -1,4 +1,4 @@
1
- import type { EndpointARN, EndpointPartition, Logger } from "@smithy/types";
1
+ import type { EndpointARN, EndpointPartition, EndpointURL, Logger } from "@smithy/types";
2
2
  export type ReferenceObject = {
3
3
  ref: string;
4
4
  };
@@ -7,9 +7,9 @@ export type FunctionObject = {
7
7
  argv: FunctionArgv;
8
8
  };
9
9
  export type FunctionArgv = Array<Expression | boolean | number>;
10
- export type FunctionReturn = string | boolean | number | EndpointARN | EndpointPartition | {
10
+ export type FunctionReturn = string | boolean | number | EndpointARN | EndpointPartition | EndpointURL | {
11
11
  [key: string]: FunctionReturn;
12
- } | null;
12
+ } | Array<FunctionReturn> | null;
13
13
  export type ConditionObject = FunctionObject & {
14
14
  assign?: string;
15
15
  };
@@ -1,15 +1,2 @@
1
- import { coalesce, ite, split } from "../lib";
2
- export declare const endpointFunctions: {
3
- booleanEquals: (value1: boolean, value2: boolean) => boolean;
4
- coalesce: typeof coalesce;
5
- getAttr: (value: import("../lib").GetAttrValue, path: string) => import("../lib").GetAttrValue;
6
- isSet: (value: unknown) => value is {};
7
- isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean;
8
- ite: typeof ite;
9
- not: (value: boolean) => boolean;
10
- parseURL: (value: string | URL | import("@smithy/types").Endpoint) => import("@smithy/types").EndpointURL | null;
11
- split: typeof split;
12
- stringEquals: (value1: string, value2: string) => boolean;
13
- substring: (input: string, start: number, stop: number, reverse: boolean) => string | null;
14
- uriEncode: (value: string) => string;
15
- };
1
+ import type { EndpointFunctions } from "../types";
2
+ export declare const endpointFunctions: EndpointFunctions;
@@ -1,8 +1,11 @@
1
1
  import type { ConditionObject, EvaluateOptions } from "../types";
2
- export declare const evaluateCondition: ({ assign, ...fnArgs }: ConditionObject, options: EvaluateOptions) => {
3
- toAssign?: {
2
+ export declare const evaluateCondition: (condition: ConditionObject, options: EvaluateOptions) => {
3
+ result: boolean;
4
+ toAssign: {
4
5
  name: string;
5
6
  value: import("../types").FunctionReturn;
6
- } | undefined;
7
+ };
8
+ } | {
7
9
  result: boolean;
10
+ toAssign?: undefined;
8
11
  };
@@ -1,8 +1,8 @@
1
1
  import type { ConditionObject, EvaluateOptions, FunctionReturn } from "../types";
2
2
  export declare const evaluateConditions: (conditions: ConditionObject[] | undefined, options: EvaluateOptions) => {
3
- result: false;
4
- referenceRecord?: undefined;
5
- } | {
6
3
  result: boolean;
7
4
  referenceRecord: Record<string, FunctionReturn>;
5
+ } | {
6
+ result: boolean;
7
+ referenceRecord?: undefined;
8
8
  };
@@ -1,2 +1,2 @@
1
1
  import type { EndpointObjectHeaders, EvaluateOptions } from "../types";
2
- export declare const getEndpointHeaders: (headers: EndpointObjectHeaders, options: EvaluateOptions) => {};
2
+ export declare const getEndpointHeaders: (headers: EndpointObjectHeaders, options: EvaluateOptions) => Record<string, string[]>;
@@ -1,8 +1,8 @@
1
1
  import type { EndpointObjectProperty } from "@smithy/types";
2
2
  import type { EndpointObjectProperties, EvaluateOptions } from "../types";
3
- export declare const getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => {};
3
+ export declare const getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => Record<string, EndpointObjectProperty>;
4
4
  export declare const getEndpointProperty: (property: EndpointObjectProperty, options: EvaluateOptions) => EndpointObjectProperty;
5
5
  export declare const group: {
6
6
  getEndpointProperty: (property: EndpointObjectProperty, options: EvaluateOptions) => EndpointObjectProperty;
7
- getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => {};
7
+ getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => Record<string, EndpointObjectProperty>;
8
8
  };
@@ -1,4 +1,4 @@
1
1
  import type { EvaluateOptions, ReferenceObject } from "../types";
2
- export declare const getReferenceValue: ({ ref }: ReferenceObject, options: EvaluateOptions) => string | number | boolean | import("@smithy/types").EndpointPartition | import("@smithy/types").EndpointARN | {
2
+ export declare const getReferenceValue: ({ ref }: ReferenceObject, options: EvaluateOptions) => string | number | boolean | import("@smithy/types").EndpointPartition | import("@smithy/types").EndpointARN | import("@smithy/types").EndpointURL | {
3
3
  [key: string]: import("../types").FunctionReturn;
4
- };
4
+ } | import("../types").FunctionReturn[];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-endpoints",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Utilities to help with endpoint resolution.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-retry",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "description": "Shared retry utilities to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -30,7 +30,7 @@
30
30
  "license": "Apache-2.0",
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
- "@smithy/service-error-classification": "^4.2.14",
33
+ "@smithy/service-error-classification": "^4.3.0",
34
34
  "@smithy/types": "^4.14.1",
35
35
  "tslib": "^2.6.2"
36
36
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-stream",
3
- "version": "4.5.23",
3
+ "version": "4.5.24",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
6
  "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline util-stream",
@@ -29,7 +29,7 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@smithy/fetch-http-handler": "^5.3.17",
32
- "@smithy/node-http-handler": "^4.5.3",
32
+ "@smithy/node-http-handler": "^4.6.0",
33
33
  "@smithy/types": "^4.14.1",
34
34
  "@smithy/util-base64": "^4.3.2",
35
35
  "@smithy/util-buffer-from": "^4.2.2",
@@ -666,8 +666,16 @@ function formatTime(isoString) {
666
666
  }
667
667
 
668
668
  // src/storage/file.ts
669
+ import { randomUUID } from "crypto";
669
670
  import { existsSync } from "fs";
670
- import { mkdir, readFile, readdir, unlink, writeFile } from "fs/promises";
671
+ import {
672
+ mkdir,
673
+ readFile,
674
+ readdir,
675
+ rename,
676
+ unlink,
677
+ writeFile
678
+ } from "fs/promises";
671
679
  import { join } from "path";
672
680
  function expandPath(path) {
673
681
  if (path.startsWith("~")) {
@@ -675,6 +683,16 @@ function expandPath(path) {
675
683
  }
676
684
  return path;
677
685
  }
686
+ var indexLocks = /* @__PURE__ */ new Map();
687
+ function withIndexLock(path, task) {
688
+ const prev = indexLocks.get(path) ?? Promise.resolve();
689
+ const next = prev.then(task, task);
690
+ indexLocks.set(
691
+ path,
692
+ next.catch(() => void 0)
693
+ );
694
+ return next;
695
+ }
678
696
  var FileStorage = class {
679
697
  baseDir;
680
698
  trajectoriesDir;
@@ -701,10 +719,10 @@ var FileStorage = class {
701
719
  await mkdir(this.activeDir, { recursive: true });
702
720
  await mkdir(this.completedDir, { recursive: true });
703
721
  if (!existsSync(this.indexPath)) {
704
- await this.saveIndex({
705
- version: 1,
706
- lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
707
- trajectories: {}
722
+ await withIndexLock(this.indexPath, async () => {
723
+ if (!existsSync(this.indexPath)) {
724
+ await this.saveIndex(this.emptyIndex());
725
+ }
708
726
  });
709
727
  }
710
728
  await this.reconcileIndex();
@@ -732,49 +750,51 @@ var FileStorage = class {
732
750
  skippedSchemaViolation: 0,
733
751
  skippedIoError: 0
734
752
  };
735
- const index = await this.loadIndex();
736
- const before = Object.keys(index.trajectories).length;
737
- const discovered = [];
738
- try {
739
- const activeFiles = await readdir(this.activeDir);
740
- for (const file of activeFiles) {
741
- if (!file.endsWith(".json")) continue;
742
- discovered.push(join(this.activeDir, file));
753
+ await withIndexLock(this.indexPath, async () => {
754
+ const index = await this.loadIndex();
755
+ const before = Object.keys(index.trajectories).length;
756
+ const discovered = [];
757
+ try {
758
+ const activeFiles = await readdir(this.activeDir);
759
+ for (const file of activeFiles) {
760
+ if (!file.endsWith(".json")) continue;
761
+ discovered.push(join(this.activeDir, file));
762
+ }
763
+ } catch (error) {
764
+ if (error.code !== "ENOENT") throw error;
743
765
  }
744
- } catch (error) {
745
- if (error.code !== "ENOENT") throw error;
746
- }
747
- await this.walkJsonFilesInto(this.completedDir, discovered);
748
- for (const filePath of discovered) {
749
- summary.scanned += 1;
750
- const result = await this.readTrajectoryFile(filePath);
751
- if (!result.ok) {
752
- if (result.reason === "malformed_json") {
753
- summary.skippedMalformedJson += 1;
754
- } else if (result.reason === "schema_violation") {
755
- summary.skippedSchemaViolation += 1;
756
- } else {
757
- summary.skippedIoError += 1;
766
+ await this.walkJsonFilesInto(this.completedDir, discovered);
767
+ for (const filePath of discovered) {
768
+ summary.scanned += 1;
769
+ const result = await this.readTrajectoryFile(filePath);
770
+ if (!result.ok) {
771
+ if (result.reason === "malformed_json") {
772
+ summary.skippedMalformedJson += 1;
773
+ } else if (result.reason === "schema_violation") {
774
+ summary.skippedSchemaViolation += 1;
775
+ } else {
776
+ summary.skippedIoError += 1;
777
+ }
778
+ continue;
758
779
  }
759
- continue;
780
+ const trajectory2 = result.trajectory;
781
+ if (index.trajectories[trajectory2.id]) {
782
+ summary.alreadyIndexed += 1;
783
+ continue;
784
+ }
785
+ index.trajectories[trajectory2.id] = {
786
+ title: trajectory2.task.title,
787
+ status: trajectory2.status,
788
+ startedAt: trajectory2.startedAt,
789
+ completedAt: trajectory2.completedAt,
790
+ path: filePath
791
+ };
792
+ summary.added += 1;
760
793
  }
761
- const trajectory2 = result.trajectory;
762
- if (index.trajectories[trajectory2.id]) {
763
- summary.alreadyIndexed += 1;
764
- continue;
794
+ if (Object.keys(index.trajectories).length !== before) {
795
+ await this.saveIndex(index);
765
796
  }
766
- index.trajectories[trajectory2.id] = {
767
- title: trajectory2.task.title,
768
- status: trajectory2.status,
769
- startedAt: trajectory2.startedAt,
770
- completedAt: trajectory2.completedAt,
771
- path: filePath
772
- };
773
- summary.added += 1;
774
- }
775
- if (Object.keys(index.trajectories).length !== before) {
776
- await this.saveIndex(index);
777
- }
797
+ });
778
798
  const hadSkips = summary.skippedMalformedJson + summary.skippedSchemaViolation + summary.skippedIoError > 0;
779
799
  if (summary.added > 0 || hadSkips) {
780
800
  const parts = [`reconciled ${summary.added}/${summary.scanned}`];
@@ -977,17 +997,19 @@ var FileStorage = class {
977
997
  if (existsSync(activePath)) {
978
998
  await unlink(activePath);
979
999
  }
980
- const index = await this.loadIndex();
981
- const entry = index.trajectories[id];
982
- if (entry?.path && existsSync(entry.path)) {
983
- await unlink(entry.path);
984
- const mdPath = entry.path.replace(".json", ".md");
985
- if (existsSync(mdPath)) {
986
- await unlink(mdPath);
1000
+ await withIndexLock(this.indexPath, async () => {
1001
+ const index = await this.loadIndex();
1002
+ const entry = index.trajectories[id];
1003
+ if (entry?.path && existsSync(entry.path)) {
1004
+ await unlink(entry.path);
1005
+ const mdPath = entry.path.replace(".json", ".md");
1006
+ if (existsSync(mdPath)) {
1007
+ await unlink(mdPath);
1008
+ }
987
1009
  }
988
- }
989
- delete index.trajectories[id];
990
- await this.saveIndex(index);
1010
+ delete index.trajectories[id];
1011
+ await this.saveIndex(index);
1012
+ });
991
1013
  }
992
1014
  /**
993
1015
  * Search trajectories by text
@@ -1065,10 +1087,23 @@ var FileStorage = class {
1065
1087
  const result = await this.readTrajectoryFile(path);
1066
1088
  return result.ok ? result.trajectory : null;
1067
1089
  }
1090
+ /**
1091
+ * Read and parse the on-disk index.
1092
+ *
1093
+ * Tolerances (belt-and-braces against the read/write race):
1094
+ * - ENOENT: first-run, return an empty index silently.
1095
+ * - Empty file: a concurrent writer truncated index.json in "w" mode
1096
+ * right before we read. Return an empty index silently — this is
1097
+ * not a real corruption, just an interleaving the mutex + atomic
1098
+ * rename should already prevent. Logging here would be noise.
1099
+ * - Non-empty but malformed JSON: genuinely corrupted on disk (hand
1100
+ * edit, disk error, etc). Log it and return an empty index so the
1101
+ * caller can recover, but keep the log so the problem is visible.
1102
+ */
1068
1103
  async loadIndex() {
1104
+ let content;
1069
1105
  try {
1070
- const content = await readFile(this.indexPath, "utf-8");
1071
- return JSON.parse(content);
1106
+ content = await readFile(this.indexPath, "utf-8");
1072
1107
  } catch (error) {
1073
1108
  if (error.code !== "ENOENT") {
1074
1109
  console.error(
@@ -1076,27 +1111,56 @@ var FileStorage = class {
1076
1111
  error
1077
1112
  );
1078
1113
  }
1079
- return {
1080
- version: 1,
1081
- lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
1082
- trajectories: {}
1083
- };
1114
+ return this.emptyIndex();
1115
+ }
1116
+ if (content.length === 0) {
1117
+ return this.emptyIndex();
1118
+ }
1119
+ try {
1120
+ return JSON.parse(content);
1121
+ } catch (error) {
1122
+ console.error(
1123
+ "Error loading trajectory index, using empty index:",
1124
+ error
1125
+ );
1126
+ return this.emptyIndex();
1084
1127
  }
1085
1128
  }
1129
+ emptyIndex() {
1130
+ return {
1131
+ version: 1,
1132
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
1133
+ trajectories: {}
1134
+ };
1135
+ }
1136
+ /**
1137
+ * Atomic write: stage into a process-unique temp path in the same directory
1138
+ * and then rename over the live file. `rename` is atomic on POSIX, so
1139
+ * concurrent readers in any process either see the old complete file or
1140
+ * the new complete file — never a half-written / zero-byte state.
1141
+ *
1142
+ * Callers MUST hold `withIndexLock(this.indexPath, ...)` so the in-process
1143
+ * read-modify-write cycle stays serialized; the unique temp name also keeps
1144
+ * parallel writers in other processes from colliding on a shared tmp path.
1145
+ */
1086
1146
  async saveIndex(index) {
1087
1147
  index.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
1088
- await writeFile(this.indexPath, JSON.stringify(index, null, 2), "utf-8");
1148
+ const tmpPath = `${this.indexPath}.${process.pid}.${randomUUID()}.tmp`;
1149
+ await writeFile(tmpPath, JSON.stringify(index, null, 2), "utf-8");
1150
+ await rename(tmpPath, this.indexPath);
1089
1151
  }
1090
1152
  async updateIndex(trajectory2, filePath) {
1091
- const index = await this.loadIndex();
1092
- index.trajectories[trajectory2.id] = {
1093
- title: trajectory2.task.title,
1094
- status: trajectory2.status,
1095
- startedAt: trajectory2.startedAt,
1096
- completedAt: trajectory2.completedAt,
1097
- path: filePath
1098
- };
1099
- await this.saveIndex(index);
1153
+ await withIndexLock(this.indexPath, async () => {
1154
+ const index = await this.loadIndex();
1155
+ index.trajectories[trajectory2.id] = {
1156
+ title: trajectory2.task.title,
1157
+ status: trajectory2.status,
1158
+ startedAt: trajectory2.startedAt,
1159
+ completedAt: trajectory2.completedAt,
1160
+ path: filePath
1161
+ };
1162
+ await this.saveIndex(index);
1163
+ });
1100
1164
  }
1101
1165
  };
1102
1166
 
@@ -2039,4 +2103,4 @@ export {
2039
2103
  getCommitsBetween,
2040
2104
  getFilesChangedBetween
2041
2105
  };
2042
- //# sourceMappingURL=chunk-2XT3DOJC.js.map
2106
+ //# sourceMappingURL=chunk-27AQPWHK.js.map