@usequeek/app-sdk 0.7.2 → 0.8.1

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.
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The `settings` entries of an app manifest (`manifest.json`, or `[[settings]]` in app.toml): the fields the merchant
3
+ * fills in when installing or managing the app. Queek validates them on registration and on every settings write.
4
+ */
5
+ /** The `type` of a manifest setting. A `secret` is write-only for the merchant and never shown back or exposed to an AI. */
6
+ export declare const MANIFEST_SETTING_TYPES: readonly ["string", "secret", "number", "boolean", "select"];
7
+ export type ManifestSettingType = (typeof MANIFEST_SETTING_TYPES)[number];
8
+ export interface ManifestSetting {
9
+ /** `[a-z0-9_]{1,64}`, unique among the app's settings. */
10
+ key: string;
11
+ label: string;
12
+ type: ManifestSettingType;
13
+ required?: boolean;
14
+ /** `select` only: the allowed values. */
15
+ options?: string[];
16
+ help?: string;
17
+ /**
18
+ * Opt in to the merchant's AI assistant changing this setting for them (default: it may not).
19
+ *
20
+ * Queek's AI assistant can change an installed third-party app's settings only when the manifest marks them
21
+ * `ai_editable: true`; every other setting stays the merchant's to change in the dashboard, because anything the
22
+ * assistant reads (a customer message, a review) could try to point a setting somewhere new (a forwarding URL, a
23
+ * recipient email). Mark a setting only when a wrong value cannot move money, data or messages to a third party:
24
+ * a prep time or a display mode, never a webhook, an address or an account. A `secret` is never AI-editable
25
+ * (a manifest that says so is refused). Each AI change still needs the merchant's explicit confirmation.
26
+ */
27
+ ai_editable?: boolean;
28
+ }
29
+ /** The keys of the settings the AI assistant may change: opted in, and never a secret (the same rule Queek applies). */
30
+ export declare function aiEditableSettingKeys(settings: readonly ManifestSetting[]): string[];
31
+ /**
32
+ * The manifest's top-level `ai` section (beside `dashboard`): the small tools and actions Queek's AI assistant may use
33
+ * for this app. It needs no scope and is part of the consent the merchant approves; adding or changing a tool or action
34
+ * needs a fresh approval. Queek's AI never runs an app action: an action only OPENS the app's own `page` with the values
35
+ * filled in, and the merchant checks them and saves there. Keys match `^[a-z][a-z0-9_]{0,39}$`.
36
+ */
37
+ export interface ManifestAi {
38
+ /** What the app is for, in your words (up to 1000 characters). Shown to the merchant, never trusted by the AI. */
39
+ summary: string;
40
+ /** Read tools (up to 20). Queek calls the app's proxy as `GET ai/{key}` signed with `surface=ai`. */
41
+ tools?: ManifestAiTool[];
42
+ /** Actions (up to 5; tools + actions up to 20). */
43
+ actions?: ManifestAiAction[];
44
+ }
45
+ /** An input type a tool takes. `order` and `product` are Queek references, given as the store's integer `p_id`. */
46
+ export declare const MANIFEST_AI_TOOL_INPUT_TYPES: readonly ["integer", "number", "boolean", "enum", "date", "order", "product"];
47
+ /** An action takes the tool types plus capped, URL-free free text. */
48
+ export declare const MANIFEST_AI_ACTION_INPUT_TYPES: readonly ["integer", "number", "boolean", "enum", "date", "order", "product", "text"];
49
+ export type ManifestAiInputType = (typeof MANIFEST_AI_ACTION_INPUT_TYPES)[number];
50
+ /** The types of the fields a tool returns. */
51
+ export declare const MANIFEST_AI_OUTPUT_TYPES: readonly ["string", "integer", "number", "boolean", "date"];
52
+ export type ManifestAiOutputType = (typeof MANIFEST_AI_OUTPUT_TYPES)[number];
53
+ /**
54
+ * Input keys Queek signs or owns on every call; a manifest declaring one is refused. Anything starting with
55
+ * `MANIFEST_AI_RESERVED_INPUT_PREFIX` is reserved too.
56
+ */
57
+ export declare const MANIFEST_AI_RESERVED_INPUT_KEYS: readonly ["sig", "ts", "jti", "shop", "kid", "surface", "method", "body_sha256", "idempotency_key", "vendor_id", "installation_id", "order_id", "product_id", "tool", "actor", "actor_role"];
58
+ export declare const MANIFEST_AI_RESERVED_INPUT_PREFIX = "logged_in_customer_";
59
+ /** True when `key` may not be declared as an AI input. */
60
+ export declare function isReservedAiInputKey(key: string): boolean;
61
+ /** One input (up to 8 per tool or action). Reserved keys (`MANIFEST_AI_RESERVED_INPUT_KEYS`, `logged_in_customer_*`) are refused. */
62
+ export interface ManifestAiInput {
63
+ key: string;
64
+ type: ManifestAiInputType;
65
+ /** Up to 80 characters. */
66
+ label: string;
67
+ required?: boolean;
68
+ /** `enum` only: 1 to 30 values of up to 60 characters. */
69
+ options?: string[];
70
+ /** `integer` and `number` only. */
71
+ min?: number;
72
+ max?: number;
73
+ /** `text` only (actions): 1 to 500, default 200. */
74
+ max_length?: number;
75
+ }
76
+ export interface ManifestAiOutputField {
77
+ key: string;
78
+ type: ManifestAiOutputType;
79
+ }
80
+ export interface ManifestAiTool {
81
+ key: string;
82
+ /** Up to 512 characters. */
83
+ description: string;
84
+ inputs?: ManifestAiInput[];
85
+ /** `list: true` means the tool answers `{ "rows": [...] }`, each row with these fields; anything else you return is dropped. */
86
+ output: {
87
+ list?: boolean;
88
+ fields: ManifestAiOutputField[];
89
+ };
90
+ }
91
+ export interface ManifestAiAction {
92
+ key: string;
93
+ /** Up to 512 characters. */
94
+ description: string;
95
+ /** A path under your merchant page's path prefix (like `extensions.nav` paths); the action needs a merchant page. */
96
+ page: string;
97
+ inputs?: ManifestAiInput[];
98
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The `settings` entries of an app manifest (`manifest.json`, or `[[settings]]` in app.toml): the fields the merchant
3
+ * fills in when installing or managing the app. Queek validates them on registration and on every settings write.
4
+ */
5
+ /** The `type` of a manifest setting. A `secret` is write-only for the merchant and never shown back or exposed to an AI. */
6
+ export const MANIFEST_SETTING_TYPES = ["string", "secret", "number", "boolean", "select"];
7
+ /** The keys of the settings the AI assistant may change: opted in, and never a secret (the same rule Queek applies). */
8
+ export function aiEditableSettingKeys(settings) {
9
+ return settings
10
+ .filter((setting) => setting.ai_editable === true && setting.type !== "secret")
11
+ .map((setting) => setting.key);
12
+ }
13
+ /** An input type a tool takes. `order` and `product` are Queek references, given as the store's integer `p_id`. */
14
+ export const MANIFEST_AI_TOOL_INPUT_TYPES = [
15
+ "integer",
16
+ "number",
17
+ "boolean",
18
+ "enum",
19
+ "date",
20
+ "order",
21
+ "product",
22
+ ];
23
+ /** An action takes the tool types plus capped, URL-free free text. */
24
+ export const MANIFEST_AI_ACTION_INPUT_TYPES = [...MANIFEST_AI_TOOL_INPUT_TYPES, "text"];
25
+ /** The types of the fields a tool returns. */
26
+ export const MANIFEST_AI_OUTPUT_TYPES = ["string", "integer", "number", "boolean", "date"];
27
+ /**
28
+ * Input keys Queek signs or owns on every call; a manifest declaring one is refused. Anything starting with
29
+ * `MANIFEST_AI_RESERVED_INPUT_PREFIX` is reserved too.
30
+ */
31
+ export const MANIFEST_AI_RESERVED_INPUT_KEYS = [
32
+ "sig",
33
+ "ts",
34
+ "jti",
35
+ "shop",
36
+ "kid",
37
+ "surface",
38
+ "method",
39
+ "body_sha256",
40
+ "idempotency_key",
41
+ "vendor_id",
42
+ "installation_id",
43
+ "order_id",
44
+ "product_id",
45
+ "tool",
46
+ "actor",
47
+ "actor_role",
48
+ ];
49
+ export const MANIFEST_AI_RESERVED_INPUT_PREFIX = "logged_in_customer_";
50
+ /** True when `key` may not be declared as an AI input. */
51
+ export function isReservedAiInputKey(key) {
52
+ return (MANIFEST_AI_RESERVED_INPUT_KEYS.includes(key) ||
53
+ key.startsWith(MANIFEST_AI_RESERVED_INPUT_PREFIX));
54
+ }