@gleanwork/api-client 0.13.11 → 0.13.13

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 (45) hide show
  1. package/dist/commonjs/hooks/registration.d.ts +1 -1
  2. package/dist/commonjs/hooks/registration.d.ts.map +1 -1
  3. package/dist/commonjs/hooks/registration.js +32 -1
  4. package/dist/commonjs/hooks/registration.js.map +1 -1
  5. package/dist/commonjs/lib/config.d.ts +3 -3
  6. package/dist/commonjs/lib/config.js +3 -3
  7. package/dist/commonjs/types/enums.d.ts +1 -8
  8. package/dist/commonjs/types/enums.d.ts.map +1 -1
  9. package/dist/commonjs/types/enums.js +3 -21
  10. package/dist/commonjs/types/enums.js.map +1 -1
  11. package/dist/commonjs/types/index.d.ts +2 -1
  12. package/dist/commonjs/types/index.d.ts.map +1 -1
  13. package/dist/commonjs/types/index.js +15 -0
  14. package/dist/commonjs/types/index.js.map +1 -1
  15. package/dist/commonjs/types/unrecognized.d.ts +10 -0
  16. package/dist/commonjs/types/unrecognized.d.ts.map +1 -0
  17. package/dist/commonjs/types/unrecognized.js +26 -0
  18. package/dist/commonjs/types/unrecognized.js.map +1 -0
  19. package/dist/esm/hooks/registration.d.ts +1 -1
  20. package/dist/esm/hooks/registration.d.ts.map +1 -1
  21. package/dist/esm/hooks/registration.js +32 -1
  22. package/dist/esm/hooks/registration.js.map +1 -1
  23. package/dist/esm/lib/config.d.ts +3 -3
  24. package/dist/esm/lib/config.js +3 -3
  25. package/dist/esm/types/enums.d.ts +1 -8
  26. package/dist/esm/types/enums.d.ts.map +1 -1
  27. package/dist/esm/types/enums.js +1 -18
  28. package/dist/esm/types/enums.js.map +1 -1
  29. package/dist/esm/types/index.d.ts +2 -1
  30. package/dist/esm/types/index.d.ts.map +1 -1
  31. package/dist/esm/types/index.js +1 -0
  32. package/dist/esm/types/index.js.map +1 -1
  33. package/dist/esm/types/unrecognized.d.ts +10 -0
  34. package/dist/esm/types/unrecognized.d.ts.map +1 -0
  35. package/dist/esm/types/unrecognized.js +23 -0
  36. package/dist/esm/types/unrecognized.js.map +1 -0
  37. package/examples/package-lock.json +1 -1
  38. package/examples/src/agentWithFileUpload.example.ts +32 -0
  39. package/jsr.json +1 -1
  40. package/package.json +1 -1
  41. package/src/hooks/registration.ts +38 -2
  42. package/src/lib/config.ts +3 -3
  43. package/src/types/enums.ts +1 -21
  44. package/src/types/index.ts +2 -1
  45. package/src/types/unrecognized.ts +27 -0
@@ -1,3 +1,3 @@
1
- import { Hooks } from "./types.js";
1
+ import { Hooks } from './types.js';
2
2
  export declare function initHooks(hooks: Hooks): void;
3
3
  //# sourceMappingURL=registration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAIrC"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,YAAY,CAAC;AA4CnD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAKrC"}
@@ -6,10 +6,41 @@ exports.initHooks = initHooks;
6
6
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
7
7
  * in this file or in separate files in the hooks folder.
8
8
  */
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
9
+ const agentFileUploadErrorHook = {
10
+ afterError: async (hookCtx, response, error) => {
11
+ if ((hookCtx.operationID === 'createAndWaitRun' ||
12
+ hookCtx.operationID === 'createAndStreamRun') &&
13
+ response?.status === 400) {
14
+ const errorMessage = String(error);
15
+ // The API returns "Not enough user permissions" when it fails to parse the file ID string
16
+ if (errorMessage.includes('permission')) {
17
+ return {
18
+ response,
19
+ error: new Error(`Agent file upload error: When using agents with file inputs, you must follow a two-step process:\n` +
20
+ `\n1. First, upload files using client.chat.uploadFiles():\n` +
21
+ ` const uploadResult = await glean.client.chat.uploadFiles({\n` +
22
+ ` files: [fileBlob]\n` +
23
+ ` });\n` +
24
+ `\n2. Then, pass the returned file IDs (not Blob/File objects) in the input field:\n` +
25
+ ` const result = await glean.client.agents.run({\n` +
26
+ ` agentId: '<agent-id>',\n` +
27
+ ` input: {\n` +
28
+ ` myFile: uploadResult.files[0].id // Use the file ID\n` +
29
+ ` }\n` +
30
+ ` });\n` +
31
+ `\nFor a complete example, see: examples/src/agentWithFileUpload.example.ts\n` +
32
+ `Documentation: https://developers.glean.com/api/client-api/agents/overview\n` +
33
+ `\nOriginal error: ${errorMessage}`),
34
+ };
35
+ }
36
+ }
37
+ return { response, error };
38
+ },
39
+ };
10
40
  function initHooks(hooks) {
11
41
  // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
12
42
  // with an instance of a hook that implements that specific Hook interface
13
43
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
44
+ hooks.registerAfterErrorHook(agentFileUploadErrorHook);
14
45
  }
15
46
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":";;AASA,8BAIC;AAXD;;;;GAIG;AAEH,mFAAmF;AACnF,SAAgB,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;AAC9F,CAAC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":";;AA4CA,8BAKC;AA/CD;;;;GAIG;AAEH,MAAM,wBAAwB,GAAmB;IAC/C,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QAC7C,IACE,CAAC,OAAO,CAAC,WAAW,KAAK,kBAAkB;YACzC,OAAO,CAAC,WAAW,KAAK,oBAAoB,CAAC;YAC/C,QAAQ,EAAE,MAAM,KAAK,GAAG,EACxB,CAAC;YACD,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,0FAA0F;YAC1F,IAAI,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxC,OAAO;oBACL,QAAQ;oBACR,KAAK,EAAE,IAAI,KAAK,CACd,oGAAoG;wBAClG,6DAA6D;wBAC7D,iEAAiE;wBACjE,0BAA0B;wBAC1B,UAAU;wBACV,qFAAqF;wBACrF,qDAAqD;wBACrD,+BAA+B;wBAC/B,iBAAiB;wBACjB,+DAA+D;wBAC/D,UAAU;wBACV,UAAU;wBACV,8EAA8E;wBAC9E,8EAA8E;wBAC9E,qBAAqB,YAAY,EAAE,CACtC;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF,SAAgB,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;IAC5F,KAAK,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;AACzD,CAAC"}
@@ -35,8 +35,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
35
35
  export declare const SDK_METADATA: {
36
36
  readonly language: "typescript";
37
37
  readonly openapiDocVersion: "0.9.0";
38
- readonly sdkVersion: "0.13.11";
39
- readonly genVersion: "2.755.9";
40
- readonly userAgent: "speakeasy-sdk/typescript 0.13.11 2.755.9 0.9.0 @gleanwork/api-client";
38
+ readonly sdkVersion: "0.13.13";
39
+ readonly genVersion: "2.760.2";
40
+ readonly userAgent: "speakeasy-sdk/typescript 0.13.13 2.760.2 0.9.0 @gleanwork/api-client";
41
41
  };
42
42
  //# sourceMappingURL=config.d.ts.map
@@ -34,8 +34,8 @@ function serverURLFromOptions(options) {
34
34
  exports.SDK_METADATA = {
35
35
  language: "typescript",
36
36
  openapiDocVersion: "0.9.0",
37
- sdkVersion: "0.13.11",
38
- genVersion: "2.755.9",
39
- userAgent: "speakeasy-sdk/typescript 0.13.11 2.755.9 0.9.0 @gleanwork/api-client",
37
+ sdkVersion: "0.13.13",
38
+ genVersion: "2.760.2",
39
+ userAgent: "speakeasy-sdk/typescript 0.13.13 2.760.2 0.9.0 @gleanwork/api-client",
40
40
  };
41
41
  //# sourceMappingURL=config.js.map
@@ -1,16 +1,9 @@
1
1
  import * as z from "zod/v3";
2
- declare const __brand: unique symbol;
3
- export type Unrecognized<T> = T & {
4
- [__brand]: "unrecognized";
5
- };
2
+ import { Unrecognized } from "./unrecognized.js";
6
3
  export type ClosedEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T];
7
4
  export type OpenEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T] | Unrecognized<T[keyof T] extends number ? number : string>;
8
- export declare function unrecognizedCounter(): {
9
- count: () => number;
10
- };
11
5
  export declare function inboundSchema<T extends Record<string, string>>(enumObj: T): z.ZodType<OpenEnum<T>, z.ZodTypeDef, unknown>;
12
6
  export declare function inboundSchemaInt<T extends Record<string, number | string>>(enumObj: T): z.ZodType<OpenEnum<T>, z.ZodTypeDef, unknown>;
13
7
  export declare function outboundSchema<T extends Record<string, string>>(_: T): z.ZodType<string, z.ZodTypeDef, OpenEnum<T>>;
14
8
  export declare function outboundSchemaInt<T extends Record<string, number | string>>(_: T): z.ZodType<number, z.ZodTypeDef, OpenEnum<T>>;
15
- export {};
16
9
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,CAAC,OAAO,CAAC,EAAE,cA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9C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACzE,CAAC,EAAE,CAAC,GACH,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAE9C"}
@@ -36,35 +36,17 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.unrecognizedCounter = unrecognizedCounter;
40
39
  exports.inboundSchema = inboundSchema;
41
40
  exports.inboundSchemaInt = inboundSchemaInt;
42
41
  exports.outboundSchema = outboundSchema;
43
42
  exports.outboundSchemaInt = outboundSchemaInt;
44
43
  const z = __importStar(require("zod/v3"));
45
- function unrecognized(value) {
46
- unrecognizedCount++;
47
- return value;
48
- }
49
- let unrecognizedCount = 0;
50
- let refCount = 0;
51
- function unrecognizedCounter() {
52
- refCount++;
53
- const start = unrecognizedCount;
54
- return {
55
- count: () => {
56
- const count = unrecognizedCount - start;
57
- if (--refCount === 0)
58
- unrecognizedCount = 0;
59
- return count;
60
- },
61
- };
62
- }
44
+ const unrecognized_js_1 = require("./unrecognized.js");
63
45
  function inboundSchema(enumObj) {
64
46
  const options = Object.values(enumObj);
65
47
  return z.union([
66
48
  ...options.map(x => z.literal(x)),
67
- z.string().transform(x => unrecognized(x)),
49
+ z.string().transform(x => (0, unrecognized_js_1.unrecognized)(x)),
68
50
  ]);
69
51
  }
70
52
  function inboundSchemaInt(enumObj) {
@@ -72,7 +54,7 @@ function inboundSchemaInt(enumObj) {
72
54
  const options = Object.values(enumObj).filter(v => typeof v === "number");
73
55
  return z.union([
74
56
  ...options.map(x => z.literal(x)),
75
- z.number().int().transform(x => unrecognized(x)),
57
+ z.number().int().transform(x => (0, unrecognized_js_1.unrecognized)(x)),
76
58
  ]);
77
59
  }
78
60
  function outboundSchema(_) {
@@ -1 +1 @@
1
- {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AQ,CAAC,CAAC;IAC1E,OAAO,CAAC,CAAC,KAAK,CAAC;QACb,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,8BAAY,EAAC,CAAC,CAAC,CAAC;KAC1C,CAAC,CAAC;AACZ,CAAC;AAED,SAAgB,cAAc,CAC5B,CAAI;IAEJ,OAAO,CAAC,CAAC,MAAM,EAAS,CAAC;AAC3B,CAAC;AAED,SAAgB,iBAAiB,CAC/B,CAAI;IAEJ,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAS,CAAC;AACjC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
2
- export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js";
2
+ export type { ClosedEnum, OpenEnum } from "./enums.js";
3
3
  export type { Result } from "./fp.js";
4
4
  export type { PageIterator, Paginator } from "./operations.js";
5
5
  export { createPageIterator } from "./operations.js";
6
6
  export { RFCDate } from "./rfcdate.js";
7
+ export * from "./unrecognized.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -2,6 +2,20 @@
2
2
  /*
3
3
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
4
  */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
5
19
  Object.defineProperty(exports, "__esModule", { value: true });
6
20
  exports.RFCDate = exports.createPageIterator = exports.isBlobLike = exports.blobLikeSchema = void 0;
7
21
  var blobs_js_1 = require("./blobs.js");
@@ -11,4 +25,5 @@ var operations_js_1 = require("./operations.js");
11
25
  Object.defineProperty(exports, "createPageIterator", { enumerable: true, get: function () { return operations_js_1.createPageIterator; } });
12
26
  var rfcdate_js_1 = require("./rfcdate.js");
13
27
  Object.defineProperty(exports, "RFCDate", { enumerable: true, get: function () { return rfcdate_js_1.RFCDate; } });
28
+ __exportStar(require("./unrecognized.js"), exports);
14
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAwD;AAA/C,0GAAA,cAAc,OAAA;AAAE,sGAAA,UAAU,OAAA;AAInC,iDAAqD;AAA5C,mHAAA,kBAAkB,OAAA;AAC3B,2CAAuC;AAA9B,qGAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,uCAAwD;AAA/C,0GAAA,cAAc,OAAA;AAAE,sGAAA,UAAU,OAAA;AAInC,iDAAqD;AAA5C,mHAAA,kBAAkB,OAAA;AAC3B,2CAAuC;AAA9B,qGAAA,OAAO,OAAA;AAChB,oDAAkC"}
@@ -0,0 +1,10 @@
1
+ declare const __brand: unique symbol;
2
+ export type Unrecognized<T> = T & {
3
+ [__brand]: "unrecognized";
4
+ };
5
+ declare function unrecognized<T>(value: T): Unrecognized<T>;
6
+ export declare function startCountingUnrecognized(): {
7
+ end: () => number;
8
+ };
9
+ export { unrecognized };
10
+ //# sourceMappingURL=unrecognized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecognized.d.ts","sourceRoot":"","sources":["../../../src/types/unrecognized.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAEhE,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAGlD;AAID,wBAAgB,yBAAyB;;EAUxC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startCountingUnrecognized = startCountingUnrecognized;
7
+ exports.unrecognized = unrecognized;
8
+ function unrecognized(value) {
9
+ globalCount++;
10
+ return value;
11
+ }
12
+ let globalCount = 0;
13
+ let refCount = 0;
14
+ function startCountingUnrecognized() {
15
+ refCount++;
16
+ const start = globalCount;
17
+ return {
18
+ end: () => {
19
+ const count = globalCount - start;
20
+ if (--refCount === 0)
21
+ globalCount = 0;
22
+ return count;
23
+ },
24
+ };
25
+ }
26
+ //# sourceMappingURL=unrecognized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecognized.js","sourceRoot":"","sources":["../../../src/types/unrecognized.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAYH,8DAUC;AAEQ,oCAAY;AAnBrB,SAAS,YAAY,CAAI,KAAQ;IAC/B,WAAW,EAAE,CAAC;IACd,OAAO,KAAwB,CAAC;AAClC,CAAC;AAED,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAgB,yBAAyB;IACvC,QAAQ,EAAE,CAAC;IACX,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,MAAM,KAAK,GAAG,WAAW,GAAG,KAAK,CAAC;YAClC,IAAI,EAAE,QAAQ,KAAK,CAAC;gBAAE,WAAW,GAAG,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,3 +1,3 @@
1
- import { Hooks } from "./types.js";
1
+ import { Hooks } from './types.js';
2
2
  export declare function initHooks(hooks: Hooks): void;
3
3
  //# sourceMappingURL=registration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAIrC"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,YAAY,CAAC;AA4CnD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAKrC"}
@@ -3,10 +3,41 @@
3
3
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
4
4
  * in this file or in separate files in the hooks folder.
5
5
  */
6
- // @ts-expect-error remove this line when you add your first hook and hooks is used
6
+ const agentFileUploadErrorHook = {
7
+ afterError: async (hookCtx, response, error) => {
8
+ if ((hookCtx.operationID === 'createAndWaitRun' ||
9
+ hookCtx.operationID === 'createAndStreamRun') &&
10
+ response?.status === 400) {
11
+ const errorMessage = String(error);
12
+ // The API returns "Not enough user permissions" when it fails to parse the file ID string
13
+ if (errorMessage.includes('permission')) {
14
+ return {
15
+ response,
16
+ error: new Error(`Agent file upload error: When using agents with file inputs, you must follow a two-step process:\n` +
17
+ `\n1. First, upload files using client.chat.uploadFiles():\n` +
18
+ ` const uploadResult = await glean.client.chat.uploadFiles({\n` +
19
+ ` files: [fileBlob]\n` +
20
+ ` });\n` +
21
+ `\n2. Then, pass the returned file IDs (not Blob/File objects) in the input field:\n` +
22
+ ` const result = await glean.client.agents.run({\n` +
23
+ ` agentId: '<agent-id>',\n` +
24
+ ` input: {\n` +
25
+ ` myFile: uploadResult.files[0].id // Use the file ID\n` +
26
+ ` }\n` +
27
+ ` });\n` +
28
+ `\nFor a complete example, see: examples/src/agentWithFileUpload.example.ts\n` +
29
+ `Documentation: https://developers.glean.com/api/client-api/agents/overview\n` +
30
+ `\nOriginal error: ${errorMessage}`),
31
+ };
32
+ }
33
+ }
34
+ return { response, error };
35
+ },
36
+ };
7
37
  export function initHooks(hooks) {
8
38
  // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
9
39
  // with an instance of a hook that implements that specific Hook interface
10
40
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
41
+ hooks.registerAfterErrorHook(agentFileUploadErrorHook);
11
42
  }
12
43
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;AAC9F,CAAC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,wBAAwB,GAAmB;IAC/C,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QAC7C,IACE,CAAC,OAAO,CAAC,WAAW,KAAK,kBAAkB;YACzC,OAAO,CAAC,WAAW,KAAK,oBAAoB,CAAC;YAC/C,QAAQ,EAAE,MAAM,KAAK,GAAG,EACxB,CAAC;YACD,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,0FAA0F;YAC1F,IAAI,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxC,OAAO;oBACL,QAAQ;oBACR,KAAK,EAAE,IAAI,KAAK,CACd,oGAAoG;wBAClG,6DAA6D;wBAC7D,iEAAiE;wBACjE,0BAA0B;wBAC1B,UAAU;wBACV,qFAAqF;wBACrF,qDAAqD;wBACrD,+BAA+B;wBAC/B,iBAAiB;wBACjB,+DAA+D;wBAC/D,UAAU;wBACV,UAAU;wBACV,8EAA8E;wBAC9E,8EAA8E;wBAC9E,qBAAqB,YAAY,EAAE,CACtC;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;IAC5F,KAAK,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;AACzD,CAAC"}
@@ -35,8 +35,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
35
35
  export declare const SDK_METADATA: {
36
36
  readonly language: "typescript";
37
37
  readonly openapiDocVersion: "0.9.0";
38
- readonly sdkVersion: "0.13.11";
39
- readonly genVersion: "2.755.9";
40
- readonly userAgent: "speakeasy-sdk/typescript 0.13.11 2.755.9 0.9.0 @gleanwork/api-client";
38
+ readonly sdkVersion: "0.13.13";
39
+ readonly genVersion: "2.760.2";
40
+ readonly userAgent: "speakeasy-sdk/typescript 0.13.13 2.760.2 0.9.0 @gleanwork/api-client";
41
41
  };
42
42
  //# sourceMappingURL=config.d.ts.map
@@ -30,8 +30,8 @@ export function serverURLFromOptions(options) {
30
30
  export const SDK_METADATA = {
31
31
  language: "typescript",
32
32
  openapiDocVersion: "0.9.0",
33
- sdkVersion: "0.13.11",
34
- genVersion: "2.755.9",
35
- userAgent: "speakeasy-sdk/typescript 0.13.11 2.755.9 0.9.0 @gleanwork/api-client",
33
+ sdkVersion: "0.13.13",
34
+ genVersion: "2.760.2",
35
+ userAgent: "speakeasy-sdk/typescript 0.13.13 2.760.2 0.9.0 @gleanwork/api-client",
36
36
  };
37
37
  //# sourceMappingURL=config.js.map
@@ -1,16 +1,9 @@
1
1
  import * as z from "zod/v3";
2
- declare const __brand: unique symbol;
3
- export type Unrecognized<T> = T & {
4
- [__brand]: "unrecognized";
5
- };
2
+ import { Unrecognized } from "./unrecognized.js";
6
3
  export type ClosedEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T];
7
4
  export type OpenEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T] | Unrecognized<T[keyof T] extends number ? number : string>;
8
- export declare function unrecognizedCounter(): {
9
- count: () => number;
10
- };
11
5
  export declare function inboundSchema<T extends Record<string, string>>(enumObj: T): z.ZodType<OpenEnum<T>, z.ZodTypeDef, unknown>;
12
6
  export declare function inboundSchemaInt<T extends Record<string, number | string>>(enumObj: T): z.ZodType<OpenEnum<T>, z.ZodTypeDef, unknown>;
13
7
  export declare function outboundSchema<T extends Record<string, string>>(_: T): z.ZodType<string, z.ZodTypeDef, OpenEnum<T>>;
14
8
  export declare function outboundSchemaInt<T extends Record<string, number | string>>(_: T): z.ZodType<number, z.ZodTypeDef, OpenEnum<T>>;
15
- export {};
16
9
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,IACxE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACb,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,IACpE,CAAC,CAAC,MAAM,CAAC,CAAC,GACV,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;AAS9D,wBAAgB,mBAAmB;;EAUlC;AAED,wB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AAM,GAAG,MAAM,CAAC,CAAC,IACpE,CAAC,CAAC,MAAM,CAAC,CAAC,GACV,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;AAE9D,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5D,OAAO,EAAE,CAAC,GACT,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAM/C;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACxE,OAAO,EAAE,CAAC,GACT,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAO/C;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7D,CAAC,EAAE,CAAC,GACH,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAE9C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACzE,CAAC,EAAE,CAAC,GACH,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAE9C"}
@@ -2,24 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
  import * as z from "zod/v3";
5
- function unrecognized(value) {
6
- unrecognizedCount++;
7
- return value;
8
- }
9
- let unrecognizedCount = 0;
10
- let refCount = 0;
11
- export function unrecognizedCounter() {
12
- refCount++;
13
- const start = unrecognizedCount;
14
- return {
15
- count: () => {
16
- const count = unrecognizedCount - start;
17
- if (--refCount === 0)
18
- unrecognizedCount = 0;
19
- return count;
20
- },
21
- };
22
- }
5
+ import { unrecognized } from "./unrecognized.js";
23
6
  export function inboundSchema(enumObj) {
24
7
  const options = Object.values(enumObj);
25
8
  return z.union([
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAU5B,SAAS,YAAY,CAAI,KAAQ;IAC/B,iBAAiB,EAAE,CAAC;IACpB,OAAO,KAAwB,CAAC;AAClC,CAAC;AAED,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAC1B,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,MAAM,UAAU,mBAAmB;IACjC,QAAQ,EAAE,CAAC;IACX,MAAM,KAAK,GAAG,iBAAiB,CAAC;IAChC,OAAO;QACL,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,KAAK,GAAG,iBAAiB,GAAG,KAAK,CAAC;YACxC,IAAI,EAAE,QAAQ,KAAK,CAAC;gBAAE,iBAAiB,GAAG,CAAC,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAU;IAEV,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,KAAK,CAAC;QACb,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KACpC,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,OAAU;IAEV,wEAA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IAEV,wEAAwE;IACxE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC1E,OAAO,CAAC,CAAC,KAAK,CAAC;QACb,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KAC1C,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,CAAI;IAEJ,OAAO,CAAC,CAAC,MAAM,EAAS,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,CAAI;IAEJ,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAS,CAAC;AACjC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
2
- export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js";
2
+ export type { ClosedEnum, OpenEnum } from "./enums.js";
3
3
  export type { Result } from "./fp.js";
4
4
  export type { PageIterator, Paginator } from "./operations.js";
5
5
  export { createPageIterator } from "./operations.js";
6
6
  export { RFCDate } from "./rfcdate.js";
7
+ export * from "./unrecognized.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -4,4 +4,5 @@
4
4
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
5
5
  export { createPageIterator } from "./operations.js";
6
6
  export { RFCDate } from "./rfcdate.js";
7
+ export * from "./unrecognized.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,10 @@
1
+ declare const __brand: unique symbol;
2
+ export type Unrecognized<T> = T & {
3
+ [__brand]: "unrecognized";
4
+ };
5
+ declare function unrecognized<T>(value: T): Unrecognized<T>;
6
+ export declare function startCountingUnrecognized(): {
7
+ end: () => number;
8
+ };
9
+ export { unrecognized };
10
+ //# sourceMappingURL=unrecognized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecognized.d.ts","sourceRoot":"","sources":["../../../src/types/unrecognized.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAEhE,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAGlD;AAID,wBAAgB,yBAAyB;;EAUxC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ function unrecognized(value) {
5
+ globalCount++;
6
+ return value;
7
+ }
8
+ let globalCount = 0;
9
+ let refCount = 0;
10
+ export function startCountingUnrecognized() {
11
+ refCount++;
12
+ const start = globalCount;
13
+ return {
14
+ end: () => {
15
+ const count = globalCount - start;
16
+ if (--refCount === 0)
17
+ globalCount = 0;
18
+ return count;
19
+ },
20
+ };
21
+ }
22
+ export { unrecognized };
23
+ //# sourceMappingURL=unrecognized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecognized.js","sourceRoot":"","sources":["../../../src/types/unrecognized.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,SAAS,YAAY,CAAI,KAAQ;IAC/B,WAAW,EAAE,CAAC;IACd,OAAO,KAAwB,CAAC;AAClC,CAAC;AAED,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,MAAM,UAAU,yBAAyB;IACvC,QAAQ,EAAE,CAAC;IACX,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,MAAM,KAAK,GAAG,WAAW,GAAG,KAAK,CAAC;YAClC,IAAI,EAAE,QAAQ,KAAK,CAAC;gBAAE,WAAW,GAAG,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "..": {
20
20
  "name": "@gleanwork/api-client",
21
- "version": "0.13.11",
21
+ "version": "0.13.13",
22
22
  "dependencies": {
23
23
  "zod": "^3.25.0 || ^4.0.0"
24
24
  },
@@ -0,0 +1,32 @@
1
+ import { config } from 'dotenv';
2
+ config();
3
+ import { Glean } from '@gleanwork/api-client';
4
+
5
+ const glean = new Glean({
6
+ domain: process.env['GLEAN_DOMAIN'] ?? '',
7
+ apiToken: process.env['GLEAN_BEARER_AUTH'] ?? '',
8
+ });
9
+
10
+ async function run() {
11
+ // 1. Upload the file first
12
+ const fileBlob = new Blob(['name,role\nAlice,Engineer'], { type: 'text/csv' });
13
+
14
+ const uploadResponse = await glean.client.chat.uploadFiles({
15
+ files: [fileBlob as any],
16
+ });
17
+
18
+ const fileId = uploadResponse.files[0].id;
19
+ console.log(`File uploaded: ${fileId}`);
20
+
21
+ // 2. Pass the file ID (NOT the blob) to the agent
22
+ const result = await glean.client.agents.run({
23
+ agentId: process.env['GLEAN_AGENT_ID']!,
24
+ input: {
25
+ file_input: fileId, // ✅ Pass the ID string
26
+ },
27
+ });
28
+
29
+ console.log('Agent run result:', result);
30
+ }
31
+
32
+ run();
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@gleanwork/api-client",
5
- "version": "0.13.11",
5
+ "version": "0.13.13",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gleanwork/api-client",
3
- "version": "0.13.11",
3
+ "version": "0.13.13",
4
4
  "author": "Speakeasy",
5
5
  "type": "module",
6
6
  "tshy": {
@@ -1,4 +1,4 @@
1
- import { Hooks } from "./types.js";
1
+ import { Hooks, AfterErrorHook } from './types.js';
2
2
 
3
3
  /*
4
4
  * This file is only ever generated once on the first generation and then is free to be modified.
@@ -6,9 +6,45 @@ import { Hooks } from "./types.js";
6
6
  * in this file or in separate files in the hooks folder.
7
7
  */
8
8
 
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
9
+ const agentFileUploadErrorHook: AfterErrorHook = {
10
+ afterError: async (hookCtx, response, error) => {
11
+ if (
12
+ (hookCtx.operationID === 'createAndWaitRun' ||
13
+ hookCtx.operationID === 'createAndStreamRun') &&
14
+ response?.status === 400
15
+ ) {
16
+ const errorMessage = String(error);
17
+ // The API returns "Not enough user permissions" when it fails to parse the file ID string
18
+ if (errorMessage.includes('permission')) {
19
+ return {
20
+ response,
21
+ error: new Error(
22
+ `Agent file upload error: When using agents with file inputs, you must follow a two-step process:\n` +
23
+ `\n1. First, upload files using client.chat.uploadFiles():\n` +
24
+ ` const uploadResult = await glean.client.chat.uploadFiles({\n` +
25
+ ` files: [fileBlob]\n` +
26
+ ` });\n` +
27
+ `\n2. Then, pass the returned file IDs (not Blob/File objects) in the input field:\n` +
28
+ ` const result = await glean.client.agents.run({\n` +
29
+ ` agentId: '<agent-id>',\n` +
30
+ ` input: {\n` +
31
+ ` myFile: uploadResult.files[0].id // Use the file ID\n` +
32
+ ` }\n` +
33
+ ` });\n` +
34
+ `\nFor a complete example, see: examples/src/agentWithFileUpload.example.ts\n` +
35
+ `Documentation: https://developers.glean.com/api/client-api/agents/overview\n` +
36
+ `\nOriginal error: ${errorMessage}`
37
+ ),
38
+ };
39
+ }
40
+ }
41
+ return { response, error };
42
+ },
43
+ };
44
+
10
45
  export function initHooks(hooks: Hooks) {
11
46
  // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
12
47
  // with an instance of a hook that implements that specific Hook interface
13
48
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
49
+ hooks.registerAfterErrorHook(agentFileUploadErrorHook);
14
50
  }
package/src/lib/config.ts CHANGED
@@ -68,8 +68,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
68
68
  export const SDK_METADATA = {
69
69
  language: "typescript",
70
70
  openapiDocVersion: "0.9.0",
71
- sdkVersion: "0.13.11",
72
- genVersion: "2.755.9",
71
+ sdkVersion: "0.13.13",
72
+ genVersion: "2.760.2",
73
73
  userAgent:
74
- "speakeasy-sdk/typescript 0.13.11 2.755.9 0.9.0 @gleanwork/api-client",
74
+ "speakeasy-sdk/typescript 0.13.13 2.760.2 0.9.0 @gleanwork/api-client",
75
75
  } as const;
@@ -3,34 +3,14 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod/v3";
6
+ import { Unrecognized, unrecognized } from "./unrecognized.js";
6
7
 
7
- declare const __brand: unique symbol;
8
- export type Unrecognized<T> = T & { [__brand]: "unrecognized" };
9
8
  export type ClosedEnum<T extends Readonly<Record<string, string | number>>> =
10
9
  T[keyof T];
11
10
  export type OpenEnum<T extends Readonly<Record<string, string | number>>> =
12
11
  | T[keyof T]
13
12
  | Unrecognized<T[keyof T] extends number ? number : string>;
14
13
 
15
- function unrecognized<T>(value: T): Unrecognized<T> {
16
- unrecognizedCount++;
17
- return value as Unrecognized<T>;
18
- }
19
-
20
- let unrecognizedCount = 0;
21
- let refCount = 0;
22
- export function unrecognizedCounter() {
23
- refCount++;
24
- const start = unrecognizedCount;
25
- return {
26
- count: () => {
27
- const count = unrecognizedCount - start;
28
- if (--refCount === 0) unrecognizedCount = 0;
29
- return count;
30
- },
31
- };
32
- }
33
-
34
14
  export function inboundSchema<T extends Record<string, string>>(
35
15
  enumObj: T,
36
16
  ): z.ZodType<OpenEnum<T>, z.ZodTypeDef, unknown> {
@@ -3,8 +3,9 @@
3
3
  */
4
4
 
5
5
  export { blobLikeSchema, isBlobLike } from "./blobs.js";
6
- export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js";
6
+ export type { ClosedEnum, OpenEnum } from "./enums.js";
7
7
  export type { Result } from "./fp.js";
8
8
  export type { PageIterator, Paginator } from "./operations.js";
9
9
  export { createPageIterator } from "./operations.js";
10
10
  export { RFCDate } from "./rfcdate.js";
11
+ export * from "./unrecognized.js";
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ declare const __brand: unique symbol;
6
+ export type Unrecognized<T> = T & { [__brand]: "unrecognized" };
7
+
8
+ function unrecognized<T>(value: T): Unrecognized<T> {
9
+ globalCount++;
10
+ return value as Unrecognized<T>;
11
+ }
12
+
13
+ let globalCount = 0;
14
+ let refCount = 0;
15
+ export function startCountingUnrecognized() {
16
+ refCount++;
17
+ const start = globalCount;
18
+ return {
19
+ end: () => {
20
+ const count = globalCount - start;
21
+ if (--refCount === 0) globalCount = 0;
22
+ return count;
23
+ },
24
+ };
25
+ }
26
+
27
+ export { unrecognized };