agent-claw: automated task changes

This commit is contained in:
daniel
2026-05-06 18:55:16 -05:00
parent 38905bb1e9
commit 732b00fb66
8494 changed files with 2018127 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
{
"targets": {
"java": {
"package": "software.amazon.awscdk.services.lambda.destinations"
},
"dotnet": {
"namespace": "Amazon.CDK.AWS.Lambda.Destinations"
},
"python": {
"module": "aws_cdk.aws_lambda_destinations"
}
}
}

View File

@@ -0,0 +1,150 @@
# Amazon Lambda Destinations Library
This library provides constructs for adding destinations to a Lambda function.
Destinations can be added by specifying the `onFailure` or `onSuccess` props when creating a function or alias.
## Destinations
The following destinations are supported
* Lambda function
* SQS queue - Only standard SQS queues are supported for failure destinations, FIFO queues are not supported.
* SNS topic
* EventBridge event bus
* S3 bucket
Example with a SNS topic for successful invocations:
```ts
// An sns topic for successful invocations of a lambda function
import * as sns from 'aws-cdk-lib/aws-sns';
const myTopic = new sns.Topic(this, 'Topic');
const myFn = new lambda.Function(this, 'Fn', {
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
// sns topic for successful invocations
onSuccess: new destinations.SnsDestination(myTopic),
})
```
Example with a SQS queue for unsuccessful invocations:
```ts
// An sqs queue for unsuccessful invocations of a lambda function
import * as sqs from 'aws-cdk-lib/aws-sqs';
const deadLetterQueue = new sqs.Queue(this, 'DeadLetterQueue');
const myFn = new lambda.Function(this, 'Fn', {
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
code: lambda.Code.fromInline('// your code'),
// sqs queue for unsuccessful invocations
onFailure: new destinations.SqsDestination(deadLetterQueue),
});
```
See also [Configuring Destinations for Asynchronous Invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations).
### Invocation record
When a lambda function is configured with a destination, an invocation record is created by the Lambda service
when the lambda function completes. The invocation record contains the details of the function, its context, and
the request and response payloads.
The following example shows the format of the invocation record for a successful invocation:
```json
{
"version": "1.0",
"timestamp": "2019-11-24T23:08:25.651Z",
"requestContext": {
"requestId": "c2a6f2ae-7dbb-4d22-8782-d0485c9877e2",
"functionArn": "arn:aws:lambda:sa-east-1:123456789123:function:event-destinations:$LATEST",
"condition": "Success",
"approximateInvokeCount": 1
},
"requestPayload": {
"Success": true
},
"responseContext": {
"statusCode": 200,
"executedVersion": "$LATEST"
},
"responsePayload": "<data returned by the function here>"
}
```
In case of failure, the record contains the reason and error object:
```json
{
"version": "1.0",
"timestamp": "2019-11-24T21:52:47.333Z",
"requestContext": {
"requestId": "8ea123e4-1db7-4aca-ad10-d9ca1234c1fd",
"functionArn": "arn:aws:lambda:sa-east-1:123456678912:function:event-destinations:$LATEST",
"condition": "RetriesExhausted",
"approximateInvokeCount": 3
},
"requestPayload": {
"Success": false
},
"responseContext": {
"statusCode": 200,
"executedVersion": "$LATEST",
"functionError": "Handled"
},
"responsePayload": {
"errorMessage": "Failure from event, Success = false, I am failing!",
"errorType": "Error",
"stackTrace": [ "exports.handler (/var/task/index.js:18:18)" ]
}
}
```
#### Destination-specific JSON format
* For SNS/SQS (`SnsDestionation`/`SqsDestination`), the invocation record JSON is passed as the `Message` to the destination.
* For Lambda (`LambdaDestination`), the invocation record JSON is passed as the payload to the function.
* For EventBridge (`EventBridgeDestination`), the invocation record JSON is passed as the `detail` in the PutEvents call.
The value for the event field `source` is `lambda`, and the value for the event field `detail-type`
is either 'Lambda Function Invocation Result - Success' or 'Lambda Function Invocation Result Failure',
depending on whether the lambda function invocation succeeded or failed. The event field `resource`
contains the function and destination ARNs. See [AWS Events](https://docs.aws.amazon.com/eventbridge/latest/userguide/aws-events.html)
for the different event fields.
* For S3 (`S3Destination`), the invocation record json is stored as a `File` in the destination bucket. The path of a destination
payload file in the configured bucket is `aws/lambda/async/<function-name>/YYYY/MM/DD/YYYY-MM-DDTHH.MM.SS-<Random UUID>`.
### Auto-extract response payload with lambda destination
The `responseOnly` option of `LambdaDestination` allows to auto-extract the response payload from the
invocation record:
```ts
// Auto-extract response payload with a lambda destination
declare const destinationFn: lambda.Function;
const sourceFn = new lambda.Function(this, 'Source', {
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
// auto-extract on success
onSuccess: new destinations.LambdaDestination(destinationFn, {
responseOnly: true,
}),
})
```
In the above example, `destinationFn` will be invoked with the payload returned by `sourceFn`
(`responsePayload` in the invocation record, not the full record).
When used with `onFailure`, the destination function is invoked with the error object returned
by the source function.
Using the `responseOnly` option allows to easily chain asynchronous Lambda functions without
having to deal with data extraction in the runtime code.

View File

@@ -0,0 +1 @@
export * from './lib';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.EventBridgeDestination=void 0,Object.defineProperty(exports,_noFold="EventBridgeDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").EventBridgeDestination;return Object.defineProperty(exports,_noFold="EventBridgeDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.LambdaDestination=void 0,Object.defineProperty(exports,_noFold="LambdaDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").LambdaDestination;return Object.defineProperty(exports,_noFold="LambdaDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.S3Destination=void 0,Object.defineProperty(exports,_noFold="S3Destination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").S3Destination;return Object.defineProperty(exports,_noFold="S3Destination",{enumerable:!0,configurable:!0,value}),value}}),exports.SnsDestination=void 0,Object.defineProperty(exports,_noFold="SnsDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").SnsDestination;return Object.defineProperty(exports,_noFold="SnsDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.SqsDestination=void 0,Object.defineProperty(exports,_noFold="SqsDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").SqsDestination;return Object.defineProperty(exports,_noFold="SqsDestination",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,19 @@
import type { Construct } from 'constructs';
import * as events from '../../aws-events';
import type * as lambda from '../../aws-lambda';
/**
* Use an Event Bridge event bus as a Lambda destination.
*
* If no event bus is specified, the default event bus is used.
*/
export declare class EventBridgeDestination implements lambda.IDestination {
private readonly eventBus?;
/**
* @default - use the default event bus
*/
constructor(eventBus?: events.IEventBus | undefined);
/**
* Returns a destination configuration
*/
bind(_scope: Construct, fn: lambda.IFunction, _options?: lambda.DestinationOptions): lambda.DestinationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBridgeDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var events=()=>{var tmp=require("../../aws-events");return events=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class EventBridgeDestination{eventBus;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_lambda_destinations.EventBridgeDestination",version:"2.252.0"};constructor(eventBus){this.eventBus=eventBus;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_events_IEventBus(eventBus)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgeDestination),error}}bind(_scope,fn,_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(this.eventBus)return this.eventBus.grantPutEventsTo(fn),{destination:this.eventBus.eventBusArn};let eventBus=_scope.node.tryFindChild("DefaultEventBus")||events().EventBus.fromEventBusArn(_scope,"DefaultEventBus",core_1().Stack.of(fn).formatArn({service:"events",resource:"event-bus",resourceName:"default"}));return eventBus.grantPutEventsTo(fn),{destination:eventBus.eventBusArn}}}exports.EventBridgeDestination=EventBridgeDestination;

View File

@@ -0,0 +1,5 @@
export * from './event-bridge';
export * from './lambda';
export * from './s3';
export * from './sns';
export * from './sqs';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.EventBridgeDestination=void 0,Object.defineProperty(exports,_noFold="EventBridgeDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./event-bridge").EventBridgeDestination;return Object.defineProperty(exports,_noFold="EventBridgeDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.LambdaDestination=void 0,Object.defineProperty(exports,_noFold="LambdaDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lambda").LambdaDestination;return Object.defineProperty(exports,_noFold="LambdaDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.S3Destination=void 0,Object.defineProperty(exports,_noFold="S3Destination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./s3").S3Destination;return Object.defineProperty(exports,_noFold="S3Destination",{enumerable:!0,configurable:!0,value}),value}}),exports.SnsDestination=void 0,Object.defineProperty(exports,_noFold="SnsDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./sns").SnsDestination;return Object.defineProperty(exports,_noFold="SnsDestination",{enumerable:!0,configurable:!0,value}),value}}),exports.SqsDestination=void 0,Object.defineProperty(exports,_noFold="SqsDestination",{enumerable:!0,configurable:!0,get:()=>{var value=require("./sqs").SqsDestination;return Object.defineProperty(exports,_noFold="SqsDestination",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,34 @@
import type { Construct } from 'constructs';
import type * as lambda from '../../aws-lambda';
/**
* Options for a Lambda destination
*/
export interface LambdaDestinationOptions {
/**
* Whether the destination function receives only the `responsePayload` of
* the source function.
*
* When set to `true` and used as `onSuccess` destination, the destination
* function will be invoked with the payload returned by the source function.
*
* When set to `true` and used as `onFailure` destination, the destination
* function will be invoked with the error object returned by source function.
*
* See the README of this module to see a full explanation of this option.
*
* @default false The destination function receives the full invocation record.
*/
readonly responseOnly?: boolean;
}
/**
* Use a Lambda function as a Lambda destination
*/
export declare class LambdaDestination implements lambda.IDestination {
private readonly fn;
private readonly options;
constructor(fn: lambda.IFunction, options?: LambdaDestinationOptions);
/**
* Returns a destination configuration
*/
bind(scope: Construct, fn: lambda.IFunction, options?: lambda.DestinationOptions): lambda.DestinationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var event_bridge_1=()=>{var tmp=require("./event-bridge");return event_bridge_1=()=>tmp,tmp},events=()=>{var tmp=require("../../aws-events");return events=()=>tmp,tmp},targets=()=>{var tmp=require("../../aws-events-targets");return targets=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class LambdaDestination{fn;options;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_lambda_destinations.LambdaDestination",version:"2.252.0"};constructor(fn,options={}){this.fn=fn,this.options=options;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_destinations_LambdaDestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaDestination),error}}bind(scope,fn,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!this.options.responseOnly)return this.fn.grantInvoke(fn),{destination:this.fn.functionArn};if(!options)throw new(core_1()).ValidationError((0,literal_string_1().lit)`MustBeOptionsDefinedUsing`,"Options must be defined when using `responseOnly`.",scope);return new(events()).Rule(scope,options.type,{eventPattern:{detailType:[`Lambda Function Invocation Result - ${options.type}`],resources:[`${fn.functionArn}:$LATEST`],source:["lambda"]},targets:[new(targets()).LambdaFunction(this.fn,{event:events().RuleTargetInput.fromEventPath("$.detail.responsePayload")})]}),new(event_bridge_1()).EventBridgeDestination().bind(scope,fn)}}exports.LambdaDestination=LambdaDestination;

View File

@@ -0,0 +1,14 @@
import type { Construct } from 'constructs';
import type * as lambda from '../../aws-lambda';
import type * as s3 from '../../aws-s3';
/**
* Use a S3 bucket as a Lambda destination
*/
export declare class S3Destination implements lambda.IDestination {
private readonly bucket;
constructor(bucket: s3.IBucket);
/**
* Returns a destination configuration
*/
bind(_scope: Construct, fn: lambda.IFunction, _options?: lambda.DestinationOptions): lambda.DestinationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.S3Destination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class S3Destination{bucket;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_lambda_destinations.S3Destination",version:"2.252.0"};constructor(bucket){this.bucket=bucket;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_IBucket(bucket)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,S3Destination),error}}bind(_scope,fn,_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}return this.bucket.grantRead(fn),this.bucket.grantPut(fn),{destination:this.bucket.bucketArn}}}exports.S3Destination=S3Destination;

View File

@@ -0,0 +1,14 @@
import type { Construct } from 'constructs';
import type * as lambda from '../../aws-lambda';
import type * as sns from '../../aws-sns';
/**
* Use a SNS topic as a Lambda destination
*/
export declare class SnsDestination implements lambda.IDestination {
private readonly topic;
constructor(topic: sns.ITopic);
/**
* Returns a destination configuration
*/
bind(_scope: Construct, fn: lambda.IFunction, _options?: lambda.DestinationOptions): lambda.DestinationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SnsDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class SnsDestination{topic;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_lambda_destinations.SnsDestination",version:"2.252.0"};constructor(topic){this.topic=topic;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sns_ITopic(topic)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SnsDestination),error}}bind(_scope,fn,_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}return this.topic.grantPublish(fn),{destination:this.topic.topicArn}}}exports.SnsDestination=SnsDestination;

View File

@@ -0,0 +1,14 @@
import type { Construct } from 'constructs';
import type * as lambda from '../../aws-lambda';
import type * as sqs from '../../aws-sqs';
/**
* Use a SQS queue as a Lambda destination
*/
export declare class SqsDestination implements lambda.IDestination {
private readonly queue;
constructor(queue: sqs.IQueue);
/**
* Returns a destination configuration
*/
bind(_scope: Construct, fn: lambda.IFunction, _options?: lambda.DestinationOptions): lambda.DestinationConfig;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SqsDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class SqsDestination{queue;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_lambda_destinations.SqsDestination",version:"2.252.0"};constructor(queue){this.queue=queue;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sqs_IQueue(queue)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SqsDestination),error}}bind(_scope,fn,_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}return this.queue.grantSendMessages(fn),{destination:this.queue.queueArn}}}exports.SqsDestination=SqsDestination;