@introspection-ai/recipes 0.49.0 → 0.51.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/dist/api/mcp.d.ts +1 -0
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +1 -0
- package/dist/api/mcp.js.map +1 -1
- package/dist/channels/tools.d.ts.map +1 -1
- package/dist/channels/tools.js +2 -17
- package/dist/channels/tools.js.map +1 -1
- package/dist/command-parameters.d.ts +10 -0
- package/dist/command-parameters.d.ts.map +1 -0
- package/dist/command-parameters.js +25 -0
- package/dist/command-parameters.js.map +1 -0
- package/dist/connector-tools.d.ts +1 -1
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js +13 -5
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/module.d.ts.map +1 -1
- package/dist/documents/module.js +2 -4
- package/dist/documents/module.js.map +1 -1
- package/dist/documents/profile.d.ts +1 -1
- package/dist/documents/profile.js +1 -1
- package/dist/egress.d.ts +23 -0
- package/dist/egress.d.ts.map +1 -0
- package/dist/egress.js +36 -0
- package/dist/egress.js.map +1 -0
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +23 -2
- package/dist/extensions.js.map +1 -1
- package/dist/introspection-open.d.ts +46 -0
- package/dist/introspection-open.d.ts.map +1 -0
- package/dist/introspection-open.js +278 -0
- package/dist/introspection-open.js.map +1 -0
- package/dist/mcp/index.d.ts +37 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +14 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/pi-client.d.ts +97 -0
- package/dist/mcp/pi-client.d.ts.map +1 -0
- package/dist/mcp/pi-client.js +342 -0
- package/dist/mcp/pi-client.js.map +1 -0
- package/dist/mcp/policy.d.ts +2 -0
- package/dist/mcp/policy.d.ts.map +1 -1
- package/dist/mcp/policy.js +6 -0
- package/dist/mcp/policy.js.map +1 -1
- package/dist/mcp-chunks/{chunk-3M4OCQR5.js → chunk-PO2SOBEN.js} +1 -0
- package/dist/mcp-daemon.js +1 -1
- package/dist/mcp-run-worker.js +1 -1
- package/dist/open.d.ts +82 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +152 -0
- package/dist/open.js.map +1 -0
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +99 -8
- package/dist/pi-extension.js.map +1 -1
- package/dist/productivity/content.d.ts +25 -0
- package/dist/productivity/content.d.ts.map +1 -0
- package/dist/productivity/content.js +94 -0
- package/dist/productivity/content.js.map +1 -0
- package/dist/productivity/handles.d.ts +72 -0
- package/dist/productivity/handles.d.ts.map +1 -0
- package/dist/productivity/handles.js +111 -0
- package/dist/productivity/handles.js.map +1 -0
- package/dist/productivity/http.d.ts +35 -0
- package/dist/productivity/http.d.ts.map +1 -0
- package/dist/productivity/http.js +203 -0
- package/dist/productivity/http.js.map +1 -0
- package/dist/productivity/index.d.ts +11 -0
- package/dist/productivity/index.d.ts.map +1 -0
- package/dist/productivity/index.js +7 -0
- package/dist/productivity/index.js.map +1 -0
- package/dist/productivity/module.d.ts +63 -0
- package/dist/productivity/module.d.ts.map +1 -0
- package/dist/productivity/module.js +119 -0
- package/dist/productivity/module.js.map +1 -0
- package/dist/productivity/paging.d.ts +32 -0
- package/dist/productivity/paging.d.ts.map +1 -0
- package/dist/productivity/paging.js +42 -0
- package/dist/productivity/paging.js.map +1 -0
- package/dist/productivity/tools.d.ts +40 -0
- package/dist/productivity/tools.d.ts.map +1 -0
- package/dist/productivity/tools.js +969 -0
- package/dist/productivity/tools.js.map +1 -0
- package/dist/productivity/types.d.ts +538 -0
- package/dist/productivity/types.d.ts.map +1 -0
- package/dist/productivity/types.js +119 -0
- package/dist/productivity/types.js.map +1 -0
- package/dist/recipe/agent.d.ts +6 -1
- package/dist/recipe/agent.d.ts.map +1 -1
- package/dist/recipe/agent.js +48 -7
- package/dist/recipe/agent.js.map +1 -1
- package/dist/recipe/companions.d.ts +2 -1
- package/dist/recipe/companions.d.ts.map +1 -1
- package/dist/recipe/companions.js +14 -11
- package/dist/recipe/companions.js.map +1 -1
- package/dist/recipe/manifest.generated.d.ts +4 -1
- package/dist/recipe/manifest.generated.d.ts.map +1 -1
- package/dist/recipe/manifest.generated.js +5 -2
- package/dist/recipe/manifest.generated.js.map +1 -1
- package/dist/recipe/package.d.ts +12 -0
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +93 -0
- package/dist/recipe/package.js.map +1 -1
- package/dist/review.d.ts +1 -0
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +1 -0
- package/dist/review.js.map +1 -1
- package/dist/search/egress.d.ts +12 -0
- package/dist/search/egress.d.ts.map +1 -0
- package/dist/search/egress.js +24 -0
- package/dist/search/egress.js.map +1 -0
- package/dist/search/http.d.ts +16 -0
- package/dist/search/http.d.ts.map +1 -0
- package/dist/search/http.js +75 -0
- package/dist/search/http.js.map +1 -0
- package/dist/search/index.d.ts +9 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +5 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/mcp.d.ts +58 -0
- package/dist/search/mcp.d.ts.map +1 -0
- package/dist/search/mcp.js +84 -0
- package/dist/search/mcp.js.map +1 -0
- package/dist/search/module.d.ts +16 -0
- package/dist/search/module.d.ts.map +1 -0
- package/dist/search/module.js +27 -0
- package/dist/search/module.js.map +1 -0
- package/dist/search/tool.d.ts +96 -0
- package/dist/search/tool.d.ts.map +1 -0
- package/dist/search/tool.js +505 -0
- package/dist/search/tool.js.map +1 -0
- package/dist/search/types.d.ts +247 -0
- package/dist/search/types.d.ts.map +1 -0
- package/dist/search/types.js +60 -0
- package/dist/search/types.js.map +1 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +175 -15
- package/dist/session.js.map +1 -1
- package/dist/skill-progress.d.ts.map +1 -1
- package/dist/skill-progress.js +5 -1
- package/dist/skill-progress.js.map +1 -1
- package/dist/tool-search.d.ts +2 -2
- package/dist/tool-search.d.ts.map +1 -1
- package/dist/tool-search.js +4 -2
- package/dist/tool-search.js.map +1 -1
- package/docs/{index.md → README.md} +10 -3
- package/docs/{slack.md → channels/slack.md} +1 -1
- package/docs/{documents.md → documents/README.md} +4 -4
- package/docs/interactions.md +90 -31
- package/docs/mcp-configuration.md +77 -2
- package/docs/productivity/README.md +360 -0
- package/docs/productivity/google.md +226 -0
- package/docs/productivity/microsoft.md +143 -0
- package/docs/recipe-format.md +24 -3
- package/docs/search/README.md +801 -0
- package/package.json +19 -8
- package/skills/README.md +12 -0
- package/skills/productivity/SKILL.md +76 -0
- package/skills/search/SKILL.md +72 -0
- /package/docs/{channels.md → channels/README.md} +0 -0
- /package/{documents → skills/documents}/SKILL.md +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ProductivityContent } from "./types.js";
|
|
2
|
+
/** The most characters of a mail or event body a result carries. */
|
|
3
|
+
export declare const BODY_LIMIT_CHARS = 20000;
|
|
4
|
+
/** The most characters of a file's text `drive read` returns. */
|
|
5
|
+
export declare const FILE_TEXT_LIMIT_CHARS = 100000;
|
|
6
|
+
/** Text as a result carries it: plain, and capped at a limit the result states. */
|
|
7
|
+
export interface ProductivityText {
|
|
8
|
+
text: string;
|
|
9
|
+
/** Whether `text` was cut at `limit_chars`. */
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
limit_chars: number;
|
|
12
|
+
/** The length before cutting, when it was cut. */
|
|
13
|
+
original_chars?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* HTML to plain text for the model. Scripts, styles, comments and images
|
|
17
|
+
* (tracking pixels and remote content) are dropped; a link keeps its text and,
|
|
18
|
+
* when it differs, its address; block elements become line breaks.
|
|
19
|
+
*/
|
|
20
|
+
export declare function htmlToText(html: string): string;
|
|
21
|
+
/** Cut text at `limit` characters, saying so. */
|
|
22
|
+
export declare function capText(text: string, limit: number): ProductivityText;
|
|
23
|
+
/** A provider's content as capped plain text. */
|
|
24
|
+
export declare function contentText(content: ProductivityContent | undefined, limit: number): ProductivityText | undefined;
|
|
25
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/productivity/content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAE7C,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AA6CD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkC/C;AAED,iDAAiD;AACjD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CASrE;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CACzB,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,KAAK,EAAE,MAAM,GACZ,gBAAgB,GAAG,SAAS,CAO9B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** The most characters of a mail or event body a result carries. */
|
|
2
|
+
export const BODY_LIMIT_CHARS = 20_000;
|
|
3
|
+
/** The most characters of a file's text `drive read` returns. */
|
|
4
|
+
export const FILE_TEXT_LIMIT_CHARS = 100_000;
|
|
5
|
+
const ENTITIES = {
|
|
6
|
+
amp: "&",
|
|
7
|
+
lt: "<",
|
|
8
|
+
gt: ">",
|
|
9
|
+
quot: '"',
|
|
10
|
+
apos: "'",
|
|
11
|
+
nbsp: " ",
|
|
12
|
+
ndash: "–",
|
|
13
|
+
mdash: "—",
|
|
14
|
+
hellip: "…",
|
|
15
|
+
lsquo: "‘",
|
|
16
|
+
rsquo: "’",
|
|
17
|
+
ldquo: "“",
|
|
18
|
+
rdquo: "”",
|
|
19
|
+
copy: "©",
|
|
20
|
+
reg: "®",
|
|
21
|
+
trade: "™",
|
|
22
|
+
bull: "•",
|
|
23
|
+
middot: "·",
|
|
24
|
+
euro: "€",
|
|
25
|
+
pound: "£",
|
|
26
|
+
zwnj: "",
|
|
27
|
+
zwj: "",
|
|
28
|
+
};
|
|
29
|
+
function decodeEntities(text) {
|
|
30
|
+
return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]*);/gi, (match, entity) => {
|
|
31
|
+
if (entity[0] === "#") {
|
|
32
|
+
const code = entity[1] === "x" || entity[1] === "X"
|
|
33
|
+
? Number.parseInt(entity.slice(2), 16)
|
|
34
|
+
: Number.parseInt(entity.slice(1), 10);
|
|
35
|
+
return Number.isFinite(code) && code > 0 && code <= 0x10ffff
|
|
36
|
+
? String.fromCodePoint(code)
|
|
37
|
+
: "";
|
|
38
|
+
}
|
|
39
|
+
return ENTITIES[entity.toLowerCase()] ?? match;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* HTML to plain text for the model. Scripts, styles, comments and images
|
|
44
|
+
* (tracking pixels and remote content) are dropped; a link keeps its text and,
|
|
45
|
+
* when it differs, its address; block elements become line breaks.
|
|
46
|
+
*/
|
|
47
|
+
export function htmlToText(html) {
|
|
48
|
+
let text = html
|
|
49
|
+
.replace(/<!--[\s\S]*?-->/g, "")
|
|
50
|
+
.replace(/<(head|script|style|noscript|template|svg|title)\b[^>]*>[\s\S]*?<\/\1\s*>/gi, "")
|
|
51
|
+
.replace(/<img\b[^>]*>/gi, "")
|
|
52
|
+
.replace(/<a\b[^>]*?\bhref\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))[^>]*>([\s\S]*?)<\/a\s*>/gi, (_match, _raw, dq, sq, bare, inner = "") => {
|
|
53
|
+
const href = decodeEntities(dq ?? sq ?? bare ?? "").trim();
|
|
54
|
+
const label = inner.replace(/<[^>]*>/g, "").trim();
|
|
55
|
+
if (!/^(https?:|mailto:)/i.test(href))
|
|
56
|
+
return label;
|
|
57
|
+
const shown = href.replace(/^mailto:/i, "");
|
|
58
|
+
return !label || decodeEntities(label) === shown
|
|
59
|
+
? shown
|
|
60
|
+
: `${label} (${shown})`;
|
|
61
|
+
})
|
|
62
|
+
.replace(/<br\s*\/?>/gi, "\n")
|
|
63
|
+
.replace(/<li\b[^>]*>/gi, "\n- ")
|
|
64
|
+
.replace(/<\/(td|th)\s*>/gi, "\t")
|
|
65
|
+
.replace(/<\/?(p|div|tr|table|h[1-6]|ul|ol|blockquote|pre|section|article|header|footer|hr)\b[^>]*>/gi, "\n")
|
|
66
|
+
.replace(/<[^>]*>/g, "");
|
|
67
|
+
text = decodeEntities(text)
|
|
68
|
+
.replace(/\r\n?/g, "\n")
|
|
69
|
+
.replace(/[ \t\f\v\u00a0]+/g, " ")
|
|
70
|
+
.replace(/ *\n */g, "\n")
|
|
71
|
+
.replace(/\n{3,}/g, "\n\n");
|
|
72
|
+
return text.trim();
|
|
73
|
+
}
|
|
74
|
+
/** Cut text at `limit` characters, saying so. */
|
|
75
|
+
export function capText(text, limit) {
|
|
76
|
+
if (text.length <= limit)
|
|
77
|
+
return { text, truncated: false, limit_chars: limit };
|
|
78
|
+
return {
|
|
79
|
+
text: text.slice(0, limit),
|
|
80
|
+
truncated: true,
|
|
81
|
+
limit_chars: limit,
|
|
82
|
+
original_chars: text.length,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** A provider's content as capped plain text. */
|
|
86
|
+
export function contentText(content, limit) {
|
|
87
|
+
if (!content)
|
|
88
|
+
return undefined;
|
|
89
|
+
const text = content.content_type === "html"
|
|
90
|
+
? htmlToText(content.content)
|
|
91
|
+
: content.content.replace(/\r\n?/g, "\n").trim();
|
|
92
|
+
return capText(text, limit);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/productivity/content.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAY7C,MAAM,QAAQ,GAA2B;IACvC,GAAG,EAAE,GAAG;IACR,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;CACR,CAAC;AAEF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CACjB,uCAAuC,EACvC,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QACxB,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,MAAM,IAAI,GACR,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;gBACpC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAA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,IAAI,EAAE,CAAC;IACrD,OAAO,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** The kinds of item the model addresses by handle, with their prefixes. */
|
|
2
|
+
declare const PREFIXES: {
|
|
3
|
+
readonly message: "msg_";
|
|
4
|
+
readonly thread: "thr_";
|
|
5
|
+
readonly attachment: "att_";
|
|
6
|
+
readonly event: "evt_";
|
|
7
|
+
readonly file: "file_";
|
|
8
|
+
readonly cursor: "cur_";
|
|
9
|
+
};
|
|
10
|
+
export type ProductivityHandleKind = keyof typeof PREFIXES;
|
|
11
|
+
/** A message: its provider id, and the draft id when the session created it as a draft. */
|
|
12
|
+
export interface MessageIdentity {
|
|
13
|
+
id: string;
|
|
14
|
+
thread_id?: string;
|
|
15
|
+
/** Set only for a draft this session created; `mail send` requires it. */
|
|
16
|
+
draft_id?: string;
|
|
17
|
+
}
|
|
18
|
+
interface AttachmentIdentity {
|
|
19
|
+
message_id: string;
|
|
20
|
+
attachment_id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
/** Where a listing resumes: the provider's cursor, and items it returned past the last page's limit. */
|
|
24
|
+
export interface CursorState<T = unknown> {
|
|
25
|
+
value?: string;
|
|
26
|
+
overflow: readonly T[];
|
|
27
|
+
}
|
|
28
|
+
interface FileIdentity {
|
|
29
|
+
id: string;
|
|
30
|
+
is_folder?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface Identities {
|
|
33
|
+
message: MessageIdentity;
|
|
34
|
+
thread: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
attachment: AttachmentIdentity;
|
|
38
|
+
event: {
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
file: FileIdentity;
|
|
42
|
+
cursor: CursorState & {
|
|
43
|
+
scope: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** A handle the session never minted, or of the wrong kind: the model's input, refused before any provider call. */
|
|
47
|
+
export declare class ProductivityHandleError extends Error {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Session-scoped opaque handles for one person's connection.
|
|
51
|
+
*
|
|
52
|
+
* The model sees only handles minted here, from items a command returned, so
|
|
53
|
+
* it cannot act on a message, event or file it was never shown, and a
|
|
54
|
+
* provider id it read in a body or invented resolves to nothing. Handles die
|
|
55
|
+
* with the session.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ProductivityHandleStore {
|
|
58
|
+
private readonly items;
|
|
59
|
+
private readonly byIdentity;
|
|
60
|
+
/** The handle for an item, the same one each time the item comes back. */
|
|
61
|
+
handle<K extends Exclude<ProductivityHandleKind, "cursor">>(kind: K, identity: Identities[K]): string;
|
|
62
|
+
/** Point an existing handle at an item's new identity (an Outlook move changes the id). */
|
|
63
|
+
rebind<K extends Exclude<ProductivityHandleKind, "cursor">>(kind: K, handle: string, identity: Identities[K]): void;
|
|
64
|
+
/** Drop a handle: its item is gone (a sent draft, a deleted message). */
|
|
65
|
+
forget(handle: string): void;
|
|
66
|
+
/** Where a listing resumes, wrapped in a handle valid only for the same command and arguments. */
|
|
67
|
+
cursor(state: CursorState, scope: string): string;
|
|
68
|
+
resolveCursor<T = unknown>(handle: string, scope: string): CursorState<T>;
|
|
69
|
+
resolve<K extends ProductivityHandleKind>(kind: K, handle: unknown): Identities[K];
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=handles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/productivity/handles.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,QAAA,MAAM,QAAQ;aACZ,OAAO,EAAE,MAAM;aACf,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,KAAK,EAAE,MAAM;aACb,IAAI,EAAE,OAAO;aACb,MAAM,EAAE,MAAM;CACN,CAAC;AAEX,MAA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2FAA2F;IAC3F,MAAM,CAAC,CAAC,SAAS,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EACxD,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACtB,IAAI,CAQN;IAED,yEAAyE;IACzE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAK3B;IAED,kGAAkG;IAClG,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhD;IAED,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAQxE;IAED,OAAO,CAAC,CAAC,SAAS,sBAAsB,EACtC,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,OAAO,GACd,UAAU,CAAC,CAAC,CAAC,CAcf;CACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
/** The kinds of item the model addresses by handle, with their prefixes. */
|
|
3
|
+
const PREFIXES = {
|
|
4
|
+
message: "msg_",
|
|
5
|
+
thread: "thr_",
|
|
6
|
+
attachment: "att_",
|
|
7
|
+
event: "evt_",
|
|
8
|
+
file: "file_",
|
|
9
|
+
cursor: "cur_",
|
|
10
|
+
};
|
|
11
|
+
const NAMES = {
|
|
12
|
+
message: "message",
|
|
13
|
+
thread: "thread",
|
|
14
|
+
attachment: "attachment",
|
|
15
|
+
event: "event",
|
|
16
|
+
file: "file",
|
|
17
|
+
cursor: "cursor",
|
|
18
|
+
};
|
|
19
|
+
/** A handle the session never minted, or of the wrong kind: the model's input, refused before any provider call. */
|
|
20
|
+
export class ProductivityHandleError extends Error {
|
|
21
|
+
}
|
|
22
|
+
function mint(prefix) {
|
|
23
|
+
return `${prefix}${randomUUID().replaceAll("-", "").slice(0, 16)}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Session-scoped opaque handles for one person's connection.
|
|
27
|
+
*
|
|
28
|
+
* The model sees only handles minted here, from items a command returned, so
|
|
29
|
+
* it cannot act on a message, event or file it was never shown, and a
|
|
30
|
+
* provider id it read in a body or invented resolves to nothing. Handles die
|
|
31
|
+
* with the session.
|
|
32
|
+
*/
|
|
33
|
+
export class ProductivityHandleStore {
|
|
34
|
+
items = new Map();
|
|
35
|
+
byIdentity = new Map();
|
|
36
|
+
/** The handle for an item, the same one each time the item comes back. */
|
|
37
|
+
handle(kind, identity) {
|
|
38
|
+
const key = JSON.stringify([kind, identityKey(kind, identity)]);
|
|
39
|
+
const existing = this.byIdentity.get(key);
|
|
40
|
+
if (existing) {
|
|
41
|
+
const previous = this.items.get(existing);
|
|
42
|
+
this.items.set(existing, merge(kind, previous, identity));
|
|
43
|
+
return existing;
|
|
44
|
+
}
|
|
45
|
+
const handle = mint(PREFIXES[kind]);
|
|
46
|
+
this.items.set(handle, identity);
|
|
47
|
+
this.byIdentity.set(key, handle);
|
|
48
|
+
return handle;
|
|
49
|
+
}
|
|
50
|
+
/** Point an existing handle at an item's new identity (an Outlook move changes the id). */
|
|
51
|
+
rebind(kind, handle, identity) {
|
|
52
|
+
const previous = this.resolve(kind, handle);
|
|
53
|
+
const updated = merge(kind, previous, identity);
|
|
54
|
+
this.items.set(handle, updated);
|
|
55
|
+
this.byIdentity.set(JSON.stringify([kind, identityKey(kind, updated)]), handle);
|
|
56
|
+
}
|
|
57
|
+
/** Drop a handle: its item is gone (a sent draft, a deleted message). */
|
|
58
|
+
forget(handle) {
|
|
59
|
+
this.items.delete(handle);
|
|
60
|
+
for (const [key, value] of this.byIdentity) {
|
|
61
|
+
if (value === handle)
|
|
62
|
+
this.byIdentity.delete(key);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Where a listing resumes, wrapped in a handle valid only for the same command and arguments. */
|
|
66
|
+
cursor(state, scope) {
|
|
67
|
+
const handle = mint(PREFIXES.cursor);
|
|
68
|
+
this.items.set(handle, { ...state, scope });
|
|
69
|
+
return handle;
|
|
70
|
+
}
|
|
71
|
+
resolveCursor(handle, scope) {
|
|
72
|
+
const { scope: owner, ...state } = this.resolve("cursor", handle);
|
|
73
|
+
if (owner !== scope) {
|
|
74
|
+
throw new ProductivityHandleError(`Cursor '${handle}' belongs to another search. Repeat the original arguments with it.`);
|
|
75
|
+
}
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
78
|
+
resolve(kind, handle) {
|
|
79
|
+
const name = NAMES[kind];
|
|
80
|
+
if (typeof handle !== "string" || !handle.startsWith(PREFIXES[kind])) {
|
|
81
|
+
throw new ProductivityHandleError(`Expected a ${name} handle (${PREFIXES[kind]}…) returned by a tool in this session.`);
|
|
82
|
+
}
|
|
83
|
+
const identity = this.items.get(handle);
|
|
84
|
+
if (identity === undefined) {
|
|
85
|
+
throw new ProductivityHandleError(`Unknown ${name} handle '${handle}'. Use a handle a tool returned in this session.`);
|
|
86
|
+
}
|
|
87
|
+
return identity;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function identityKey(kind, identity) {
|
|
91
|
+
if (kind === "attachment") {
|
|
92
|
+
const attachment = identity;
|
|
93
|
+
return [attachment.message_id, attachment.attachment_id];
|
|
94
|
+
}
|
|
95
|
+
return identity.id;
|
|
96
|
+
}
|
|
97
|
+
function merge(kind, previous, next) {
|
|
98
|
+
if (kind !== "message")
|
|
99
|
+
return { ...previous, ...next };
|
|
100
|
+
const before = previous;
|
|
101
|
+
const after = next;
|
|
102
|
+
return {
|
|
103
|
+
...before,
|
|
104
|
+
...after,
|
|
105
|
+
// Authorship of a draft is never lost because a search returned it again.
|
|
106
|
+
...((after.draft_id ?? before.draft_id)
|
|
107
|
+
? { draft_id: after.draft_id ?? before.draft_id }
|
|
108
|
+
: {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=handles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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U,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,CAAC;IACD,OAAQ,QAA2B,CAAC,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,KAAK,CAAI,IAA4B,EAAE,QAAW,EAAE,IAAO;IAClE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,QAA2B,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAuB,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,KAAK;QACR,0EAA0E;QAC1E,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjD,CAAC,CAAC,EAAE,CAAC;KACH,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Tracer } from "@opentelemetry/api";
|
|
2
|
+
import type { ProductivityFetch, ProductivityHttp } from "./types.js";
|
|
3
|
+
/** Sent where a provider expects a token; the egress replaces it with the person's. */
|
|
4
|
+
export declare const PRODUCTIVITY_EGRESS_TOKEN = "introspection-egress";
|
|
5
|
+
/** The attribute a JSON response body is recorded under, as the tool result itself is. */
|
|
6
|
+
export declare const RESPONSE_BODY_ATTRIBUTE = "gen_ai.tool.call.result";
|
|
7
|
+
/** The API's own id for the method called, such as `gmail.users.messages.get`. */
|
|
8
|
+
export declare const OPERATION_ID_ATTRIBUTE = "introspection.api.operation_id";
|
|
9
|
+
/** The largest response body recorded on a span; a larger one records its size only. */
|
|
10
|
+
export declare const MAX_RECORDED_BODY_BYTES: number;
|
|
11
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
12
|
+
export interface ProductivityHttpOptions {
|
|
13
|
+
/** Names the spans' instrumentation scope: `@introspection-ai/recipe-productivity-<provider>`. */
|
|
14
|
+
provider: string;
|
|
15
|
+
env?: Env;
|
|
16
|
+
/** A host's request hook, which attaches the person's credential itself. */
|
|
17
|
+
fetch?: ProductivityFetch;
|
|
18
|
+
/** Injected so tests do not wait out a backoff. */
|
|
19
|
+
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
20
|
+
/** Default: the globally registered tracer. */
|
|
21
|
+
tracer?: Tracer;
|
|
22
|
+
}
|
|
23
|
+
/** Seconds from a `Retry-After` header: delta-seconds or an HTTP date. */
|
|
24
|
+
export declare function retryAfterSeconds(value: string | null | undefined, now?: number): number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The HTTP a provider sends through: the placeholder credential, one client
|
|
27
|
+
* span per attempt (a child of the tool call's span, recording a JSON body
|
|
28
|
+
* but never a header, path or query), and a read retried while the provider
|
|
29
|
+
* is throttled, after `Retry-After` or a backoff of 1, 2 and 4 seconds. A
|
|
30
|
+
* write is sent once. A failed answer comes back as it is, its body readable,
|
|
31
|
+
* for the provider to map.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createProductivityHttp(options: ProductivityHttpOptions): ProductivityHttp;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/productivity/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAIpB,uFAAuF;AACvF,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAEhE,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAWlD,KAAK,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAExD,MAAM,WAAW,uBAAuB;IACtC,kGAAkG;IAClG,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,4EAA4E;IAC5E,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,mDAAmD;IACnD,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAqBD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,SAAa,GACf,MAAM,GAAG,SAAS,CAGpB;AA6GD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CA8FlB"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { setTimeout as sleepFor } from "node:timers/promises";
|
|
2
|
+
import { SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
|
|
3
|
+
import { egressCredentialLane, parseRetryAfter } from "../egress.js";
|
|
4
|
+
/** Sent where a provider expects a token; the egress replaces it with the person's. */
|
|
5
|
+
export const PRODUCTIVITY_EGRESS_TOKEN = "introspection-egress";
|
|
6
|
+
/** The attribute a JSON response body is recorded under, as the tool result itself is. */
|
|
7
|
+
export const RESPONSE_BODY_ATTRIBUTE = "gen_ai.tool.call.result";
|
|
8
|
+
/** The API's own id for the method called, such as `gmail.users.messages.get`. */
|
|
9
|
+
export const OPERATION_ID_ATTRIBUTE = "introspection.api.operation_id";
|
|
10
|
+
/** The largest response body recorded on a span; a larger one records its size only. */
|
|
11
|
+
export const MAX_RECORDED_BODY_BYTES = 256 * 1024;
|
|
12
|
+
/** Retries of a throttled read, after the first attempt. */
|
|
13
|
+
const MAX_RETRIES = 3;
|
|
14
|
+
/** The longest wait slept through; a longer one comes back to the provider. */
|
|
15
|
+
const MAX_WAIT_MS = 30_000;
|
|
16
|
+
/** Statuses a read is retried on, beyond what the provider adds with `throttled`. */
|
|
17
|
+
const RETRIED_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
18
|
+
/**
|
|
19
|
+
* The `Authorization` a request leaving the sandbox carries: the placeholder
|
|
20
|
+
* the egress (or a host's hook) replaces, or the session locator the provider
|
|
21
|
+
* listener exchanges for the token.
|
|
22
|
+
*/
|
|
23
|
+
function productivityAuthorization(env, hostAttachesCredential) {
|
|
24
|
+
const lane = egressCredentialLane(env);
|
|
25
|
+
if (hostAttachesCredential || lane?.kind === "proxy_native")
|
|
26
|
+
return `Bearer ${PRODUCTIVITY_EGRESS_TOKEN}`;
|
|
27
|
+
if (!lane)
|
|
28
|
+
throw new Error("Productivity tools need the Introspection cloud egress, or a host that attaches the person's credential. Use introspection dev to test them.");
|
|
29
|
+
return `Bearer ${lane.locator}`;
|
|
30
|
+
}
|
|
31
|
+
/** Seconds from a `Retry-After` header: delta-seconds or an HTTP date. */
|
|
32
|
+
export function retryAfterSeconds(value, now = Date.now()) {
|
|
33
|
+
const seconds = parseRetryAfter(value, now);
|
|
34
|
+
return seconds === undefined ? undefined : Math.max(0, seconds);
|
|
35
|
+
}
|
|
36
|
+
/** The span name and start attributes for one request, after the HTTP client conventions. */
|
|
37
|
+
function httpRequestSpan(request) {
|
|
38
|
+
const attributes = { "http.request.method": request.method };
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(request.url);
|
|
41
|
+
attributes["server.address"] = url.hostname;
|
|
42
|
+
const port = url.port ||
|
|
43
|
+
(url.protocol === "https:"
|
|
44
|
+
? "443"
|
|
45
|
+
: url.protocol === "http:"
|
|
46
|
+
? "80"
|
|
47
|
+
: "");
|
|
48
|
+
if (port)
|
|
49
|
+
attributes["server.port"] = Number(port);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// The fetch reports a malformed URL.
|
|
53
|
+
}
|
|
54
|
+
if (request.template)
|
|
55
|
+
attributes["url.template"] = request.template;
|
|
56
|
+
if (request.operation)
|
|
57
|
+
attributes[OPERATION_ID_ATTRIBUTE] = request.operation;
|
|
58
|
+
return {
|
|
59
|
+
name: request.template
|
|
60
|
+
? `${request.method} ${request.template}`
|
|
61
|
+
: request.method,
|
|
62
|
+
attributes,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Keys whose value is a link that carries its own credential. */
|
|
66
|
+
const CREDENTIAL_KEYS = /^(uploadUrl|@microsoft\.graph\.downloadUrl|downloadUrl)$/i;
|
|
67
|
+
/** Query parameters that make a URL a credential. */
|
|
68
|
+
const CREDENTIAL_QUERY = /[?&](tempauth|sig|signature|token|access_token|x-amz-signature|x-goog-signature|x-goog-credential)=/i;
|
|
69
|
+
const REDACTED = "[redacted]";
|
|
70
|
+
/** A JSON body with every pre-authenticated link replaced, or undefined when it is not JSON. */
|
|
71
|
+
function redactedBody(text) {
|
|
72
|
+
let parsed;
|
|
73
|
+
try {
|
|
74
|
+
parsed = JSON.parse(text);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const redact = (value, key) => {
|
|
80
|
+
if (typeof value === "string")
|
|
81
|
+
return (key !== undefined && CREDENTIAL_KEYS.test(key)) ||
|
|
82
|
+
CREDENTIAL_QUERY.test(value)
|
|
83
|
+
? REDACTED
|
|
84
|
+
: value;
|
|
85
|
+
if (Array.isArray(value))
|
|
86
|
+
return value.map((item) => redact(item));
|
|
87
|
+
if (value && typeof value === "object")
|
|
88
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redact(v, k)]));
|
|
89
|
+
return value;
|
|
90
|
+
};
|
|
91
|
+
return JSON.stringify(redact(parsed));
|
|
92
|
+
}
|
|
93
|
+
/** The attributes a response adds: its status and, when recorded, its redacted JSON body up to the cap. */
|
|
94
|
+
function httpResponseAttributes(status, body, record = false) {
|
|
95
|
+
const attributes = { "http.response.status_code": status };
|
|
96
|
+
if (status >= 400)
|
|
97
|
+
attributes["error.type"] = String(status);
|
|
98
|
+
if (body !== undefined) {
|
|
99
|
+
const size = Buffer.byteLength(body);
|
|
100
|
+
attributes["http.response.body.size"] = size;
|
|
101
|
+
const recorded = record && size <= MAX_RECORDED_BODY_BYTES
|
|
102
|
+
? redactedBody(body)
|
|
103
|
+
: undefined;
|
|
104
|
+
if (recorded !== undefined)
|
|
105
|
+
attributes[RESPONSE_BODY_ATTRIBUTE] = recorded;
|
|
106
|
+
}
|
|
107
|
+
return attributes;
|
|
108
|
+
}
|
|
109
|
+
function isJson(response) {
|
|
110
|
+
const type = response.headers.get("Content-Type")?.toLowerCase() ?? "";
|
|
111
|
+
return type.includes("application/json") || type.includes("+json");
|
|
112
|
+
}
|
|
113
|
+
/** A response whose body was read once, served again byte for byte. */
|
|
114
|
+
function buffered(response, bytes, text) {
|
|
115
|
+
return {
|
|
116
|
+
ok: response.ok,
|
|
117
|
+
status: response.status,
|
|
118
|
+
headers: response.headers,
|
|
119
|
+
text: async () => text,
|
|
120
|
+
json: async () => JSON.parse(text),
|
|
121
|
+
arrayBuffer: async () => bytes.slice().buffer,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The HTTP a provider sends through: the placeholder credential, one client
|
|
126
|
+
* span per attempt (a child of the tool call's span, recording a JSON body
|
|
127
|
+
* but never a header, path or query), and a read retried while the provider
|
|
128
|
+
* is throttled, after `Retry-After` or a backoff of 1, 2 and 4 seconds. A
|
|
129
|
+
* write is sent once. A failed answer comes back as it is, its body readable,
|
|
130
|
+
* for the provider to map.
|
|
131
|
+
*/
|
|
132
|
+
export function createProductivityHttp(options) {
|
|
133
|
+
const env = options.env ?? process.env;
|
|
134
|
+
const fetchImpl = options.fetch ??
|
|
135
|
+
((url, init) => globalThis.fetch(url, init));
|
|
136
|
+
const sleep = options.sleep ??
|
|
137
|
+
(async (ms, signal) => {
|
|
138
|
+
await sleepFor(ms, undefined, { signal });
|
|
139
|
+
});
|
|
140
|
+
const tracer = options.tracer ??
|
|
141
|
+
trace.getTracer(`@introspection-ai/recipe-productivity-${options.provider}`);
|
|
142
|
+
async function attempt(request) {
|
|
143
|
+
const headers = request.anonymous
|
|
144
|
+
? { ...request.headers }
|
|
145
|
+
: {
|
|
146
|
+
...request.headers,
|
|
147
|
+
Authorization: productivityAuthorization(env, options.fetch !== undefined),
|
|
148
|
+
};
|
|
149
|
+
const { name, attributes } = httpRequestSpan(request);
|
|
150
|
+
const span = tracer.startSpan(name, { kind: SpanKind.CLIENT, attributes });
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetchImpl(request.url, {
|
|
153
|
+
method: request.method,
|
|
154
|
+
headers,
|
|
155
|
+
...(request.body !== undefined ? { body: request.body } : {}),
|
|
156
|
+
redirect: request.redirect ?? "error",
|
|
157
|
+
...(request.signal ? { signal: request.signal } : {}),
|
|
158
|
+
});
|
|
159
|
+
if (response.status >= 400)
|
|
160
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
161
|
+
if (!isJson(response) && response.ok) {
|
|
162
|
+
span.setAttributes(httpResponseAttributes(response.status));
|
|
163
|
+
return response;
|
|
164
|
+
}
|
|
165
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
166
|
+
const text = new TextDecoder().decode(bytes);
|
|
167
|
+
span.setAttributes(httpResponseAttributes(response.status, isJson(response) ? text : undefined, request.record ?? request.read === true));
|
|
168
|
+
return buffered(response, bytes, text);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
span.setAttribute("error.type", error instanceof Error && error.name ? error.name : "_OTHER");
|
|
172
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
span.end();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return async (request) => {
|
|
180
|
+
for (let retries = 0;; retries += 1) {
|
|
181
|
+
const response = await attempt(request);
|
|
182
|
+
const retryAfter = retryAfterSeconds(response.headers.get("Retry-After"));
|
|
183
|
+
const answered = {
|
|
184
|
+
ok: response.ok,
|
|
185
|
+
status: response.status,
|
|
186
|
+
headers: response.headers,
|
|
187
|
+
text: () => response.text(),
|
|
188
|
+
json: () => response.json(),
|
|
189
|
+
arrayBuffer: () => response.arrayBuffer(),
|
|
190
|
+
...(retryAfter !== undefined ? { retryAfterSeconds: retryAfter } : {}),
|
|
191
|
+
};
|
|
192
|
+
if (response.ok || !request.read || retries >= MAX_RETRIES)
|
|
193
|
+
return answered;
|
|
194
|
+
const throttled = RETRIED_STATUSES.has(response.status) ||
|
|
195
|
+
(request.throttled?.(response.status, await response.text()) ?? false);
|
|
196
|
+
const waitMs = retryAfter !== undefined ? retryAfter * 1000 : 1000 * 2 ** retries;
|
|
197
|
+
if (!throttled || waitMs > MAX_WAIT_MS)
|
|
198
|
+
return answered;
|
|
199
|
+
await sleep(waitMs, request.signal);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/productivity/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,GAGN,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAUrE,uFAAuF;AACvF,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE,0FAA0F;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,kFAAkF;AAClF,MAAM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C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { loadRecipeProductivity, PRODUCTIVITY_MODULE_API_VERSION, PRODUCTIVITY_SKILL, productivityDownloadRoot, } from "./module.js";
|
|
2
|
+
export type { LoadedRecipeProductivity, RecipeProductivityModule, } from "./module.js";
|
|
3
|
+
export { PRODUCTIVITY_FILE_LIMIT_BYTES, productivityCapabilitiesProblem, productivityCommandsFor, registerProductivityTools, } from "./tools.js";
|
|
4
|
+
export type { ProductivityToolHost, RegisterProductivityToolsOptions, } from "./tools.js";
|
|
5
|
+
export { ProductivityHandleStore } from "./handles.js";
|
|
6
|
+
export { createProductivityHttp, MAX_RECORDED_BODY_BYTES, OPERATION_ID_ATTRIBUTE, PRODUCTIVITY_EGRESS_TOKEN, RESPONSE_BODY_ATTRIBUTE, retryAfterSeconds, } from "./http.js";
|
|
7
|
+
export type { ProductivityHttpOptions } from "./http.js";
|
|
8
|
+
export { BODY_LIMIT_CHARS, capText, contentText, FILE_TEXT_LIMIT_CHARS, htmlToText, } from "./content.js";
|
|
9
|
+
export type { ProductivityText } from "./content.js";
|
|
10
|
+
export * from "./types.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/productivity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,oBAAoB,EACpB,gCAAgC,GACjC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { loadRecipeProductivity, PRODUCTIVITY_MODULE_API_VERSION, PRODUCTIVITY_SKILL, productivityDownloadRoot, } from "./module.js";
|
|
2
|
+
export { PRODUCTIVITY_FILE_LIMIT_BYTES, productivityCapabilitiesProblem, productivityCommandsFor, registerProductivityTools, } from "./tools.js";
|
|
3
|
+
export { ProductivityHandleStore } from "./handles.js";
|
|
4
|
+
export { createProductivityHttp, MAX_RECORDED_BODY_BYTES, OPERATION_ID_ATTRIBUTE, PRODUCTIVITY_EGRESS_TOKEN, RESPONSE_BODY_ATTRIBUTE, retryAfterSeconds, } from "./http.js";
|
|
5
|
+
export { BODY_LIMIT_CHARS, capText, contentText, FILE_TEXT_LIMIT_CHARS, htmlToText, } from "./content.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/productivity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,cAAc,YAAY,CAAC"}
|