@getfamiliar/shared 0.1.2

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 (83) hide show
  1. package/build/AgentRun.d.ts +187 -0
  2. package/build/AgentRun.js +1 -0
  3. package/build/AgentRunBus.d.ts +147 -0
  4. package/build/AgentRunBus.js +362 -0
  5. package/build/Calendar.d.ts +450 -0
  6. package/build/Calendar.js +37 -0
  7. package/build/ChatMessage.d.ts +53 -0
  8. package/build/ChatMessage.js +11 -0
  9. package/build/ChatMessageBus.d.ts +110 -0
  10. package/build/ChatMessageBus.js +257 -0
  11. package/build/Config.d.ts +83 -0
  12. package/build/Config.js +1 -0
  13. package/build/ContainerTool.d.ts +34 -0
  14. package/build/ContainerTool.js +1 -0
  15. package/build/CronExpression.d.ts +53 -0
  16. package/build/CronExpression.js +77 -0
  17. package/build/Event.d.ts +280 -0
  18. package/build/Event.js +14 -0
  19. package/build/EventBus.d.ts +198 -0
  20. package/build/EventBus.js +482 -0
  21. package/build/HandlerCatalog.d.ts +75 -0
  22. package/build/HandlerCatalog.js +165 -0
  23. package/build/InferenceEvent.d.ts +30 -0
  24. package/build/InferenceEvent.js +1 -0
  25. package/build/InferenceEventBus.d.ts +39 -0
  26. package/build/InferenceEventBus.js +80 -0
  27. package/build/Mail.d.ts +250 -0
  28. package/build/Mail.js +73 -0
  29. package/build/MailStyleTemplate.d.ts +71 -0
  30. package/build/MailStyleTemplate.js +47 -0
  31. package/build/ModelMetaData.d.ts +63 -0
  32. package/build/ModelMetaData.js +12 -0
  33. package/build/PathGlob.d.ts +20 -0
  34. package/build/PathGlob.js +33 -0
  35. package/build/Plugin.d.ts +709 -0
  36. package/build/Plugin.js +29 -0
  37. package/build/PostgresConnection.d.ts +75 -0
  38. package/build/PostgresConnection.js +162 -0
  39. package/build/ScheduledSubagent.d.ts +49 -0
  40. package/build/ScheduledSubagent.js +1 -0
  41. package/build/ScheduledSubagentBus.d.ts +94 -0
  42. package/build/ScheduledSubagentBus.js +187 -0
  43. package/build/Schema.d.ts +84 -0
  44. package/build/Schema.js +570 -0
  45. package/build/StepResult.d.ts +103 -0
  46. package/build/StepResult.js +1 -0
  47. package/build/StepResultBus.d.ts +64 -0
  48. package/build/StepResultBus.js +169 -0
  49. package/build/Timezone.d.ts +58 -0
  50. package/build/Timezone.js +84 -0
  51. package/build/ToolCall.d.ts +25 -0
  52. package/build/ToolCall.js +1 -0
  53. package/build/ToolCallBus.d.ts +65 -0
  54. package/build/ToolCallBus.js +110 -0
  55. package/build/ToolLevel.d.ts +20 -0
  56. package/build/ToolLevel.js +2 -0
  57. package/build/ToolRunner.d.ts +118 -0
  58. package/build/ToolRunner.js +192 -0
  59. package/build/ToolsExpressionUtils.d.ts +80 -0
  60. package/build/ToolsExpressionUtils.js +102 -0
  61. package/build/WorkspaceFile.d.ts +104 -0
  62. package/build/WorkspaceFile.js +7 -0
  63. package/build/estimateTokens.d.ts +16 -0
  64. package/build/estimateTokens.js +18 -0
  65. package/build/index.d.ts +37 -0
  66. package/build/index.js +26 -0
  67. package/build/logging/Logger.d.ts +66 -0
  68. package/build/logging/Logger.js +90 -0
  69. package/build/markdownHtml.d.ts +14 -0
  70. package/build/markdownHtml.js +21 -0
  71. package/build/markdownTerminal.d.ts +14 -0
  72. package/build/markdownTerminal.js +376 -0
  73. package/build/testing/MockAgentRunBus.d.ts +52 -0
  74. package/build/testing/MockAgentRunBus.js +175 -0
  75. package/build/testing/MockBusStore.d.ts +22 -0
  76. package/build/testing/MockBusStore.js +22 -0
  77. package/build/testing/MockEventBus.d.ts +20 -0
  78. package/build/testing/MockEventBus.js +57 -0
  79. package/build/testing/MockLogger.d.ts +52 -0
  80. package/build/testing/MockLogger.js +65 -0
  81. package/build/testing/index.d.ts +4 -0
  82. package/build/testing/index.js +4 -0
  83. package/package.json +63 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Per-mailbox styling commands the send path applies to every outgoing
3
+ * mail. Two extracted fields (signature, textStyle) plus three booleans
4
+ * that capture per-kind habits (whether the signature should be appended
5
+ * on replies / forwards, and whether the user predominantly writes
6
+ * plain text).
7
+ *
8
+ * Named `MailStyleTemplate` (not `MailTemplate`) because the JSON
9
+ * carries styling commands, not a full template body — the word
10
+ * "template" alone over-claims.
11
+ *
12
+ * Storage is provider-agnostic: the file lives at
13
+ * `data/mail/templates/<mailbox>/<name>.json` so a future Gmail / IMAP
14
+ * provider can write its own templates without colliding with ms365.
15
+ */
16
+ export interface MailStyleTemplate {
17
+ /**
18
+ * HTML fragment — the user's signature block as Outlook stamps it
19
+ * onto sent mail. No `<html>`/`<head>`/`<body>` wrapper; the send
20
+ * path appends this verbatim at the end of the rendered body.
21
+ */
22
+ readonly signature: string;
23
+ /**
24
+ * CSS declarations the user's mails use by default, packed into a
25
+ * single attribute-ready string (e.g.
26
+ * `"font-family: Calibri; font-size: 11pt; color: #1f1f1f"`).
27
+ * Injected as a `style="…"` attribute on every block-level element
28
+ * the markdown→HTML renderer emits, since most clients ignore
29
+ * `<style>` blocks and require inline styling per element.
30
+ */
31
+ readonly textStyle: string;
32
+ /**
33
+ * Dominant `body.contentType` across the user's sampled Sent mails.
34
+ * `true` when the user predominantly writes plain text — the send
35
+ * path then ships new mails with `body.contentType: "Text"` and
36
+ * the raw markdown body (markdown reads fine as plain text).
37
+ */
38
+ readonly usePlainText: boolean;
39
+ /**
40
+ * True when the signature appears in ≥ half of the user's reply
41
+ * samples. Drives whether the send path appends the signature on
42
+ * reply paths. Empty reply bucket ⇒ `false` (no evidence; default
43
+ * to "don't sign").
44
+ */
45
+ readonly useSignatureOnReplies: boolean;
46
+ /** Same as {@link useSignatureOnReplies} for the forward bucket. */
47
+ readonly useSignatureOnForwards: boolean;
48
+ }
49
+ /** Defaults applied when a `mailstyle_update` call creates a new file. */
50
+ export declare const MAIL_STYLE_TEMPLATE_DEFAULTS: MailStyleTemplate;
51
+ /**
52
+ * Absolute path of a per-mailbox style template. `name` defaults to
53
+ * `"default"` — that's the single template every mailbox always has.
54
+ * Multi-template support (e.g. business vs. personal signature) plugs
55
+ * in by passing a different name; the directory layout is already
56
+ * forward-compatible.
57
+ */
58
+ export declare function mailStyleTemplatePath(dataDir: string, mailbox: string, name?: string): string;
59
+ /**
60
+ * Strip an HTML signature fragment down to a plain-text rendition the
61
+ * `usePlainText` new-mail branch can append below the markdown body.
62
+ * Three regex passes:
63
+ * 1. `<br>` and `</p>` / `</div>` / `</li>` close-tags become a single
64
+ * newline so paragraph and list-item structure survives.
65
+ * 2. Every remaining tag is dropped.
66
+ * 3. The five common HTML entities are decoded.
67
+ * Trailing whitespace on each line is trimmed and runs of 3+ blank
68
+ * lines are collapsed to a single blank line so the result reads
69
+ * cleanly in a plain-text mail body.
70
+ */
71
+ export declare function signatureToPlainText(html: string): string;
@@ -0,0 +1,47 @@
1
+ import path from "node:path";
2
+ /** Defaults applied when a `mailstyle_update` call creates a new file. */
3
+ export const MAIL_STYLE_TEMPLATE_DEFAULTS = {
4
+ signature: "",
5
+ textStyle: "",
6
+ usePlainText: false,
7
+ useSignatureOnReplies: false,
8
+ useSignatureOnForwards: false,
9
+ };
10
+ /**
11
+ * Absolute path of a per-mailbox style template. `name` defaults to
12
+ * `"default"` — that's the single template every mailbox always has.
13
+ * Multi-template support (e.g. business vs. personal signature) plugs
14
+ * in by passing a different name; the directory layout is already
15
+ * forward-compatible.
16
+ */
17
+ export function mailStyleTemplatePath(dataDir, mailbox, name = "default") {
18
+ return path.join(dataDir, "mail", "templates", mailbox, `${name}.json`);
19
+ }
20
+ /**
21
+ * Strip an HTML signature fragment down to a plain-text rendition the
22
+ * `usePlainText` new-mail branch can append below the markdown body.
23
+ * Three regex passes:
24
+ * 1. `<br>` and `</p>` / `</div>` / `</li>` close-tags become a single
25
+ * newline so paragraph and list-item structure survives.
26
+ * 2. Every remaining tag is dropped.
27
+ * 3. The five common HTML entities are decoded.
28
+ * Trailing whitespace on each line is trimmed and runs of 3+ blank
29
+ * lines are collapsed to a single blank line so the result reads
30
+ * cleanly in a plain-text mail body.
31
+ */
32
+ export function signatureToPlainText(html) {
33
+ const withBreaks = html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/(p|div|li|tr)>/gi, "\n");
34
+ const stripped = withBreaks.replace(/<[^>]+>/g, "");
35
+ const decoded = stripped
36
+ .replace(/&nbsp;/g, " ")
37
+ .replace(/&amp;/g, "&")
38
+ .replace(/&lt;/g, "<")
39
+ .replace(/&gt;/g, ">")
40
+ .replace(/&quot;/g, '"');
41
+ return decoded
42
+ .split("\n")
43
+ .map((line) => line.replace(/\s+$/g, ""))
44
+ .join("\n")
45
+ .replace(/\n{3,}/g, "\n\n")
46
+ .trim();
47
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Capability metadata for a single inference model, normalized across
3
+ * every source that can supply it (the models.dev database baked into
4
+ * the host, or a plugin's {@link PluginHostManifest.getModelMetaData}
5
+ * hook). Every field is optional because no single source fills them
6
+ * all — featherless, for instance, exposes no `reasoning` flag, while
7
+ * models.dev carries `npm` / `api` at the provider level rather than
8
+ * per model.
9
+ *
10
+ * The host assembles this shape and the container fetches it (through
11
+ * the bastion's `/model-metadata/` gateway) when an agentrun starts, so
12
+ * downstream code can reason about the running model's limits and
13
+ * capabilities.
14
+ */
15
+ export interface ModelMetaData {
16
+ /** npm package backing the model's SDK, e.g. `@ai-sdk/openai-compatible`. */
17
+ npmPackage?: string;
18
+ /** Upstream API base URL, e.g. `https://api.featherless.ai/v1`. */
19
+ apiEndpoint?: string;
20
+ /** Whether the model supports tool / function calling. */
21
+ toolCall?: boolean;
22
+ /** Whether the model is a reasoning model. */
23
+ reasoning?: boolean;
24
+ /** Maximum context window, in tokens. */
25
+ contextLimit?: number;
26
+ /** Maximum output length, in tokens. */
27
+ outputLimit?: number;
28
+ }
29
+ /**
30
+ * Provider-level descriptor a plugin returns from
31
+ * {@link PluginHostManifest.getModelProviders} to declare an inference
32
+ * provider it owns (one the models.dev database doesn't cover). The host
33
+ * uses it to wire the reverse proxy (auth + upstream base) and the
34
+ * container's model factory (which `create*` to call), keyed off
35
+ * {@link npmPackage}.
36
+ */
37
+ export interface ModelProviderDescriptor {
38
+ /**
39
+ * Provider key — the id used under `inference.apiKeys.<key>`, in
40
+ * `/llm/<key>/` proxy routes, and as the `model` prefix. Matches a
41
+ * models.dev provider id only when the plugin intentionally overrides
42
+ * one; otherwise it's a plugin-owned id like `featherless`.
43
+ */
44
+ readonly key: string;
45
+ /** npm package backing the provider's SDK, e.g. `@ai-sdk/openai-compatible`. */
46
+ readonly npmPackage: string;
47
+ /**
48
+ * Upstream API base URL the reverse proxy forwards to, e.g.
49
+ * `https://api.featherless.ai/v1`. Required for openai-compatible
50
+ * providers (no SDK default exists); for a provider whose npm package
51
+ * carries a built-in default base it may be omitted.
52
+ */
53
+ readonly apiEndpoint?: string;
54
+ }
55
+ /**
56
+ * Thrown by a {@link PluginHostManifest.getModelMetaData} hook when the
57
+ * plugin authoritatively owns the given provider and knows the model is
58
+ * not supported there. The host treats this as a definitive "no" and
59
+ * stops the lookup rather than consulting further plugins.
60
+ */
61
+ export declare class ModelNotSupported extends Error {
62
+ constructor(message: string);
63
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Thrown by a {@link PluginHostManifest.getModelMetaData} hook when the
3
+ * plugin authoritatively owns the given provider and knows the model is
4
+ * not supported there. The host treats this as a definitive "no" and
5
+ * stops the lookup rather than consulting further plugins.
6
+ */
7
+ export class ModelNotSupported extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "ModelNotSupported";
11
+ }
12
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Root-anchored `*`-glob matcher shared across the platform: the memory
3
+ * indexer's exclude list, the memory context provider's embed
4
+ * eligibility check, the container fs tools' `core.writablePaths`
5
+ * allowlist, and the handler-resolution guards all speak this same
6
+ * grammar.
7
+ *
8
+ * `*` stands for "any characters", everything else is literal. The
9
+ * pattern is **anchored at the workspace root** (the leading `^`): it
10
+ * matches from the start of the workspace-relative POSIX path, not as a
11
+ * floating substring. So `wiki/**` collapses to `^wiki/.*` and matches
12
+ * `wiki/<rest>` only — never `notwiki/secret.md`, which the old
13
+ * unanchored grammar would have falsely matched. A trailing `*` (as in
14
+ * `wiki/**`) keeps the tail open, so the end is intentionally not
15
+ * anchored. Always match against the workspace-relative POSIX path so a
16
+ * glob means the same thing at every call site.
17
+ */
18
+ export declare function matchesGlob(pattern: string, value: string): boolean;
19
+ /** Convenience: true iff `value` matches at least one of the patterns. */
20
+ export declare function matchesAnyGlob(patterns: readonly string[], value: string): boolean;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Root-anchored `*`-glob matcher shared across the platform: the memory
3
+ * indexer's exclude list, the memory context provider's embed
4
+ * eligibility check, the container fs tools' `core.writablePaths`
5
+ * allowlist, and the handler-resolution guards all speak this same
6
+ * grammar.
7
+ *
8
+ * `*` stands for "any characters", everything else is literal. The
9
+ * pattern is **anchored at the workspace root** (the leading `^`): it
10
+ * matches from the start of the workspace-relative POSIX path, not as a
11
+ * floating substring. So `wiki/**` collapses to `^wiki/.*` and matches
12
+ * `wiki/<rest>` only — never `notwiki/secret.md`, which the old
13
+ * unanchored grammar would have falsely matched. A trailing `*` (as in
14
+ * `wiki/**`) keeps the tail open, so the end is intentionally not
15
+ * anchored. Always match against the workspace-relative POSIX path so a
16
+ * glob means the same thing at every call site.
17
+ */
18
+ export function matchesGlob(pattern, value) {
19
+ if (pattern === "*" || pattern === "**") {
20
+ return true;
21
+ }
22
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
23
+ return new RegExp(`^${escaped}`).test(value);
24
+ }
25
+ /** Convenience: true iff `value` matches at least one of the patterns. */
26
+ export function matchesAnyGlob(patterns, value) {
27
+ for (const pattern of patterns) {
28
+ if (matchesGlob(pattern, value)) {
29
+ return true;
30
+ }
31
+ }
32
+ return false;
33
+ }