iit-mcp-autotask 0.63.14 → 0.63.16
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/.env.example +5 -0
- package/README.md +25 -5
- package/capabilities.json +3 -3
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.js +10 -0
- package/dist/policy.d.ts +2 -0
- package/dist/policy.js +13 -1
- package/dist/tools/catalog-data.d.ts +1 -1
- package/dist/tools/catalog-data.js +2 -2
- package/dist/tools/composites.js +7 -1
- package/dist/tools/context/client.js +9 -3
- package/dist/tools/dispatch.js +8 -2
- package/dist/tools/lists.d.ts +9 -0
- package/dist/tools/lists.js +77 -15
- package/dist/tools/meta.js +34 -7
- package/dist/tools/query-budget.d.ts +16 -0
- package/dist/tools/query-budget.js +58 -0
- package/dist/tools/resolves.d.ts +1 -1
- package/dist/tools/resolves.js +1 -1
- package/dist/tools/results/envelope.d.ts +0 -1
- package/dist/tools/results/envelope.js +10 -1
- package/dist/tools/results/errors.d.ts +36 -0
- package/dist/tools/results/errors.js +126 -15
- package/dist/tools/results/untrusted.d.ts +15 -2
- package/dist/tools/results/untrusted.js +15 -3
- package/dist/tools/schemas.d.ts +1 -0
- package/dist/tools/schemas.js +2 -1
- package/dist/tools/write/apply.js +29 -13
- package/dist/tools/write/outcome.js +10 -6
- package/dist/tools/write/parse.js +3 -0
- package/dist/tools/write/preview.js +8 -2
- package/dist/tools/write/snapshot.d.ts +3 -1
- package/dist/tools/write/snapshot.js +34 -12
- package/dist/write/evaluate.js +2 -10
- package/package.json +2 -2
- package/server.json +2 -2
- package/skills/asset-inventory.md +30 -23
- package/skills/slim-reads.md +6 -4
package/.env.example
CHANGED
|
@@ -104,6 +104,11 @@ AUTOTASK_CACHE=on
|
|
|
104
104
|
# symlink escape is refused BEFORE anything is created. See README, Query results.
|
|
105
105
|
# AUTOTASK_OUTPUT_DIR=/srv/autotask-output
|
|
106
106
|
|
|
107
|
+
# --- autotask_query response budget ---
|
|
108
|
+
# Rows answers (JSON or tsv) larger than this many bytes are cut to the longest whole-row prefix that
|
|
109
|
+
# fits (hasMore, bytesCapped). 16384 to 4194304; unset = 262144 (256 KiB).
|
|
110
|
+
# AUTOTASK_QUERY_MAX_BYTES=262144
|
|
111
|
+
|
|
107
112
|
# --- HTTP hardening (http transport only) ---
|
|
108
113
|
# Bind address (the --host flag): 127.0.0.1 by default. Off loopback, the two settings below are
|
|
109
114
|
# required or boot fails.
|
package/README.md
CHANGED
|
@@ -57,9 +57,10 @@ examples; `full: true` serves the complete record, `summary: true` about 2 KB),
|
|
|
57
57
|
refusal; no parent match is an empty result with a `relationNote`), in rows, counts and totals.
|
|
58
58
|
On a relation target itself (`ticket.<field>` on `tickets`, `task.<field>` on `tasks`,
|
|
59
59
|
`project.<field>` on `projects`) the prefix is dropped: the own field (0.38.1, #234). Rows on
|
|
60
|
-
`tickets` and `
|
|
61
|
-
`DEFAULT_COLUMNS` in `src/tools/lists.ts`; 0.38.1, #235
|
|
62
|
-
`resolution`, `internalNotes
|
|
60
|
+
`tickets`, `time_entries` and `configuration_items` without `include_fields` carry default columns
|
|
61
|
+
(18 / 13 / 14, `DEFAULT_COLUMNS` in `src/tools/lists.ts`; 0.38.1, #235; configuration items #451):
|
|
62
|
+
name any other field (`description`, `resolution`, `internalNotes`, a configuration item's `notes`
|
|
63
|
+
or RMM columns) in `include_fields`. `output_path` and `autotask_read` of
|
|
63
64
|
`<resource>.query` keep the full row.
|
|
64
65
|
The separate `autotask_aggregate` and `autotask_fetch_many` tools are removed (#228, 0.37.0); a
|
|
65
66
|
mixed-resource batch by id is `autotask_read` `operations.fetchByIds`. The served filter
|
|
@@ -322,7 +323,18 @@ A supported per-call `names: false` disables them; composite `max_name_reads` st
|
|
|
322
323
|
`items` holds the vendor records (free text wrapped in `<untrusted_content>` markers), `fetched` is
|
|
323
324
|
`items.length`, `hasMore` flags a truncated walk — the `limit` or the 1000-page guard on a normal
|
|
324
325
|
query, or the `output_path` 10,000-row cap — and `pagesWalked` counts the pages fetched. `count` is never served — the vendor documents it as the CURRENT page's
|
|
325
|
-
count, so a total rides `<resource>.count`.
|
|
326
|
+
count, so a total rides `<resource>.count`. A row's `userDefinedFields` is dropped when it is an
|
|
327
|
+
empty array and `include_fields` does not name it (#459); a requested list stays (even `[]`) and a
|
|
328
|
+
non-empty one is served as before, its values wrapped as untrusted content.
|
|
329
|
+
|
|
330
|
+
**Response byte budget** (#451): a rows answer (JSON or `format: 'tsv'`) is at most
|
|
331
|
+
`AUTOTASK_QUERY_MAX_BYTES` (default 256 KiB), measured on the finished tool result the client receives
|
|
332
|
+
(the envelope and its mirrored text block, after the untrusted marking). A larger answer is cut to the
|
|
333
|
+
longest whole-row prefix that fits: `hasMore: true`, `fetched` (or the TSV `rowCount`) is the rows
|
|
334
|
+
served, and `bytesCapped: { maxBytes, rowsReturned, rowsFetched }` says so; the summary steers to
|
|
335
|
+
`count` / `group_by` for totals, `include_fields` for fewer columns and, on stdio with an output root (`AUTOTASK_OUTPUT_DIR` or `AUTOTASK_STATE_DIR`), `output_path` for
|
|
336
|
+
the full set. A row is never cut in half and the other envelope fields stay. An answer within the
|
|
337
|
+
budget is unchanged. Totals mode, `output_path` and `autotask_read` are not capped by it.
|
|
326
338
|
|
|
327
339
|
**Saved files are the host's job.** Unless you ask for `output_path` (below), this server never
|
|
328
340
|
writes a result file on its own: when a result is too large, the MCP host persists the oversized
|
|
@@ -533,6 +545,7 @@ non-zero on an invalid config (fail-fast) instead of failing at the first tool c
|
|
|
533
545
|
| `AUTOTASK_ALLOW_ANY_BASE_HOST` | no | `false` | lab-only opt-in to boot with neither allow-list nor default origin; `warn`-logged at boot (decision D-4); refused with the operator profile. Not set in production. |
|
|
534
546
|
| `AUTOTASK_CACHE` | no | `on` | the single off switch for the SDK's per-tenant in-process caches (see [Per-tenant pool & cache](#per-tenant-pool--cache)): `on` (default) sends no cache block — the SDK's default-on caches apply to each pooled tenant client (read ~5 min + the reference tables at 1 h, field metadata ~5 min, plus the fuzzy company-name index below); `off` sends `cache: false` (every read re-dials the vendor) |
|
|
535
547
|
| `AUTOTASK_OUTPUT_DIR` | no | unset | the ONE directory the `output_path` option may write into (the bounded query tools and the invoice export; stdio transport only). Unset = defaults to `output/` under `AUTOTASK_STATE_DIR` (the feature refuses when neither is set); must be absolute, must already EXIST (the server never creates the root) and must not be the filesystem root. A caller path is relative to this root, and the root and target are canonically resolved (`realpath`) so a traversal or symlink escape is refused — with nothing created outside the root. See [Query results](#query-results-tsv-output_path-and-the-saved-file-shape) |
|
|
548
|
+
| `AUTOTASK_QUERY_MAX_BYTES` | no | 262144 (256 KiB) | the `autotask_query` rows-mode response budget in bytes (16384 to 4194304): a larger answer is cut to the longest whole-row prefix that fits, with `hasMore` and `bytesCapped` (see [Query results](#query-results-tsv-output_path-and-the-saved-file-shape)); totals, `output_path` and `autotask_read` are not capped |
|
|
536
549
|
| `AUTOTASK_RATE_LIMIT_PER_HOUR` | no | 8000 (agent profile) | override the SDK's local hourly allowance (at most 10,000; `null`/off is rejected at boot); the shared SDK origin ceiling remains enforced |
|
|
537
550
|
| `AUTOTASK_MAX_CONCURRENT` | no | 3 (agent profile) | override local aggregate concurrency across objects (1–10); the SDK still caps each object/tracking identifier at three active requests |
|
|
538
551
|
| `AUTOTASK_TIMEOUT_MS` | no | 20000 (agent profile) | whole-call budget |
|
|
@@ -780,7 +793,14 @@ guards (rate limiter, 429 cooldown) — a worse security posture, not a safer on
|
|
|
780
793
|
envelope, and the vendor's message strings cross cleaned, per-string 200-char capped and
|
|
781
794
|
secret-scrubbed, **unwrapped** (0.9.0: the angle-bracket escape is gone) — the error trailer
|
|
782
795
|
marks them untrusted data, never instructions (the only served vendor text outside a wrapper;
|
|
783
|
-
the bound is the cap plus the data-never-instructions rule).
|
|
796
|
+
the bound is the cap plus the data-never-instructions rule). An SDK client-side validation
|
|
797
|
+
refusal (category `validation`, no `httpStatus`, `url` or `vendorError`), such as an unknown-field
|
|
798
|
+
refusal listing the valid names, crosses in `data.message` up to 3,000 characters (#458). It can
|
|
799
|
+
quote live tenant metadata (field names, picklist labels), so it is served as untrusted content:
|
|
800
|
+
embedded wrapper tags dropped, cleaned, secret-scrubbed, capped and wrapped in
|
|
801
|
+
`<untrusted_content>`; `reasons[].detail` is its first 500 characters, unwrapped. Every other
|
|
802
|
+
error message keeps the 200-character bound. An all-digit credential value (the impersonation id)
|
|
803
|
+
is scrubbed only on digit boundaries, so it does not match inside a longer number.
|
|
784
804
|
- **Host allow-list is fail-closed at boot** (see [Per-request credential model](#per-request-credential-model)).
|
|
785
805
|
- **Sensitive-data-safe structured JSON logging:** NDJSON; stdio → stderr only (stdout is the
|
|
786
806
|
protocol), http → stdout. Operation keys, status, latency and byte sizes are loggable; credential
|
package/capabilities.json
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"id": "autotask.platform.catalog",
|
|
77
|
-
"description": "Find the exact operation key for anything without a dedicated tool: ranked search (q) over the 1,
|
|
77
|
+
"description": "Find the exact operation key for anything without a dedicated tool: ranked search (q) over the 1,393 registry operations, with effect and whether this deployment serves it. No vendor call.",
|
|
78
78
|
"mcpPrimitive": "tool",
|
|
79
79
|
"toolName": "autotask_catalog",
|
|
80
80
|
"type": "read",
|
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
268
|
"id": "autotask.configuration_item.profile",
|
|
269
|
-
"description": "One configuration item (asset/device) with type, category, notes, related items and
|
|
269
|
+
"description": "One configuration item (asset/device) with type, category, product, notes, related items, billing products and its software or licence subscriptions. Product and subscriptions degrade to unavailable without read access.",
|
|
270
270
|
"mcpPrimitive": "tool",
|
|
271
271
|
"toolName": "autotask_configuration_item_profile",
|
|
272
272
|
"type": "read",
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
"autotask_describe",
|
|
481
481
|
"autotask_read"
|
|
482
482
|
],
|
|
483
|
-
"backingRegistryOperations":
|
|
483
|
+
"backingRegistryOperations": 1393,
|
|
484
484
|
"note": "autotask_catalog finds the exact operation key (ranked search), autotask_describe serves its contract, autotask_read runs any effect=read key. Writes go through the operator profile (autotask_write then autotask_apply); authenticate.* is never served."
|
|
485
485
|
},
|
|
486
486
|
"schemas": {}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export declare const TOOLSETS: readonly ["service", "records", "finance"];
|
|
|
18
18
|
export type Toolset = (typeof TOOLSETS)[number];
|
|
19
19
|
/** The database-wide vendor hourly ceiling; the optional local quota must not exceed it. */
|
|
20
20
|
export declare const VENDOR_HOURLY_CAP = 10000;
|
|
21
|
+
/** `autotask_query` rows-mode response budget (#451): default 256 KiB, bounds 16 KiB to 4 MiB (the Billing Review response cap). */
|
|
22
|
+
export declare const QUERY_MAX_BYTES_DEFAULT: number;
|
|
23
|
+
export declare const QUERY_MAX_BYTES_MIN: number;
|
|
24
|
+
export declare const QUERY_MAX_BYTES_MAX: number;
|
|
21
25
|
/**
|
|
22
26
|
* A run scope: the companies one operator principal may write in this run. `{all: true}` means the
|
|
23
27
|
* policy's own scope; company ids are intersected with it, so a run scope can only narrow.
|
|
@@ -96,6 +100,7 @@ export declare const CONFIG_FIELDS: z.ZodObject<{
|
|
|
96
100
|
off: "off";
|
|
97
101
|
}>>;
|
|
98
102
|
AUTOTASK_OUTPUT_DIR: z.ZodOptional<z.ZodPreprocess<z.ZodString, unknown>>;
|
|
103
|
+
AUTOTASK_QUERY_MAX_BYTES: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
99
104
|
AUTOTASK_RATE_LIMIT_PER_HOUR: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
100
105
|
AUTOTASK_MAX_CONCURRENT: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
101
106
|
AUTOTASK_TIMEOUT_MS: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
@@ -154,6 +159,7 @@ export declare const schema: z.ZodObject<{
|
|
|
154
159
|
off: "off";
|
|
155
160
|
}>>;
|
|
156
161
|
AUTOTASK_OUTPUT_DIR: z.ZodOptional<z.ZodPreprocess<z.ZodString, unknown>>;
|
|
162
|
+
AUTOTASK_QUERY_MAX_BYTES: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
157
163
|
AUTOTASK_RATE_LIMIT_PER_HOUR: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
158
164
|
AUTOTASK_MAX_CONCURRENT: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
159
165
|
AUTOTASK_TIMEOUT_MS: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
package/dist/config/schema.js
CHANGED
|
@@ -16,6 +16,10 @@ export const PROFILES = ['readonly', 'operator'];
|
|
|
16
16
|
export const TOOLSETS = ['service', 'records', 'finance'];
|
|
17
17
|
/** The database-wide vendor hourly ceiling; the optional local quota must not exceed it. */
|
|
18
18
|
export const VENDOR_HOURLY_CAP = 10_000;
|
|
19
|
+
/** `autotask_query` rows-mode response budget (#451): default 256 KiB, bounds 16 KiB to 4 MiB (the Billing Review response cap). */
|
|
20
|
+
export const QUERY_MAX_BYTES_DEFAULT = 256 * 1024;
|
|
21
|
+
export const QUERY_MAX_BYTES_MIN = 16 * 1024;
|
|
22
|
+
export const QUERY_MAX_BYTES_MAX = 4 * 1024 * 1024;
|
|
19
23
|
/**
|
|
20
24
|
* A run scope: the companies one operator principal may write in this run. `{all: true}` means the
|
|
21
25
|
* policy's own scope; company ids are intersected with it, so a run scope can only narrow.
|
|
@@ -193,6 +197,12 @@ export const CONFIG_FIELDS = z
|
|
|
193
197
|
* escape is refused before the walk.
|
|
194
198
|
*/
|
|
195
199
|
AUTOTASK_OUTPUT_DIR: blankToUndefined.optional(),
|
|
200
|
+
/**
|
|
201
|
+
* The `autotask_query` rows-mode response budget in bytes (#451), measured on the finished result the
|
|
202
|
+
* client receives; a larger answer is cut to the longest whole-row prefix that fits (`bytesCapped`).
|
|
203
|
+
* Unset = {@link QUERY_MAX_BYTES_DEFAULT}. Totals mode, `output_path` and `autotask_read` are not capped.
|
|
204
|
+
*/
|
|
205
|
+
AUTOTASK_QUERY_MAX_BYTES: z.coerce.number().int().min(QUERY_MAX_BYTES_MIN).max(QUERY_MAX_BYTES_MAX).optional(),
|
|
196
206
|
/**
|
|
197
207
|
* The client-side hourly budget (vendor cap 10,000 req/hour; the `agent` profile default is
|
|
198
208
|
* 8,000). Positive integer only — `null`/off is rejected at boot to retain this lower local
|
package/dist/policy.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare const CREDENTIAL_RESOURCES: readonly ["authenticate"];
|
|
|
35
35
|
export declare function isSecretOperation(operation: string): boolean;
|
|
36
36
|
export declare function isStaffAttachmentWrite(operation: string): boolean;
|
|
37
37
|
export declare function staffAttachmentScopeReason(operation: string, runScope: RunScope | undefined): Reason | undefined;
|
|
38
|
+
/** Resolve the account scope shared by discovery and the write evaluator. */
|
|
39
|
+
export declare function accountWriteScopeReason(operation: string, accountWide: boolean, runScope: RunScope | undefined): Reason | undefined;
|
|
38
40
|
/**
|
|
39
41
|
* The one-line reason `operation` is refused (for a catalog row or `describe`), or `null` when this
|
|
40
42
|
* deployment serves it. `writable` is the set of write operations the operator policy lists.
|
package/dist/policy.js
CHANGED
|
@@ -44,6 +44,18 @@ export function staffAttachmentScopeReason(operation, runScope) {
|
|
|
44
44
|
detail: `${operation} requires a run scope of {"all":true} because the parent does not establish company ownership`,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
/** Resolve the account scope shared by discovery and the write evaluator. */
|
|
48
|
+
export function accountWriteScopeReason(operation, accountWide, runScope) {
|
|
49
|
+
const staffAttachment = staffAttachmentScopeReason(operation, runScope);
|
|
50
|
+
if (staffAttachment !== undefined)
|
|
51
|
+
return staffAttachment;
|
|
52
|
+
if (!accountWide || runScope === undefined || !('companyIds' in runScope))
|
|
53
|
+
return undefined;
|
|
54
|
+
return {
|
|
55
|
+
code: 'TARGET_NOT_IN_SCOPE',
|
|
56
|
+
detail: `${operation} is account-wide (tenant configuration that belongs to no company), so a company run scope never admits it; only a run scope of {"all":true} does`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
47
59
|
/**
|
|
48
60
|
* The one-line reason `operation` is refused (for a catalog row or `describe`), or `null` when this
|
|
49
61
|
* deployment serves it. `writable` is the set of write operations the operator policy lists.
|
|
@@ -59,7 +71,7 @@ export function refusalReason(operation, record, config, writable = new Set(), r
|
|
|
59
71
|
return 'refused: profile readonly serves reads only';
|
|
60
72
|
if (!writable.has(operation))
|
|
61
73
|
return 'refused: not admitted by the effective write policy (unlisted writes are read-only)';
|
|
62
|
-
const scope =
|
|
74
|
+
const scope = accountWriteScopeReason(operation, record.metadata?.accountWide === true, runScope);
|
|
63
75
|
return scope === undefined ? null : `refused: ${scope.detail}`;
|
|
64
76
|
}
|
|
65
77
|
/** The `POLICY_DENIED` error: deployment policy is fixed for the life of the process, so the
|
|
@@ -108,7 +108,7 @@ export declare function sdkCacheOptions(cache: 'on' | 'off'): Pick<AutotaskConfi
|
|
|
108
108
|
* fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
|
|
109
109
|
* describes the SDK behind it.
|
|
110
110
|
*/
|
|
111
|
-
export declare const BUILT_AGAINST_PLAN_HASH = "
|
|
111
|
+
export declare const BUILT_AGAINST_PLAN_HASH = "929593354ffa904a038cb7cbbf7b91ffbb05e9f06078181e9f225505f3463a88";
|
|
112
112
|
/**
|
|
113
113
|
* Fail fast when the installed SDK's plan has moved out from under this surface.
|
|
114
114
|
* Called at boot (main.ts) and safe to call repeatedly (pure comparison).
|
|
@@ -143,7 +143,7 @@ export const TOOL_DESCRIPTIONS = {
|
|
|
143
143
|
autotask_service_call_full_profile: 'One service call with its linked tickets, tasks and resource assignments, for on-site visit work. Missing parts degrade to typed absent.',
|
|
144
144
|
autotask_resource_workload: 'A resource\'s open tickets (primary or secondary, de-duplicated), assignments, time off. For "how many" use totals (exact; capped = link cap hit, not row capped; extra reads; totalsAbsent = failed). Missing parts: typed absent.',
|
|
145
145
|
autotask_contact_full_profile: 'One contact with their company and open tickets (closed set from the tenant status picklist). Contains personal data. Missing parts degrade to typed absent.',
|
|
146
|
-
autotask_configuration_item_profile: 'One configuration item (asset/device) with type, category, notes, related items and
|
|
146
|
+
autotask_configuration_item_profile: 'One configuration item (asset/device) with type, category, product, notes, related items, billing products and its software or licence subscriptions. Product and subscriptions degrade to unavailable without read access.',
|
|
147
147
|
autotask_contract_full_profile: 'One contract with services, billing rules, newest charges and service units. Monthly P&L: autotask_read (guide: contract-profitability).',
|
|
148
148
|
autotask_quote_get: 'One quote with its line items in one call. A list of quotes: autotask_read quotes.query.',
|
|
149
149
|
autotask_revenue_rollup: 'Revenue for recurring and fixed price contracts by vertical, company or month, with excluded amounts and coverage. One scope required; full-month windows in the user zone. May take 15-45 seconds. Finance playbook: revenue-rollup.',
|
|
@@ -190,7 +190,7 @@ export function sdkCacheOptions(cache) {
|
|
|
190
190
|
* fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
|
|
191
191
|
* describes the SDK behind it.
|
|
192
192
|
*/
|
|
193
|
-
export const BUILT_AGAINST_PLAN_HASH = '
|
|
193
|
+
export const BUILT_AGAINST_PLAN_HASH = '929593354ffa904a038cb7cbbf7b91ffbb05e9f06078181e9f225505f3463a88';
|
|
194
194
|
/**
|
|
195
195
|
* Fail fast when the installed SDK's plan has moved out from under this surface.
|
|
196
196
|
* Called at boot (main.ts) and safe to call repeatedly (pure comparison).
|
package/dist/tools/composites.js
CHANGED
|
@@ -104,7 +104,13 @@ export function buildConfigurationItemProfile(ctx) {
|
|
|
104
104
|
operation: 'configuration_items.profile',
|
|
105
105
|
title: 'Get a configuration item with its bounded profile',
|
|
106
106
|
input: closedInput(CONFIGURATION_ITEM_PROFILE_INPUT),
|
|
107
|
-
opts: (a) => bagOf([
|
|
107
|
+
opts: (a) => bagOf([
|
|
108
|
+
['noteLimit', a.note_limit],
|
|
109
|
+
['relatedLimit', a.related_limit],
|
|
110
|
+
['subscriptionLimit', a.subscription_limit],
|
|
111
|
+
['names', a.names],
|
|
112
|
+
['maxNameReads', a.max_name_reads],
|
|
113
|
+
]),
|
|
108
114
|
});
|
|
109
115
|
}
|
|
110
116
|
/** #287: row caps of the phases and tasks parts (exact totals come from the count reads). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** SDK client construction (base options, placeholder, stdio client) and the default SDK ops bundle (issue #91). */
|
|
2
|
+
import { knowledgeBaseStatusCode } from '../results/errors.js';
|
|
2
3
|
import { AutotaskClient } from 'node-autotask';
|
|
3
4
|
import { invokeDelete, invokeRead, invokeReadPages, invokeWrite, relationshipMap, resolveAny, searchAcrossResources } from 'node-autotask/operations';
|
|
4
5
|
import { serverCredentialDefaults } from '../../config/load.js';
|
|
@@ -55,14 +56,19 @@ export function buildSdkBaseOptions(config, log) {
|
|
|
55
56
|
// own shape metadata is forwarded — never bodies or payload values (security S9).
|
|
56
57
|
onAudit: (event) => {
|
|
57
58
|
const e = event;
|
|
59
|
+
const operation = typeof e.operation === 'string' ? e.operation : undefined;
|
|
60
|
+
const status = typeof e.status === 'number' ? e.status : undefined;
|
|
61
|
+
const errorCode = typeof e.errorCode === 'string' && e.errorCode !== 'MAINTENANCE'
|
|
62
|
+
? knowledgeBaseStatusCode(operation, status) ?? e.errorCode
|
|
63
|
+
: e.errorCode === 'MAINTENANCE' ? 'MAINTENANCE' : undefined;
|
|
58
64
|
log.info('autotask request', {
|
|
59
65
|
...(typeof e.correlationId === 'string' ? { correlationId: e.correlationId } : {}),
|
|
60
|
-
...(
|
|
66
|
+
...(operation !== undefined ? { operation } : {}),
|
|
61
67
|
...(typeof e.method === 'string' ? { method: e.method } : {}),
|
|
62
68
|
...(typeof e.path === 'string' ? { path: e.path } : {}),
|
|
63
|
-
...(
|
|
69
|
+
...(status !== undefined ? { status } : {}),
|
|
64
70
|
...(typeof e.durationMs === 'number' ? { durationMs: e.durationMs } : {}),
|
|
65
|
-
...(
|
|
71
|
+
...(errorCode !== undefined ? { errorCode } : {}),
|
|
66
72
|
...(e.notSent === true ? { notSent: true } : {}),
|
|
67
73
|
});
|
|
68
74
|
},
|
package/dist/tools/dispatch.js
CHANGED
|
@@ -17,7 +17,7 @@ import { assertFilterShape, QUERY_LIMIT, QUERY_MAX_ROWS } from './schemas.js';
|
|
|
17
17
|
import { RECORDS, toolForOp } from './catalog-data.js';
|
|
18
18
|
import { AUTOTASK_BASE_PATH } from '../base-hosts.js';
|
|
19
19
|
import { releaseClientOnError } from './context/derive.js';
|
|
20
|
-
import { abortedResult, closedArgsError, errorContent, refusalContent } from './results/errors.js';
|
|
20
|
+
import { abortedResult, closedArgsError, errorContent, isKnowledgeBaseRootOperation, refusalContent } from './results/errors.js';
|
|
21
21
|
import { crossResourceUntrusted, isFileOperation, markFilePayload, markResult, markServerField } from './results/untrusted.js';
|
|
22
22
|
import { mirrorEnvelope } from './results/envelope.js';
|
|
23
23
|
import { assertOperationPermitted } from '../policy.js';
|
|
@@ -179,7 +179,13 @@ function annotateCatalogRows(result) {
|
|
|
179
179
|
continue;
|
|
180
180
|
const resource = row.resource;
|
|
181
181
|
// #228: autotask_query serves every <resource>.query read
|
|
182
|
-
|
|
182
|
+
const operation = typeof resource === 'string' ? `${resource}.query` : undefined;
|
|
183
|
+
const catalogRow = row;
|
|
184
|
+
catalogRow.queryOperation = operation !== undefined && toolForOp(operation) === 'autotask_query' ? operation : null;
|
|
185
|
+
if (isKnowledgeBaseRootOperation(operation) && catalogRow.error != null) {
|
|
186
|
+
// The SDK's row error carries vendor text and a code without trusted HTTP status.
|
|
187
|
+
catalogRow.error = { code: 'UPSTREAM_ERROR', message: 'Autotask could not provide Knowledge Base metadata.' };
|
|
188
|
+
}
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
191
|
/**
|
package/dist/tools/lists.d.ts
CHANGED
|
@@ -3,7 +3,16 @@ import type { BuiltTool } from './surface.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* #235: the columns a tickets / time_entries row carries when include_fields is absent. A full row is
|
|
5
5
|
* about 4 KB (107 keys with labels) / 2 KB, so 12 tickets cost 50 KB; these cost about a quarter.
|
|
6
|
+
* #451: configuration_items too (a full row has over 100 model fields: Datto, RMM, SSL, domain, UDFs).
|
|
6
7
|
* output_path (a file, not context) and autotask_read of <resource>.query keep the full row.
|
|
7
8
|
*/
|
|
8
9
|
export declare const DEFAULT_COLUMNS: Readonly<Record<string, readonly string[]>>;
|
|
9
10
|
export declare function buildQuery(ctx: ToolContext): BuiltTool;
|
|
11
|
+
/**
|
|
12
|
+
* #459: the query result with each row's `userDefinedFields` removed when it is an empty array and the caller did
|
|
13
|
+
* not name it in `include_fields` (an empty list on every row of a large answer is noise in the model context). A
|
|
14
|
+
* requested key stays, even empty; a non-empty list stays and is marked untrusted as before. The SDK's objects are
|
|
15
|
+
* never mutated (the envelope, its item array and each slimmed row are copies); a result without an item array, or
|
|
16
|
+
* with no empty list to drop, is returned as it is. `output_path` files and `autotask_read` keep the full row.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withoutEmptyUdfs(result: unknown, includeFields: readonly string[] | undefined): unknown;
|
package/dist/tools/lists.js
CHANGED
|
@@ -13,7 +13,8 @@ import { QUERY_INPUT, QUERY_LIMIT, assertFilterShape, closedInput } from './sche
|
|
|
13
13
|
import { isDeletedActivityAuditResource } from './catalog-data.js';
|
|
14
14
|
import { abortedAnswer, InputInvalidError } from './dispatch.js';
|
|
15
15
|
import { runAggregate } from './aggregate.js';
|
|
16
|
-
import { markResult, markServerField, sanitiseVendorOutput } from './results/untrusted.js';
|
|
16
|
+
import { markResult, markServerField, PROVENANCE, sanitiseVendorOutput } from './results/untrusted.js';
|
|
17
|
+
import { bytesCappedNote, QUERY_MAX_BYTES, withinQueryBudget } from './query-budget.js';
|
|
17
18
|
import { ok } from './results/envelope.js';
|
|
18
19
|
import { toTsv } from './tsv.js';
|
|
19
20
|
import { exportQueryFile, QueryExportIncompleteError } from './query-export.js';
|
|
@@ -32,11 +33,13 @@ const NOUNS = {
|
|
|
32
33
|
/**
|
|
33
34
|
* #235: the columns a tickets / time_entries row carries when include_fields is absent. A full row is
|
|
34
35
|
* about 4 KB (107 keys with labels) / 2 KB, so 12 tickets cost 50 KB; these cost about a quarter.
|
|
36
|
+
* #451: configuration_items too (a full row has over 100 model fields: Datto, RMM, SSL, domain, UDFs).
|
|
35
37
|
* output_path (a file, not context) and autotask_read of <resource>.query keep the full row.
|
|
36
38
|
*/
|
|
37
39
|
export const DEFAULT_COLUMNS = {
|
|
38
40
|
tickets: ['id', 'ticketNumber', 'title', 'status', 'priority', 'issueType', 'subIssueType', 'ticketType', 'queueID', 'companyID', 'contactID', 'assignedResourceID', 'contractID', 'createDate', 'lastActivityDate', 'completedDate', 'dueDateTime', 'estimatedHours'],
|
|
39
41
|
time_entries: ['id', 'ticketID', 'taskID', 'resourceID', 'dateWorked', 'hoursWorked', 'hoursToBill', 'isNonBillable', 'billingCodeID', 'contractID', 'roleID', 'timeEntryType', 'summaryNotes'],
|
|
42
|
+
configuration_items: ['id', 'referenceTitle', 'referenceNumber', 'serialNumber', 'configurationItemType', 'configurationItemCategoryID', 'companyID', 'productID', 'vendorID', 'contractID', 'isActive', 'installDate', 'warrantyExpirationDate', 'parentConfigurationItemID'],
|
|
40
43
|
};
|
|
41
44
|
export function buildQuery(ctx) {
|
|
42
45
|
return {
|
|
@@ -56,7 +59,7 @@ export function buildQuery(ctx) {
|
|
|
56
59
|
// INPUT_INVALID error, as when the schema required it: a model retries it; needs_input reads as "stop" (rule 3). autotask_read *.query keeps its bounded no-filter default (limit 50; #83, #243).
|
|
57
60
|
const conditions = Array.isArray(args.filter) ? args.filter : args.filter?.filter;
|
|
58
61
|
if (args.filter === undefined || (Array.isArray(conditions) && conditions.length === 0)) {
|
|
59
|
-
//
|
|
62
|
+
// one sentence that names the scope to add (data.message and reasons[].detail both carry it whole)
|
|
60
63
|
const hint = isDeletedActivityAuditResource(args.resource)
|
|
61
64
|
? 'pass an audit filter such as {field: "id", op: "exist"} for bounded reads or counts'
|
|
62
65
|
: 'call again with a scope such as {field: "companyID", op: "eq", value: "<id>"} (time_entries: ticket.companyID), or {field: "id", op: "exist"} for the whole entity';
|
|
@@ -82,7 +85,7 @@ export function buildQuery(ctx) {
|
|
|
82
85
|
if (args.filter !== undefined)
|
|
83
86
|
bag.filter = args.filter;
|
|
84
87
|
bag.limit = args.limit ?? QUERY_LIMIT.parse(undefined);
|
|
85
|
-
// #235: no include_fields on tickets / time_entries sends the default columns
|
|
88
|
+
// #235 / #451: no include_fields on tickets / time_entries / configuration_items sends the default columns
|
|
86
89
|
const defaults = args.include_fields === undefined ? DEFAULT_COLUMNS[args.resource] : undefined;
|
|
87
90
|
const includeFields = args.include_fields ?? defaults;
|
|
88
91
|
if (includeFields !== undefined)
|
|
@@ -101,8 +104,19 @@ export function buildQuery(ctx) {
|
|
|
101
104
|
const n = v.count ?? v.total ?? (Array.isArray(v.items) ? v.items.length : undefined);
|
|
102
105
|
const capped = result.noteCharsTruncated;
|
|
103
106
|
// #231: note_chars capping is reported here and by noteCharsTruncated, never as a top-level truncated flag (rows: hasMore)
|
|
104
|
-
const
|
|
105
|
-
|
|
107
|
+
const notes = `${typeof capped === 'number' ? ` ${capped} text field(s) cut by note_chars.` : ''}${defaults !== undefined ? ' Default columns: pass include_fields for any other field.' : ''}`;
|
|
108
|
+
// output_path is named only where resolveOutputTarget can accept it: stdio with a configured root (or a state dir to default it under)
|
|
109
|
+
// (both are blank-to-undefined at boot)
|
|
110
|
+
const fileForm = ctx.config.MCP_TRANSPORT === 'stdio' && (ctx.config.AUTOTASK_OUTPUT_DIR !== undefined || ctx.config.AUTOTASK_STATE_DIR !== undefined);
|
|
111
|
+
// #451: the full answer as today, or (over the byte budget) the cut answer of the first `rows` rows
|
|
112
|
+
const countText = (rows, cut) => cut === undefined
|
|
113
|
+
? `${typeof n === 'number' ? `${n} ${noun}` : noun} returned.${notes}`
|
|
114
|
+
: `${rows} of ${cut.rowsFetched} ${noun} returned.${notes}${bytesCappedNote(cut, fileForm)}`;
|
|
115
|
+
// #459: an empty userDefinedFields array the caller did not name is dropped before the marking, so the
|
|
116
|
+
// byte budget below measures the slimmed rows; JSON and TSV rows share this one result.
|
|
117
|
+
const marked = markResult(withoutEmptyUdfs(result, args.include_fields), fields);
|
|
118
|
+
const markedItems = Array.isArray(marked.items) ? marked.items : [];
|
|
119
|
+
const maxBytes = ctx.config.AUTOTASK_QUERY_MAX_BYTES ?? QUERY_MAX_BYTES;
|
|
106
120
|
// #227: the server-side enrich is gone; the SDK labels every row by default (<fk>Name, <picklist>Label).
|
|
107
121
|
// #11 N4: format 'tsv' serves the table as result.tsv and OMITS items (the size saving). The
|
|
108
122
|
// TSV is built from the items AFTER the untrusted marking, so the markers survive in cells.
|
|
@@ -110,23 +124,71 @@ export function buildQuery(ctx) {
|
|
|
110
124
|
// The cells pass through the vendor-text choke point before the table is built (the table
|
|
111
125
|
// itself is then exempt from it, so the wrappers in its cells survive).
|
|
112
126
|
const itemList = Array.isArray(marked.items) ? sanitiseVendorOutput(marked.items) : [];
|
|
113
|
-
const { tsv, columns, rowCount } = toTsv(itemList);
|
|
114
127
|
const rest = { ...marked };
|
|
115
128
|
delete rest.items;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
return withinQueryBudget(itemList.length, maxBytes, ctx.correlationId, (rows, cut) => {
|
|
130
|
+
const { tsv, columns, rowCount } = toTsv(cut === undefined ? itemList : itemList.slice(0, rows));
|
|
131
|
+
// The table is built from cells that already passed the choke point: this exact object's
|
|
132
|
+
// `tsv` is recorded as server-built (by provenance, never by its key name).
|
|
133
|
+
const table = { ...rest, ...(cut === undefined ? {} : cutFields(rest, cut)), tsv, columns, rowCount };
|
|
134
|
+
markServerField(table, 'tsv', 'server');
|
|
135
|
+
markServerField(columns, '*', 'server');
|
|
136
|
+
return ok(`${countText(rows, cut)} Served as TSV: data.result.tsv (${rowCount} row(s), ${columns.length} column(s)); items omitted.`, {
|
|
137
|
+
resource: args.resource,
|
|
138
|
+
result: table,
|
|
139
|
+
});
|
|
124
140
|
});
|
|
125
141
|
}
|
|
126
|
-
return
|
|
142
|
+
return withinQueryBudget(markedItems.length, maxBytes, ctx.correlationId, (rows, cut) => {
|
|
143
|
+
if (cut === undefined)
|
|
144
|
+
return ok(countText(rows), { resource: args.resource, result: marked });
|
|
145
|
+
// The cut answer reuses the marked rows (their provenance rides the row objects) on a copy of
|
|
146
|
+
// the envelope that keeps every other field and the top-level provenance.
|
|
147
|
+
const items = markedItems.slice(0, rows);
|
|
148
|
+
copyProvenance(markedItems, items);
|
|
149
|
+
const page = { ...marked, items, ...cutFields(marked, cut) };
|
|
150
|
+
copyProvenance(marked, page);
|
|
151
|
+
return ok(countText(rows, cut), { resource: args.resource, result: page });
|
|
152
|
+
});
|
|
127
153
|
},
|
|
128
154
|
};
|
|
129
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* #459: the query result with each row's `userDefinedFields` removed when it is an empty array and the caller did
|
|
158
|
+
* not name it in `include_fields` (an empty list on every row of a large answer is noise in the model context). A
|
|
159
|
+
* requested key stays, even empty; a non-empty list stays and is marked untrusted as before. The SDK's objects are
|
|
160
|
+
* never mutated (the envelope, its item array and each slimmed row are copies); a result without an item array, or
|
|
161
|
+
* with no empty list to drop, is returned as it is. `output_path` files and `autotask_read` keep the full row.
|
|
162
|
+
*/
|
|
163
|
+
export function withoutEmptyUdfs(result, includeFields) {
|
|
164
|
+
if (includeFields?.some((f) => f.toLowerCase() === 'userdefinedfields') === true)
|
|
165
|
+
return result;
|
|
166
|
+
const items = result?.items;
|
|
167
|
+
const isEmptyUdfRow = (row) => {
|
|
168
|
+
const udfs = row?.userDefinedFields;
|
|
169
|
+
return Array.isArray(udfs) && udfs.length === 0;
|
|
170
|
+
};
|
|
171
|
+
if (!Array.isArray(items) || !items.some(isEmptyUdfRow))
|
|
172
|
+
return result;
|
|
173
|
+
const slim = items.map((row) => {
|
|
174
|
+
if (!isEmptyUdfRow(row))
|
|
175
|
+
return row;
|
|
176
|
+
const rest = { ...row };
|
|
177
|
+
delete rest.userDefinedFields;
|
|
178
|
+
return rest;
|
|
179
|
+
});
|
|
180
|
+
return { ...result, items: slim };
|
|
181
|
+
}
|
|
182
|
+
/** The fields a byte-budget cut changes on the envelope (#451): the rows served, hasMore and the marker. */
|
|
183
|
+
function cutFields(envelope, cut) {
|
|
184
|
+
return { ...(Object.prototype.hasOwnProperty.call(envelope, 'fetched') ? { fetched: cut.rowsReturned } : {}), hasMore: true, bytesCapped: { ...cut } };
|
|
185
|
+
}
|
|
186
|
+
/** Carry the untrusted provenance of `from` onto its copy `to` (the cut envelope and its row array). */
|
|
187
|
+
function copyProvenance(from, to) {
|
|
188
|
+
const fields = PROVENANCE.get(from);
|
|
189
|
+
if (fields !== undefined)
|
|
190
|
+
PROVENANCE.set(to, new Map(fields));
|
|
191
|
+
}
|
|
130
192
|
/**
|
|
131
193
|
* The `output_path` answer (issue #11 ruling N6): resolve + contain the target FIRST (a bad path
|
|
132
194
|
* never reaches the vendor), invoke the SDK's capped query walk, then
|
package/dist/tools/meta.js
CHANGED
|
@@ -26,7 +26,7 @@ import { releaseClientOnError } from './context/derive.js';
|
|
|
26
26
|
import {} from './context/types.js';
|
|
27
27
|
import { abortedAnswer, FIELD_CATALOG_MAX_BYTES, InputInvalidError, readOneItem, requestSecrets } from './dispatch.js';
|
|
28
28
|
import { zoneClock } from './clock.js';
|
|
29
|
-
import { typedErrorPayload } from './results/errors.js';
|
|
29
|
+
import { isKnowledgeBaseRootOperation, typedErrorPayload } from './results/errors.js';
|
|
30
30
|
import { markResult, sanitiseVendorOutput, UNTRUSTED_TEXT_CAP } from './results/untrusted.js';
|
|
31
31
|
import { errorEnvelope, ok, TRUNCATION_MARKER } from './results/envelope.js';
|
|
32
32
|
import { compileBm25 } from './rank.js';
|
|
@@ -34,7 +34,7 @@ import { playbooksFor } from './guide.js';
|
|
|
34
34
|
import { FIELD_INFO_EXPENSIVE, fieldLookupCall, udfCatalogCall } from './field-pointer.js';
|
|
35
35
|
import { SERVER_NAME, SERVER_VERSION } from './server-version.js';
|
|
36
36
|
import { CATALOG_INPUT, DESCRIBE_INPUT, AR_AGING_INPUT, WIP_HOURS_INPUT, NON_CHARGEABLE_WORK_INPUT, COMPANY_FULL_PROFILE_INPUT, CONFIGURATION_ITEM_PROFILE_INPUT, CONTACT_FULL_PROFILE_INPUT, CONTRACT_FULL_PROFILE_INPUT, INVOICE_GET_INPUT, PORTFOLIO_MARGIN_INPUT, RECURRING_REVENUE_INPUT, REVENUE_ROLLUP_INPUT, PROJECT_GET_CONTEXT_INPUT, QUERY_INPUT, QUOTE_GET_INPUT, RESOLVE_INPUT, RESOURCE_WORKLOAD_INPUT, SERVICE_CALL_FULL_PROFILE_INPUT, TICKET_FULL_CONTEXT_INPUT, QUERY_LIMIT, READ_INPUT, TENANT_STATUS_INPUT, TENANT_STATUS_PARTS, readIgnoredKeys, closedInput, } from './schemas.js';
|
|
37
|
-
import { isStaffAttachmentWrite, refusalReason } from '../policy.js';
|
|
37
|
+
import { isStaffAttachmentWrite, isWriteEffect, refusalReason } from '../policy.js';
|
|
38
38
|
/** Static registry search metadata; vendor reads and per-deployment boosts never enter this index. */
|
|
39
39
|
const CATALOG_INDEX = compileBm25(CATALOG.catalog.map((r) => `${r.operation} ${r.operation.replace(/[._]/g, ' ')} ${toolForOp(r.operation) ?? ''} ${r.purpose ?? ''}`));
|
|
40
40
|
/** `autotask_catalog`: the filtered, ranked, paged registry rows with this deployment's verdicts. */
|
|
@@ -524,6 +524,22 @@ function staffAttachmentArgs(rec) {
|
|
|
524
524
|
? 'parentId and id each require a positive safe integer JSON number.'
|
|
525
525
|
: 'parentId requires a positive safe integer JSON number. data is the attachment payload.';
|
|
526
526
|
}
|
|
527
|
+
function knowledgeBaseWriteArgs(rec) {
|
|
528
|
+
if (!isKnowledgeBaseRootOperation(rec.id) || !isWriteEffect(rec))
|
|
529
|
+
return undefined;
|
|
530
|
+
const ids = ['parentId', 'id'].filter(key => rec.inputSchema[key] !== undefined);
|
|
531
|
+
if (ids.length === 0)
|
|
532
|
+
return undefined;
|
|
533
|
+
const args = ids.map(key => operatorIdDescription(rec, key));
|
|
534
|
+
if (rec.inputSchema['data'] !== undefined)
|
|
535
|
+
args.push('data is the write payload.');
|
|
536
|
+
return args.join(' ');
|
|
537
|
+
}
|
|
538
|
+
function operatorIdDescription(rec, key) {
|
|
539
|
+
return rec.resource === 'knowledge_base_articles' && key === 'parentId'
|
|
540
|
+
? 'parentId requires a positive signed 32-bit category ID as a JSON integer.'
|
|
541
|
+
: `${key} requires a positive safe integer JSON number.`;
|
|
542
|
+
}
|
|
527
543
|
/** Served record: caveats projected, MCP argument restrictions applied and the SDK's own test list dropped. */
|
|
528
544
|
function servedRecord(rec) {
|
|
529
545
|
const projected = { ...projectCaveats(rec) };
|
|
@@ -532,13 +548,15 @@ function servedRecord(rec) {
|
|
|
532
548
|
const usage = servedUsage(rec);
|
|
533
549
|
if (usage !== undefined && usage !== md?.usage)
|
|
534
550
|
projected.metadata = { ...md, usage };
|
|
535
|
-
const
|
|
551
|
+
const staffArgs = staffAttachmentArgs(rec);
|
|
552
|
+
const args = staffArgs ?? knowledgeBaseWriteArgs(rec);
|
|
536
553
|
if (args !== undefined) {
|
|
537
554
|
const schema = { ...rec.inputSchema };
|
|
538
555
|
for (const key of ['parentId', 'id']) {
|
|
539
556
|
const descriptor = schema[key];
|
|
540
|
-
if (descriptor
|
|
541
|
-
|
|
557
|
+
if (descriptor === undefined)
|
|
558
|
+
continue;
|
|
559
|
+
schema[key] = { ...descriptor, type: 'number', description: operatorIdDescription(rec, key) };
|
|
542
560
|
}
|
|
543
561
|
projected.inputSchema = schema;
|
|
544
562
|
projected.metadata = { ...projected.metadata, args };
|
|
@@ -559,7 +577,16 @@ function capText(text, max, name, cut) {
|
|
|
559
577
|
/** Keep the SDK's audit caveats ahead of the compact descriptions' character caps. */
|
|
560
578
|
function compactUsage(rec, summary) {
|
|
561
579
|
const usage = servedUsage(rec);
|
|
562
|
-
if (usage === undefined
|
|
580
|
+
if (usage === undefined)
|
|
581
|
+
return usage;
|
|
582
|
+
if (rec.resource === 'knowledge_base_articles') {
|
|
583
|
+
if (rec.operation === 'update' && summary) {
|
|
584
|
+
return `Update uses the approved category route; articleCategoryID is read-only. ${usage}`;
|
|
585
|
+
}
|
|
586
|
+
const visibility = usage.indexOf('Can access Knowledgebase permission');
|
|
587
|
+
return visibility > 0 ? `${usage.slice(visibility)} ${usage.slice(0, visibility).trimEnd()}` : usage;
|
|
588
|
+
}
|
|
589
|
+
if (!isDeletedActivityAuditResource(rec.resource))
|
|
563
590
|
return usage;
|
|
564
591
|
if (!summary && rec.operation !== 'query')
|
|
565
592
|
return usage;
|
|
@@ -593,7 +620,7 @@ function summariseRecord(ctx, operation, viaTool) {
|
|
|
593
620
|
...(tool !== undefined ? { tool, ...toolServed(ctx, tool) } : {}),
|
|
594
621
|
purpose: capText(text(md.purpose) || text(row?.purpose), SUMMARY_CAPS.purpose, 'purpose', cut),
|
|
595
622
|
requiredArgs: row?.requiredArgs ?? [],
|
|
596
|
-
args: capText(staffAttachmentArgs(rec) ?? text(md.args), SUMMARY_CAPS.args, 'args', cut),
|
|
623
|
+
args: capText(staffAttachmentArgs(rec) ?? knowledgeBaseWriteArgs(rec) ?? text(md.args), SUMMARY_CAPS.args, 'args', cut),
|
|
597
624
|
usage: capText(text(compactUsage(rec, true)), SUMMARY_CAPS.usage, 'usage', cut),
|
|
598
625
|
reachable: reason === null,
|
|
599
626
|
why_not: reason,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolReturn } from './results/envelope.js';
|
|
2
|
+
/** The default budget (bytes) when `AUTOTASK_QUERY_MAX_BYTES` is unset. */
|
|
3
|
+
export declare const QUERY_MAX_BYTES: number;
|
|
4
|
+
/** The `bytesCapped` marker of a cut answer. */
|
|
5
|
+
export interface BytesCapped {
|
|
6
|
+
maxBytes: number;
|
|
7
|
+
rowsReturned: number;
|
|
8
|
+
rowsFetched: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Serve `build(rows)` within `maxBytes`. `build(rowsFetched)` is today's answer (no marker); `build(k,
|
|
12
|
+
* marker)` for `k < rowsFetched` is the cut answer of the first `k` rows. Returns the finished result.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withinQueryBudget(rowsFetched: number, maxBytes: number, correlationId: string, build: (rows: number, capped?: BytesCapped) => ToolReturn): ToolReturn;
|
|
15
|
+
/** The one steer of a cut answer's human line; `fileForm`: output_path can serve here (stdio with an output root). */
|
|
16
|
+
export declare function bytesCappedNote(capped: BytesCapped, fileForm: boolean): string;
|