Skip to content

本页为英文技术参考;字段、编号与支持状态直接来自同一契约源。中文学习路线见 开发文档。

Tasks ​

Create and observe bounded records of work. A task communicates progress and terminal results; it is not permission to perform the underlying business action.

Contract: nexa.tasks/100. API index.

Typical sequence ​

For plugin-owned work, CreateOwned, Report progress, then Complete or Fail exactly as the result warrants. For Host work, read/watch the returned operation and request cancellation through its supported route.

Behavior and limits ​

Dismiss terminal records when no longer needed. Retry is not mapped in the current Desktop snapshot; a generic retry button must not replay unknown effects with fresh keys.

The recorded Host maps 10 of 10 operations in this group. A mapping is subject to permission, phase, scope, platform and business preconditions. Host snapshot identifies the source revision; negotiate against the actual installed Host.

Operations ​

CreateOwned · Report · Complete · Fail · List · Read · Watch · Cancel · Retry · Dismiss

CreateOwned ​

TaskCreate → OperationRef

PropertyContract
Local SDK method ID1
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
IdQualifiedIdIdentity in this model’s domain. Use the identity issued or declared for this object, not a display name or filesystem path.
TitleLocalizedTextStructured LocalizedText value; follow its linked field contract.
OperationEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.
CancellableboolDomain value named by this field; additional accepted values and bounds are determined by the operation and Host policy.

Successful result

Work has been admitted. Read or watch the owned operation through Tasks to establish its terminal result; admission is not completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_CreateOwned(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_CreateOwned_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Report ​

TaskProgress → Empty

PropertyContract
Local SDK method ID2
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
TaskEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.
StagestringDomain value named by this field; additional accepted values and bounds are determined by the operation and Host policy.
ProgressdoubleDomain value named by this field; additional accepted values and bounds are determined by the operation and Host policy.
ExpectedRevisionRevisionRevision observed before this change. Preserve it exactly; a mismatch requires re-reading and reconciling the target.

Successful result

There is no result payload beyond the encoded Empty model. Check Success; an empty failure value is not successful completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Report(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Report_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Complete ​

TaskCompletion → Empty

PropertyContract
Local SDK method ID3
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
TaskEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.
ResultAbiValueTyped operation output. It is meaningful only when the operation state and result schema permit reading it.
SchemaSchemaRefExact schema identity, version and fingerprint used to validate Value.
ExpectedRevisionRevisionRevision observed before this change. Preserve it exactly; a mismatch requires re-reading and reconciling the target.

Successful result

There is no result payload beyond the encoded Empty model. Check Success; an empty failure value is not successful completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Complete(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Complete_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Fail ​

TaskFailure → Empty

PropertyContract
Local SDK method ID4
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
TaskEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.
ErrorOperationFailureStructured OperationFailure value; follow its linked field contract.
ExpectedRevisionRevisionRevision observed before this change. Preserve it exactly; a mismatch requires re-reading and reconciling the target.

Successful result

There is no result payload beyond the encoded Empty model. Check Success; an empty failure value is not successful completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Fail(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Fail_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

List ​

PageRequest → Page<OperationRecord> (wrapper, item)

PropertyContract
Local SDK method ID5
KindQuery
Permissionnexa.tasks.read
Legal phasesInitialize, PostInitialize, Checkup, Finalize, Active
IdempotencyReadOnly
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
Cursorstring?Opaque continuation or observation cursor. Reuse only in the issuing query/scope; absence and invalidity are different. Nullable; omission is distinct from an empty value. No implicit default is promised by this type.
LimitlongRequested bound on returned items. The Host may impose a smaller domain-specific limit.

Successful result

Read Items and continue with NextCursor while preserving the original query. An absent cursor ends the sequence; an invalid cursor is an error.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. A read-only classification does not bypass budgets or guarantee a failed request can be retried indefinitely. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_List(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_List_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Read ​

EntityRequest → OperationRecord

PropertyContract
Local SDK method ID6
KindQuery
Permissionnexa.tasks.read
Legal phasesInitialize, PostInitialize, Checkup, Finalize, Active
IdempotencyReadOnly
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
IdEntityIdIdentity in this model’s domain. Use the identity issued or declared for this object, not a display name or filesystem path.

Successful result

Decode the exact output model after Success. Preserve its identities, revision and schema metadata for subsequent domain operations.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. A read-only classification does not bypass budgets or guarantee a failed request can be retried indefinitely. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Read(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Read_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Watch ​

WatchRequest → SubscriptionRef

PropertyContract
Local SDK method ID7
KindSubscription
Permissionnexa.tasks.read
Legal phasesInitialize, PostInitialize, Checkup, Finalize, Active
IdempotencyReadOnly
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
TargetEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.
Cursorstring?Opaque continuation or observation cursor. Reuse only in the issuing query/scope; absence and invalidity are different. Nullable; omission is distinct from an empty value. No implicit default is promised by this type.
SchemaSchemaRefExact schema identity, version and fingerprint used to validate Value.

Successful result

Retain the subscription identity, consume bounded batches or callbacks as specified, handle gaps, and release it when no longer needed.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. A read-only classification does not bypass budgets or guarantee a failed request can be retried indefinitely. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Watch(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Watch_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Cancel ​

OperationRequest → OperationRef

PropertyContract
Local SDK method ID8
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
OperationEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.

Successful result

Work has been admitted. Read or watch the owned operation through Tasks to establish its terminal result; admission is not completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Cancel(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Cancel_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Retry ​

OperationRequest → OperationRef

PropertyContract
Local SDK method ID9
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Retry an owned failed/cancelled task where the owner defines replay semantics. Plugin-created tasks reset to Pending under the same ID and a new revision; the plugin must perform and report the work again. Failed workflows use the workflow journal and its recovery rules. Running/completed tasks, foreign tasks and unknown outcomes are rejected. Arbitrary Host file/network/game operations are not implicitly replayed; prepare a new domain plan instead.

Request fields

FieldTypeMeaning
OperationEntityIdIdentity or revision in this model’s domain; preserve ownership and exact spelling.

Successful result

Work has been admitted. Read or watch the owned operation through Tasks to establish its terminal result; admission is not completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Retry(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Retry_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.

Dismiss ​

EntityRequest → Empty

PropertyContract
Local SDK method ID10
KindMutation
Permissionnexa.tasks.write
Legal phasesActive
IdempotencyRequiredKey
Host statusMapped in recorded snapshot

Request fields

FieldTypeMeaning
IdEntityIdIdentity in this model’s domain. Use the identity issued or declared for this object, not a display name or filesystem path.

Successful result

There is no result payload beyond the encoded Empty model. Check Success; an empty failure value is not successful completion.

Failure and retry

Unavailable capability, denied permission, wrong phase, malformed schema or foreign ownership fails the call. Supply a key for the intended effect and retain that key and inputs while resolving an uncertain reply. Do not retry with changed inputs under the same key. Re-read after revision conflicts; cancellation does not prove rollback. Preserve structured errors; see recovery guidance.

C binding (call fragment; the caller supplies the encoded request and buffers):

c
nx_Tasks_Dismiss(&reply, request, &options);

The next resume receives the reply. Check nx_reply_success before nx_Tasks_Dismiss_result. See the complete continuation example and Wasm ownership rules. This fragment is not a standalone guest.


来源: NexaCL-Plugin-SDK · Apache-2.0.

Site documentation: CC BY-SA 4.0. Imported SDK documents: Apache-2.0 as marked.