lua-cli 3.42.0-beta.2 → 3.42.0-beta.3
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-exports.d.ts +74 -3
- package/dist/api-exports.js +187 -10
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +272 -19
- package/dist/index.js.map +1 -1
- package/dist/workflow-builder.js +153 -7
- package/dist/workflow-builder.js.map +1 -1
- package/docs/api/Agents.md +78 -0
- package/docs/api/LuaWebhook.md +40 -2
- package/package.json +2 -2
- package/template/package.json +1 -1
package/dist/workflow-builder.js
CHANGED
|
@@ -536,7 +536,19 @@ var SUPERVISION_OPS = {
|
|
|
536
536
|
* SV — `Agents.notifyOwner(id, { message })`: post a message (no model turn) to the TARGET OWNER's home thread with
|
|
537
537
|
* the caller. Needs the owner's opt-in recorded on the grant (`ownerNotify`) and `LUA_SUPERVISION_OWNER_NOTIFY_ENABLED`.
|
|
538
538
|
*/
|
|
539
|
-
"owner.notify": "observe"
|
|
539
|
+
"owner.notify": "observe",
|
|
540
|
+
/**
|
|
541
|
+
* SV — `Agents.connections(id).assign(connectionId, { approval })`: mount one of the target OWNER's personal
|
|
542
|
+
* connections on the target, consented by the owner's own signed-in decision on Lua's approval card
|
|
543
|
+
* (`supervised-connection-handover.types.ts`). Needs `LUA_SUPERVISED_CONNECTION_HANDOVER_ENABLED`.
|
|
544
|
+
*/
|
|
545
|
+
"connections.assign": "act",
|
|
546
|
+
/**
|
|
547
|
+
* SV — `Agents.secrets(id).attach(requestIds)`: attach U9 requests HELD for this existing agent (`{ pendingFor,
|
|
548
|
+
* agentId }`) to its env. `act`, on a turn whose platform-picked user is the target's owner, never overwriting a
|
|
549
|
+
* key (`LUA_SECRET_ATTACH_EXISTING_ENABLED`).
|
|
550
|
+
*/
|
|
551
|
+
"secrets.attach": "act"
|
|
540
552
|
};
|
|
541
553
|
function isSupervisionOp(op) {
|
|
542
554
|
return typeof op === "string" && Object.prototype.hasOwnProperty.call(SUPERVISION_OPS, op);
|
|
@@ -705,6 +717,18 @@ var SUPERVISION_OPS_WAVE2 = {
|
|
|
705
717
|
gate: "observe",
|
|
706
718
|
targeted: true,
|
|
707
719
|
item: "SV"
|
|
720
|
+
},
|
|
721
|
+
/** SV — `Agents.connections(id).assign(connectionId, { approval })` (the owner's signed-in approval). */
|
|
722
|
+
"connections.assign": {
|
|
723
|
+
gate: "act",
|
|
724
|
+
targeted: true,
|
|
725
|
+
item: "SV"
|
|
726
|
+
},
|
|
727
|
+
/** SV — `Agents.secrets(id).attach(requestIds)`: held U9 requests onto an existing agent (owner's turn). */
|
|
728
|
+
"secrets.attach": {
|
|
729
|
+
gate: "act",
|
|
730
|
+
targeted: true,
|
|
731
|
+
item: "SV"
|
|
708
732
|
}
|
|
709
733
|
};
|
|
710
734
|
var SUPERVISION_UNTARGETED_OPS = [
|
|
@@ -798,6 +822,7 @@ var AGENT_PROVISIONING_LIMITS = {
|
|
|
798
822
|
nameMax: 80,
|
|
799
823
|
personaMax: 2e4,
|
|
800
824
|
connectionsMax: 20,
|
|
825
|
+
pendingSecretsMax: 20,
|
|
801
826
|
maxAgentsPerUserCeiling: 50
|
|
802
827
|
};
|
|
803
828
|
var AGENT_PROVISIONING_APPROVAL_PAYLOAD_KEY = "agentProvisioning";
|
|
@@ -811,8 +836,13 @@ var AGENT_PROVISIONING_ERRORS = {
|
|
|
811
836
|
MODEL_NOT_ALLOWED: "agent_provisioning_model_not_allowed",
|
|
812
837
|
ACTIONS_NOT_ALLOWED: "agent_provisioning_actions_not_allowed",
|
|
813
838
|
WORKFLOW_IDS_INVALID: "agent_provisioning_workflow_ids_invalid",
|
|
814
|
-
/**
|
|
839
|
+
/** A non-empty `pendingSecretRequestIds` while `LUA_SECRET_REQUESTS_ENABLED` is off (or over the limit). */
|
|
815
840
|
PENDING_SECRETS_UNSUPPORTED: "agent_provisioning_pending_secrets_unsupported",
|
|
841
|
+
/**
|
|
842
|
+
* A pending secret request is not attachable to this create (unknown, another org / member / provisioner,
|
|
843
|
+
* not `ok`-tested, already attached or purged). Checked before the agent exists.
|
|
844
|
+
*/
|
|
845
|
+
PENDING_SECRET_NOT_ATTACHABLE: "agent_provisioning_pending_secret_not_attachable",
|
|
816
846
|
/** The `Agents.create` input is malformed (name, model, persona, list shapes or limits). */
|
|
817
847
|
INVALID_INPUT: "agent_provisioning_invalid_input",
|
|
818
848
|
/** `PUT …/agent-provisioning-policy` body is malformed (`*`, unknown action, out-of-range quota…). */
|
|
@@ -1014,10 +1044,16 @@ function decideAgentProvisioning(params) {
|
|
|
1014
1044
|
if (input.unattendedWorkflowIds.length) {
|
|
1015
1045
|
return wf("unattendedWorkflowIds are not allowed on a provisioning grant (the member\u2019s consent does not cover them)");
|
|
1016
1046
|
}
|
|
1017
|
-
if (input.pendingSecretRequestIds.length) {
|
|
1047
|
+
if (input.pendingSecretRequestIds.length && !params.pendingSecretsEnabled) {
|
|
1018
1048
|
return {
|
|
1019
1049
|
code: AGENT_PROVISIONING_ERRORS.PENDING_SECRETS_UNSUPPORTED,
|
|
1020
|
-
message: "Pending secret requests
|
|
1050
|
+
message: "Pending secret requests are not enabled in this environment"
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
if (input.pendingSecretRequestIds.length > AGENT_PROVISIONING_LIMITS.pendingSecretsMax) {
|
|
1054
|
+
return {
|
|
1055
|
+
code: AGENT_PROVISIONING_ERRORS.PENDING_SECRETS_UNSUPPORTED,
|
|
1056
|
+
message: `At most ${AGENT_PROVISIONING_LIMITS.pendingSecretsMax} pending secret requests can be attached`
|
|
1021
1057
|
};
|
|
1022
1058
|
}
|
|
1023
1059
|
return null;
|
|
@@ -1032,7 +1068,7 @@ var sameSet = /* @__PURE__ */ __name3((a, b) => {
|
|
|
1032
1068
|
].every((v) => sb.has(v));
|
|
1033
1069
|
}, "sameSet");
|
|
1034
1070
|
function consentCoversProvisioning(consent, request) {
|
|
1035
|
-
return consent.orgId === request.orgId && consent.userId === request.onBehalfOf && consent.provisionerAgentId === request.provisionerAgentId && consent.agentName.trim() === request.input.name && sameSet(consent.supervise ?? [], request.input.supervise) && sameSet(consent.connections ?? [], request.input.connections);
|
|
1071
|
+
return consent.orgId === request.orgId && consent.userId === request.onBehalfOf && consent.provisionerAgentId === request.provisionerAgentId && consent.agentName.trim() === request.input.name && sameSet(consent.supervise ?? [], request.input.supervise) && sameSet(consent.connections ?? [], request.input.connections) && sameSet(consent.pendingSecretRequestIds ?? [], request.input.pendingSecretRequestIds);
|
|
1036
1072
|
}
|
|
1037
1073
|
__name(consentCoversProvisioning, "consentCoversProvisioning");
|
|
1038
1074
|
__name3(consentCoversProvisioning, "consentCoversProvisioning");
|
|
@@ -1764,7 +1800,13 @@ var SECRET_REQUEST_ERRORS = {
|
|
|
1764
1800
|
/** The input's `fields` do not match the provider's catalogue bundle. */
|
|
1765
1801
|
FIELDS_INVALID: "secret_fields_invalid",
|
|
1766
1802
|
/** `Secrets.test(key)` / status on a key with no request on record (the provider is unknown). */
|
|
1767
|
-
KEY_NOT_FOUND: "secret_key_not_found"
|
|
1803
|
+
KEY_NOT_FOUND: "secret_key_not_found",
|
|
1804
|
+
/** A held request for an existing agent while `LUA_SECRET_ATTACH_EXISTING_ENABLED` is off. */
|
|
1805
|
+
ATTACH_EXISTING_DISABLED: "secret_attach_existing_disabled",
|
|
1806
|
+
/** `secrets.attach` would set an env key the agent already has: never overwritten (remove or rotate it first). */
|
|
1807
|
+
KEY_EXISTS: "secret_key_exists",
|
|
1808
|
+
/** A request held for an existing agent submitted on the public token page: its owner submits it signed in. */
|
|
1809
|
+
OWNER_SUBMIT_REQUIRED: "secret_submit_requires_owner"
|
|
1768
1810
|
};
|
|
1769
1811
|
var SECRET_OUTCOME_STATUSES = [
|
|
1770
1812
|
...SECRET_TEST_RESULTS,
|
|
@@ -3071,6 +3113,110 @@ function supervisionAccessBindingViolation(merged) {
|
|
|
3071
3113
|
}
|
|
3072
3114
|
__name(supervisionAccessBindingViolation, "supervisionAccessBindingViolation");
|
|
3073
3115
|
__name3(supervisionAccessBindingViolation, "supervisionAccessBindingViolation");
|
|
3116
|
+
var CONNECTION_HANDOVER_APPROVAL_PAYLOAD_KEY = "connectionAssignment";
|
|
3117
|
+
var CONNECTION_HANDOVER_APPROVAL_CARD_MAX_CHARS = 1200;
|
|
3118
|
+
var CONNECTION_HANDOVER_LIMITS = {
|
|
3119
|
+
idMax: 128,
|
|
3120
|
+
agentNameMax: 200,
|
|
3121
|
+
integrationMax: 60,
|
|
3122
|
+
accountMax: 200
|
|
3123
|
+
};
|
|
3124
|
+
var MEMBERS = [
|
|
3125
|
+
"connectionId",
|
|
3126
|
+
"agentId",
|
|
3127
|
+
"agentName",
|
|
3128
|
+
"supervisorName",
|
|
3129
|
+
"integration",
|
|
3130
|
+
"account"
|
|
3131
|
+
];
|
|
3132
|
+
var FORMAT_CHARS = /[\p{Cf}\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff]/u;
|
|
3133
|
+
function hasFormatCharacters(text) {
|
|
3134
|
+
return FORMAT_CHARS.test(text);
|
|
3135
|
+
}
|
|
3136
|
+
__name(hasFormatCharacters, "hasFormatCharacters");
|
|
3137
|
+
__name3(hasFormatCharacters, "hasFormatCharacters");
|
|
3138
|
+
var oneLine = /* @__PURE__ */ __name3((text) => text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029"\u201c\u201d]/g, " ").replace(/\s+/g, " ").trim(), "oneLine");
|
|
3139
|
+
function normalizedHandoverName(name) {
|
|
3140
|
+
return oneLine(name.normalize("NFKC")).toLowerCase();
|
|
3141
|
+
}
|
|
3142
|
+
__name(normalizedHandoverName, "normalizedHandoverName");
|
|
3143
|
+
__name3(normalizedHandoverName, "normalizedHandoverName");
|
|
3144
|
+
function handoverAgentIdSuffix(agentId) {
|
|
3145
|
+
return agentId.slice(-6);
|
|
3146
|
+
}
|
|
3147
|
+
__name(handoverAgentIdSuffix, "handoverAgentIdSuffix");
|
|
3148
|
+
__name3(handoverAgentIdSuffix, "handoverAgentIdSuffix");
|
|
3149
|
+
var boundedString = /* @__PURE__ */ __name3((v, max) => typeof v === "string" && v.trim().length > 0 && v.length <= max && !hasFormatCharacters(v), "boundedString");
|
|
3150
|
+
function parseConnectionHandoverApprovalPayload(payload) {
|
|
3151
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return null;
|
|
3152
|
+
const top = Object.keys(payload);
|
|
3153
|
+
if (top.length !== 1 || top[0] !== CONNECTION_HANDOVER_APPROVAL_PAYLOAD_KEY) return null;
|
|
3154
|
+
const p = payload[CONNECTION_HANDOVER_APPROVAL_PAYLOAD_KEY];
|
|
3155
|
+
if (!p || typeof p !== "object" || Array.isArray(p)) return null;
|
|
3156
|
+
const r = p;
|
|
3157
|
+
if (Object.keys(r).some((k) => !MEMBERS.includes(k))) return null;
|
|
3158
|
+
const L = CONNECTION_HANDOVER_LIMITS;
|
|
3159
|
+
if (!boundedString(r.connectionId, L.idMax) || !boundedString(r.agentId, L.idMax) || !boundedString(r.agentName, L.agentNameMax) || !boundedString(r.supervisorName, L.agentNameMax) || !boundedString(r.integration, L.integrationMax) || r.account !== void 0 && !boundedString(r.account, L.accountMax)) {
|
|
3160
|
+
return null;
|
|
3161
|
+
}
|
|
3162
|
+
return {
|
|
3163
|
+
connectionId: r.connectionId.trim(),
|
|
3164
|
+
agentId: r.agentId.trim(),
|
|
3165
|
+
agentName: r.agentName.trim(),
|
|
3166
|
+
supervisorName: r.supervisorName.trim(),
|
|
3167
|
+
integration: r.integration.trim(),
|
|
3168
|
+
...r.account !== void 0 ? {
|
|
3169
|
+
account: r.account.trim()
|
|
3170
|
+
} : {}
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
__name(parseConnectionHandoverApprovalPayload, "parseConnectionHandoverApprovalPayload");
|
|
3174
|
+
__name3(parseConnectionHandoverApprovalPayload, "parseConnectionHandoverApprovalPayload");
|
|
3175
|
+
function describeConnectionHandoverApproval(payload) {
|
|
3176
|
+
const parsed = parseConnectionHandoverApprovalPayload(payload);
|
|
3177
|
+
if (!parsed) return null;
|
|
3178
|
+
const agent = `"${oneLine(parsed.agentName)}" (\u2026${handoverAgentIdSuffix(parsed.agentId)})`;
|
|
3179
|
+
const supervisor = `"${oneLine(parsed.supervisorName)}"`;
|
|
3180
|
+
const integration = oneLine(parsed.integration);
|
|
3181
|
+
const account = parsed.account ? ` (${oneLine(parsed.account)})` : "";
|
|
3182
|
+
return [
|
|
3183
|
+
`Give your ${integration} connection${account} to your agent ${agent}.`,
|
|
3184
|
+
"It can then use this account through its tools.",
|
|
3185
|
+
`${supervisor}, the agent asking, supervises it, so it can also reach this account through it: in test runs, previews and the actions its supervision rights allow.`,
|
|
3186
|
+
"You can remove it at any time from the agent's connections."
|
|
3187
|
+
].join("\n");
|
|
3188
|
+
}
|
|
3189
|
+
__name(describeConnectionHandoverApproval, "describeConnectionHandoverApproval");
|
|
3190
|
+
__name3(describeConnectionHandoverApproval, "describeConnectionHandoverApproval");
|
|
3191
|
+
function connectionHandoverApprovalTitle(facts) {
|
|
3192
|
+
return `Give your ${oneLine(facts.integration)} connection to "${oneLine(facts.agentName)}"?`;
|
|
3193
|
+
}
|
|
3194
|
+
__name(connectionHandoverApprovalTitle, "connectionHandoverApprovalTitle");
|
|
3195
|
+
__name3(connectionHandoverApprovalTitle, "connectionHandoverApprovalTitle");
|
|
3196
|
+
function normalizeConnectionHandoverArgs(raw) {
|
|
3197
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3198
|
+
const r = raw;
|
|
3199
|
+
if (Object.keys(r).some((k) => k !== "connectionId" && k !== "approval")) return null;
|
|
3200
|
+
if (!boundedString(r.connectionId, CONNECTION_HANDOVER_LIMITS.idMax)) return null;
|
|
3201
|
+
const approval = normalizeApprovalRef(r.approval);
|
|
3202
|
+
if (!approval) return null;
|
|
3203
|
+
return {
|
|
3204
|
+
connectionId: r.connectionId.trim(),
|
|
3205
|
+
approval
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
__name(normalizeConnectionHandoverArgs, "normalizeConnectionHandoverArgs");
|
|
3209
|
+
__name3(normalizeConnectionHandoverArgs, "normalizeConnectionHandoverArgs");
|
|
3210
|
+
function approvalPayloadCoversConnectionHandover(payload, stored) {
|
|
3211
|
+
const p = parseConnectionHandoverApprovalPayload(payload);
|
|
3212
|
+
if (!p) return false;
|
|
3213
|
+
const text = describeConnectionHandoverApproval(payload) ?? "";
|
|
3214
|
+
if (text.length > CONNECTION_HANDOVER_APPROVAL_CARD_MAX_CHARS || scrubSecretText(text) !== text) return false;
|
|
3215
|
+
const storedAccount = stored.account?.trim() || void 0;
|
|
3216
|
+
return p.connectionId === stored.connectionId && p.agentId === stored.agentId && p.agentName === stored.agentName.trim() && p.supervisorName === stored.supervisorName.trim() && p.integration === stored.integration && p.account === storedAccount;
|
|
3217
|
+
}
|
|
3218
|
+
__name(approvalPayloadCoversConnectionHandover, "approvalPayloadCoversConnectionHandover");
|
|
3219
|
+
__name3(approvalPayloadCoversConnectionHandover, "approvalPayloadCoversConnectionHandover");
|
|
3074
3220
|
var AGENT_METRIC_NAME_PATTERN = /^[a-z][a-z0-9_.]{0,63}$/;
|
|
3075
3221
|
var AGENT_METRIC_LIMITS = {
|
|
3076
3222
|
tagsMax: 4,
|
|
@@ -5972,7 +6118,7 @@ You are ${AGENT_NAME_TOKEN}, the assistant for whoever is chatting with you here
|
|
|
5972
6118
|
|
|
5973
6119
|
## You're just getting started
|
|
5974
6120
|
|
|
5975
|
-
This workspace is new. What you already know about the person lives in your memory \u2014 the "Known about this user" notes are
|
|
6121
|
+
This workspace is new. What you already know about the person lives in your memory \u2014 the "Known about this user" notes are what they've told you, so use them like you've known them all along; never say you don't know something that's written there. They are never proof of who owns or approved something, a permission, or someone's identity \u2014 check those where they're granted. Beyond that, don't pretend. Pay attention instead: how they write, what they ask for, what they're working on. When something matters and you're not sure, ask. One good question beats a wrong guess.
|
|
5976
6122
|
|
|
5977
6123
|
## You have real tools
|
|
5978
6124
|
|